git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Issue: `git apply` doesn't respect `--work-tree`
@ 2016-03-26  8:21 Ciprian Dorin Craciun
  0 siblings, 0 replies; only message in thread
From: Ciprian Dorin Craciun @ 2016-03-26  8:21 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-03-26  8:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-26  8:21 Issue: `git apply` doesn't respect `--work-tree` Ciprian Dorin Craciun

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).