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
29
votes
5 answers

How to patch a module's internal functions with mock?

By "internal function", I mean a function that is called from within the same module it is defined in. I am using the mock library, specifically the patch decorators, in my unit tests. They're Django unit tests, but this should apply to any python…
eternicode
  • 6,805
  • 4
  • 33
  • 39
28
votes
1 answer

How do I get a "git log" patch for a specific commit

If I have a commit hash that has not yet been pushed to origin, how can I generate a patch for that commit only. I would like to use git log -p --no-names but can't see a switch to pass in a specific commit hash. Should I be using a different git…
Jonathan Day
  • 18,519
  • 10
  • 84
  • 137
28
votes
5 answers

How to edit Git "add patch" hunks/diffs/lines during selective staging?

I have a source file where 2 features have been added. In order to allow cherry-picking, I'd like to commit that in 2 phases: one for each feature. Until now, in similar situations, using git add -p served me well, to commit one feature while…
bart
  • 7,640
  • 3
  • 33
  • 40
28
votes
3 answers

Create "patch" between revisions?

It seems SVN's "patch" functionality is not exactly what I want. What I really want is to create a diff of files between revisions. So, I'd choose rev1 and rev 2 and end up with a folder containing all files that were changed or added between those…
Josh M.
  • 26,437
  • 24
  • 119
  • 200
27
votes
3 answers

How to support Partial Updates (PATCH) in REST

I want to implement the partial updates for my resource as i have large resource and want to update the partial information from it.I have gone through the following links but not able to figure out whether to use HTTP POST or PATCH methods. HTTP…
prashant
  • 2,181
  • 2
  • 22
  • 37
27
votes
5 answers

How do I get patch to ignore carriage returns?

I'm attempting to apply a patch to a file with Windows line endings on a Linux system and I'm getting conflicts due to the carriage returns in the file. The -l option (ignore whitespace) isn't ignoring the EOL characters. Is there anyway to get…
James McMahon
  • 48,506
  • 64
  • 207
  • 283
25
votes
3 answers

How to overwrite some bytes in the middle of a file with Python?

I'd like to be able to overwrite some bytes at a given offset in a file using Python. My attempts have failed miserably and resulted in: overwriting the bytes at the offset but also truncating the file just after (file mode = "w" or "w+") …
sebastien
  • 347
  • 1
  • 3
  • 5
25
votes
2 answers

git am: Patch format detection failed

I have never used patches with Git before and I need some help. I am trying to apply a patch to a Git repo to test a Wine patch, specifically this patch here. So I did the following: $ git clone git://source.winehq.org/git/wine.git $ cd wine $ nano…
Aaron Franke
  • 3,268
  • 4
  • 31
  • 51
25
votes
3 answers

How do I apply rejected hunks after fixing them?

I'm trying to apply a patch to a file using git apply. The overall patch failed, so I used git apply --reject. Inspecting the generated .rej file showed me what's wrong, now I fixed the problem in the .rej file. But trying to apply the .rej file…
eckes
  • 64,417
  • 29
  • 168
  • 201
25
votes
2 answers

Patch - Patching the class introduces an extra parameter?

First time using patch. I've tried to patch one of my classes for testing. Without the patch attempting to run gets past the test function definition, but with the patch the test function definition apparently requires another parameter and I get…
golmschenk
  • 11,736
  • 20
  • 78
  • 137
24
votes
3 answers

Mocking before importing a module

How can I patch and mock getLogger in this module under test (MUT): # Start of the module under test import logging log = logging.getLogger('some_logger') # ... I would like to do: mock_logging.getLogger.return_value = Mock() However I can't…
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
24
votes
6 answers

showing differences within a line in diff output

This StackOverflow answer has an image of KDiff3 highlighting intra-line differences. Does someone know of a tool which can show the same (ex, via color) on the command line? Another way to think of this is wanting to diff each difference in a…
Brian Harris
  • 2,735
  • 3
  • 22
  • 34
23
votes
3 answers

How to use google-diff-match-patch C# library?

I am looking at http://code.google.com/p/google-diff-match-patch/ and have downloaded the file. When I look at it is 2 files DiffMatchPatch.cs DiffMatchPatchTest.cs When I try to make a new object of DiffMatchPatch.cs I have to pass in some…
Sharpoint
  • 307
  • 1
  • 4
  • 8
23
votes
4 answers

Is it possible to patch a submodule in Git from the parent project?

I have a project main that contains a submodule foo. For this particular project, I would like to make a small change to foo that only applies to this particular project main. main/ + .git + main.c + lib/ | + bar.c + foo/ # My…
nowox
  • 25,978
  • 39
  • 143
  • 293
23
votes
4 answers

Is there a diff tool (patch) that is aware of indentation?

I'm regularly using the gnu-utils patch and diff. Using git, I often do: git diff Often simple changes create a large patch because the only that changed was, for example, adding a if/else loop and everything inside is indented to the…
augustin
  • 14,373
  • 13
  • 66
  • 79