Questions tagged [patch]

A patch is file used to alter a source code package, e.g. in order to correct a bug or add a feature.

Patches are generally applied using the patch utility and created with diff.

How do I apply software patches?

210 questions
42
votes
6 answers

How to fix "Hunk #1 FAILED at 1 (different line endings)" message?

I am trying to create a patch with the command git diff sourcefile >/var/lib/laymab/overlay/category/ebuild/files/thepatch.patch when I apply the patch, it gives me $ patch -v GNU patch 2.7.5 $ /usr/bin/patch -p1…
user1709408
  • 669
  • 1
  • 9
  • 14
38
votes
2 answers

How can I apply a -p0 patch from any working directory?

I have a patch with absolute paths that I wish to use. i.e. the first few lines are as follows. --- /usr/share/apps/plasma/packages/org.kde.pager/contents/ui/main.qml 2014-10-10 18:47:23.000000000 +1100 +++…
Sparhawk
  • 19,561
  • 18
  • 86
  • 152
33
votes
3 answers

Patching a binary with dd

I have read this quote (below) several times, most recently here, and am continually puzzled at how dd can be used to patch anything let alone a compiler: The Unix system I used at school, 30 years ago, was very limited in RAM and Disk space.…
amziraro
  • 467
  • 1
  • 4
  • 8
29
votes
5 answers

Check if a file or folder has been patched already

Is it possible to know if a file has been patched already, before apply the patch? I need to do this in a script, any thoughts?
daisy
  • 53,527
  • 78
  • 236
  • 383
27
votes
2 answers

Is this a good way to create a patch?

I would like to create a patch from a specific gcc branch comparing it to the official releases; so when I unpack the tarball from the stable release, I can apply the patch and get the equivalent of what was in that specific branch . It's the first…
user2485710
  • 1,403
  • 4
  • 15
  • 26
26
votes
5 answers

How do I get a linux kernel patch set from the mailing list?

I don't subscribe to the linux-kernel mailing list, but I want to get a set of patches that were posted a few weeks ago and apply them to my kernel for testing. I'm very familiar with patching, building, etc. My question is, what's the best way to…
MadScientist
  • 3,068
  • 2
  • 20
  • 16
25
votes
8 answers

how to use patch and diff to merge two files and automatically resolve conflicts

I have read about diff and patch but I can't figure out how to apply what I need. I guess its pretty simple, so to show my problem take these two files: a.xml #AAABBB
Rafael T
  • 815
  • 3
  • 11
  • 16
24
votes
3 answers

When patching what's the difference between arguments -p0 and -p1?

What's the difference between patch -p0 and patch -p1? Is there any difference at all?
chrisjlee
  • 8,283
  • 16
  • 49
  • 54
23
votes
3 answers

Display only relevant hunks of a diff/patch based on a regexp

git log -G -p is a wonderful tool to search a codebase's history for changes that match the specified pattern. However, it can be overwhelming to locate the relevant hunk in the diff/patch output in a sea of mostly irrelevant hunks. It’s of…
wrksprfct
  • 343
  • 2
  • 6
22
votes
7 answers

Running "patch" without generating *.orig and *.rej files

Is it possible to tell patch not to generate .orig and .rej files? I find it extremely annoying that patch creates these.
TheLegassis
  • 241
  • 2
  • 3
  • 4
22
votes
5 answers

Why use diff/patch when it is easier to just use cp

diff -u file1.txt file2.txt > patchfile creates a patch file which consists of instruction for patch to convert file1.txt to be exactly like file2.txt Can't this be done using cp command instead? I can imagine this to be useful for when the file is…
toddlermenot
  • 323
  • 2
  • 6
22
votes
2 answers

What is the purpose of patches of the linux kernel?

For each Linux kernel version, there is a patch file available for download. For instance, linux-3.12.22 has a corresponding patch-3.12.22. What is the purpose of that patch? To always patch the corresponding kernel before compiling it, or to…
Eleno
  • 1,849
  • 4
  • 27
  • 39
17
votes
2 answers

How to make patch ignore already applied hunks

I have a very large patch file that I'm trying to apply to my code. The problem is, some of the changes in my patch already exist in the code. Is there a way to make patch gracefully ignore the changes that have already been applied? The -N option…
Shum
  • 1,335
  • 4
  • 14
  • 19
17
votes
1 answer

Can’t find file to patch at input line 3

I generated a patch using the diff command with the number of context lines as 1 (-c option). My patch file contents: *** /home/sk/abc/def/src/klm/a.py 2015-05-18 16:25:50.348398554 +0530 --- /opt/abc/def/ghi/klm/a.py 2015-05-18 14:27:13.860503469…
user93868
16
votes
5 answers

Diff of two similar big raw binary files

Let's say I have a 4 GB file abc on my local computer. I have uploaded it to a distant server via SFTP, it took a few hours. Now I have slightly modified the file (probably 50 MB maximum, but not consecutive bytes in this file) locally, and saved it…
Basj
  • 2,351
  • 9
  • 37
  • 70
1
2 3
13 14