Questions tagged [patch]

A patch is a piece of software designed to fix problems with, or update a computer program or its supporting data. This includes fixing security vulnerabilities and other bugs, and improving the usability or performance.

Programmers publish and apply patches in various forms. Because proprietary software authors withhold their source code, their patches are distributed as binary executables instead of source. This type of patch modifies the program executable—the program the user actually runs—either by modifying the binary file to include the fixes or by completely replacing it.

Patches can also circulate in the form of source code modifications. In these cases, the patches consist of textual differences between two source code files. These types of patches commonly come out of open source projects. In these cases, developers expect users to compile the new or changed files themselves.

Because the word "patch" carries the connotation of a small fix, large fixes may use different nomenclature. Bulky patches or patches that significantly change a program may circulate as "service packs" or as "software updates". Microsoft Windows NT and its successors (including Windows 2000, Windows XP, and later versions) use the "service pack" terminology.

In several Unix-like systems, particularly Linux, updates between releases are delivered as new software packages. These updates are in the same format as the original installation so they can be used either to update an existing package in-place (effectively patching) or be used directly for new installations.

2809 questions
77
votes
9 answers

How do I create binary patches?

What's the best way to go about making a patch for a binary file? I want it to be simple for users to apply (a simple patch application would be nice). Running diff on the file just gives Binary files [...] differ.
Mike
  • 23,892
  • 18
  • 70
  • 90
72
votes
8 answers

Write byte at address (hexedit/modify binary from the command line)

Is there any straightforward way to modify a binary from the commandline? Let's say I know that my binary contains 1234ABCD and I want to change it to 12FFABCD or FFFFABCD or maybe even FF34FFABC0 (you get the idea) :-) How might I achieve that…
Josh
  • 721
  • 1
  • 5
  • 4
70
votes
4 answers

In git, how do I create a single patch for the last 2+ revisions?

I would like to create a patch for the last 2 revisions. git format-patch -2 gives me 2 patch files, one for each revision git format-patch HEAD~2..HEAD gives the same thing. git format-patch -1 HEAD~2..HEAD gives a single file, but only contains…
Matthew
  • 28,056
  • 26
  • 104
  • 170
68
votes
3 answers

How to create patch between two tags with multiple commits between them?

I have two tags in my git in same branch. There are at least 5-6 commits between them. How can I create a single patch between the two tags so that it can be applied to a GitHub repo?
Rishi
  • 3,499
  • 8
  • 35
  • 54
67
votes
8 answers

git: generate a single patch across multiple commits

This is the situation: We created a "private" repo (say our-repo) based off an existing open-source git repo (say source-repo). We have been developing code and have around 20 merges into our repo. So, the repo moved from "State_Initial" to…
SimpleCoder
  • 1,101
  • 2
  • 10
  • 21
65
votes
4 answers

How to make svn diff produce file that patch would apply, when svn cp or svn mv was used?

The scenario is: svn cp or mv some file modify that file svn diff > mypatch On other machine (same working copy, but no changes): Try to apply mypatch. Fail -> tries to modify unexistant file. How can I make svn diff produce patch-appliable…
Paweł Hajdan
  • 18,074
  • 9
  • 49
  • 65
65
votes
2 answers

Python mock patch a function called by another function

def f1(): return 10, True def f2(): num, stat = f1() return 2*num, stat How do I use python's mock library to patch f1() and return a custom result so I could test f2()? Edited: Is there something wrong with my test? This doesn't seem…
Nam Ngo
  • 2,093
  • 1
  • 23
  • 30
64
votes
2 answers

Create a patch including specific files in git

Let's say that I am 7 commits ahead of the origin/master repo. I would like to create a patch that includes in the patch specific files that were changed, not all the files. Or equivalent exclude specific files from the patch that were changed. How…
vasilakisfil
  • 2,279
  • 4
  • 24
  • 31
63
votes
4 answers

How to do PATCH properly in strongly typed languages based on Spring - example

According to my knowledge: PUT - update object with its whole representation (replace) PATCH - update object with given fields only (update) I'm using Spring to implement a pretty simple HTTP server. When a user wants to update his data he needs…
KlimczakM
  • 12,576
  • 11
  • 64
  • 83
62
votes
3 answers

Creating a Patch with TFS

Creating a patch is very easy in SubVersion, With Tortoise, you right-click and select Create Patch. But for the life of me, I can't find this functionality in TFS. Is this possible? If not, what's the standard way to submit patches in open source…
swilliams
  • 48,060
  • 27
  • 100
  • 130
61
votes
3 answers

How to make and apply SVN patch?

I would like to make a SVN type patch file for httpd.conf so I can easily apply it to other hosts. If I do cd /root diff -Naur /etc/httpd/conf/httpd.conf_original /etc/httpd/conf/httpd.conf > httpd.patch cp /etc/httpd/conf/httpd.conf_original…
Sandra Schlichting
  • 25,050
  • 33
  • 110
  • 162
56
votes
7 answers

Creating a patch file from a diff of 2 folders

I made some changes to an open source project without taking time to create proper patch files. Now, the maintainer of the project released a new version, and among new and edited files, there are a bunch of renamed files. What is the best way to…
karatchov
  • 947
  • 2
  • 9
  • 14
56
votes
4 answers

git create patch with diff

I tried doing git diff 13.1_dev sale_edit > patch.diff Then I tried doing git apply patch.diff in another branch, but I got patch does not apply. How do I create patch files from diffs that I can use with git apply? Errors received: $ git apply…
Chris Muench
  • 17,444
  • 70
  • 209
  • 362
54
votes
6 answers

How to apply SVN diff to Git?

I have my projects in 2 repositories. One under SVN and one under Git. Whenever I change something in SVN I want to do the same thing to the Git repository. Say I make a change to SVN repository, producing revision 125. How would I apply these same…
Andriy Drozdyuk
  • 58,435
  • 50
  • 171
  • 272
51
votes
5 answers

How to create a patch without commit in Git?

I did some search online. I know that you can use format-patch after commit, but my situation is a little different. I want to create a patch, similar to "dpk" in SVN, so I can send it out for code review, but I don't yet want to commit it. How can…
doglin
  • 1,651
  • 4
  • 28
  • 38