From: Yasushi SHOJI <yashi@atmark-techno.com>
To: git@vger.kernel.org
Subject: git diff-index with relative git-dir does not work
Date: Tue, 09 Feb 2010 20:05:28 +0900 [thread overview]
Message-ID: <871vguy8hz.wl@dns1.atmark-techno.com> (raw)
Hi all,
I was just testing --git-dir and --work-tree options and found that
the following test code fails with the current next (2ac040d3).
diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh
index 9df3012..1f90f45 100755
--- a/t/t1501-worktree.sh
+++ b/t/t1501-worktree.sh
@@ -195,4 +195,8 @@ test_expect_success 'make_relative_path handles double slashes in GIT_DIR' '
git --git-dir="$(pwd)//repo.git" --work-tree="$(pwd)" add dummy_file
'
+test_expect_success 'git diff-index' '
+ git --git-dir repo.git --work-tree repo.git/work diff-index HEAD
+'
+
test_done
This is because static variable 'base' in sha1_file_name is already
assigned _before_ setup_work_tree() from cmd_diff_index() is
called. setup_work_tree() eventually chdir to the given work tree dir,
but we use the old base to generate object file path. And that cause
open(2) to fail because the object file path and the current dir is
not in sync any more.
So, is it correct to assume that we must call setup_work_tree()
_before_ any function which call getter/setter in environment.c? This
including open_sha1_file, in this case.
Also, would it be a good idea to make all builtin command to
_explicitly_ call setup_* functions, so that we can find calling order
bug? In that case, we must change the setup functions signature to
allow marking "not interested" or something.
Any thoughts?
--
yashi
next reply other threads:[~2010-02-09 11:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-09 11:05 Yasushi SHOJI [this message]
2010-02-09 11:58 ` git diff-index with relative git-dir does not work Nguyen Thai Ngoc Duy
2010-02-09 13:10 ` Yasushi SHOJI
2010-02-11 10:35 ` Nguyen Thai Ngoc Duy
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871vguy8hz.wl@dns1.atmark-techno.com \
--to=yashi@atmark-techno.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.
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 NNTP newsgroup(s).