Re: Behaviour of git apply --directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks for your detailed explanation.

On 2011-08-22, at 2:28 PM, Junio C Hamano wrote:

> Because the patch application in git is always relative to the top level
> of your working tree no matter where you are, this applies to the path you
> intended it to.

This is where I see the issue. For some reason when I specify --directory, I do have to be somewhere in the directory tree that the patch is going to be applied to. For example, in the following it works if my cwd is the repository root, or src, but not patches.

$ find . -not -path '*.git*'
.
./patches
./patches/LICENSE.patch
./src
./src/LICENSE.txt
$ git status
# On branch master
nothing to commit (working directory clean)
$ cat patches/LICENSE.patch 
diff --git a/LICENSE.txt b/LICENSE.txt
index 2c095c8..64ee213 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,3 +1,4 @@
+GPL GPL GPL
 GNU GENERAL PUBLIC LICENSE
 
               Version 2, June 1991
$ cd patches
$ git apply -v --directory=src LICENSE.patch
$ git status
# On branch master
nothing to commit (working directory clean)
$ cd ..
$ git apply -v --directory=src patches/LICENSE.patch
Checking patch src/LICENSE.txt...
Applied patch src/LICENSE.txt cleanly.
$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   src/LICENSE.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git checkout src
$ cd src
$ git apply -v --directory=src ../patches/LICENSE.patch
Checking patch src/LICENSE.txt...
Applied patch src/LICENSE.txt cleanly.
$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   LICENSE.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

<<attachment: smime.p7s>>


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]