git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
To: git@vger.kernel.org
Subject: Issue: `git apply` doesn't respect `--work-tree`
Date: Sat, 26 Mar 2016 10:21:45 +0200	[thread overview]
Message-ID: <CA+Tk8fwhjwj9qjgWiiDsJnCupAQT1JJTfYYgDykQhfBnXE09SQ@mail.gmail.com> (raw)

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

                 reply	other threads:[~2016-03-26  8:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+Tk8fwhjwj9qjgWiiDsJnCupAQT1JJTfYYgDykQhfBnXE09SQ@mail.gmail.com \
    --to=ciprian.craciun@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).