Issue: `git apply` doesn't respect `--work-tree`

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

 



[I've quickly looked at the mailing list archive and didn't see this
issue reported.  However I might be wrong.]


The issue is simple:  `git apply` does not respect the `--work-tree`
argument when called outside the repository.

The version of Git I used is OpenSUSE's official 2.1.4 but also 2.7.4
from their repositories.

The command I used is:
  git --work-tree /.../some-repo --git-dir /.../some-repo/.git apply
/.../some-patch

The current working directory is completely unrelated with the
targeted work-tree (i.e. it is not a subdirectory of the work-tree).


I confirmed the above by using `strace -f -e file -- git ...`, and
although Git picks the correct path for the target work-tree and
switches there, it then switches back to the initial working directory
(the one being invoked from).  See bellow the (redacted) output of
`strace`:

~~~~
getcwd("{current-working-dir}", 129) = 79
stat("{target-working-dir}/.git", {st_mode=S_IFDIR|0700, st_size=300, ...}) = 0
lstat("{target-working-dir}/.git/HEAD", {st_mode=S_IFREG|0600,
st_size=23, ...}) = 0
open("{target-working-dir}/.git/HEAD", O_RDONLY)  = 3
lstat("{target-working-dir}/.git/commondir", 0x7ffe0231eb90) = -1
ENOENT (No such file or directory)
access("{target-working-dir}/.git/objects", X_OK) = 0
access("{target-working-dir}/.git/refs", X_OK)    = 0
lstat("{target-working-dir}/.git/commondir", 0x7ffe0231eb80) = -1
ENOENT (No such file or directory)
access("{home}/.config/git/config", R_OK) = -1 ENOENT (No such file or
directory)
access("{home}/.gitconfig", R_OK) = 0
open("{home}/.gitconfig", O_RDONLY) = 3
access("{target-working-dir}/.git/config", R_OK)  = 0
open("{target-working-dir}/.git/config", O_RDONLY) = 3
stat("{target-working-dir}", {st_mode=S_IFDIR|0700, st_size=880, ...}) = 0
getcwd("{current-working-dir}", 129) = 79
chdir("{target-working-dir}")                     = 0
getcwd("{target-working-dir}", 139)               = 11
lstat("{target-working-dir}", {st_mode=S_IFDIR|0700, st_size=880, ...}) = 0
chdir("{current-working-dir}") = 0
stat("{target-working-dir}/.git", {st_mode=S_IFDIR|0700, st_size=300, ...}) = 0
lstat("{target-working-dir}/.git/commondir", 0x7ffe0231eb40) = -1
ENOENT (No such file or directory)
access("{home}/.config/git/config", R_OK) = -1 ENOENT (No such file or
directory)
access("{home}/.gitconfig", R_OK) = 0
open("{home}/.gitconfig", O_RDONLY) = 3
access("{target-working-dir}/.git/config", R_OK)  = 0
open("{target-working-dir}/.git/config", O_RDONLY) = 3
open("{target-diff}", O_RDONLY)           = 3
open("{home}/.config/git/attributes", O_RDONLY) = -1 ENOENT (No such
file or directory)
open(".gitattributes", O_RDONLY)        = -1 ENOENT (No such file or directory)
open("{target-working-dir}/.git/info/attributes", O_RDONLY) = -1
ENOENT (No such file or directory)
lstat("{file-to-be-patched}", 0x7ffe0231e1f0)       = -1 ENOENT (No
such file or directory)
error: {file-to-be-patched}: No such file or directory
+++ exited with 1 +++


Hope it helps,
Ciprian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]