A bug in git-add with GIT_DIR?
- Date: Thu, 20 Dec 2018 10:37:21 +0200
- From: Orgad Shaneh <orgads@xxxxxxxxx>
- Subject: A bug in git-add with GIT_DIR?
I played around with t5403-post-checkout-hook, and noticed that its
state is not exactly what I'd expect it to be.
The test setup is:
echo Data for commit0. >a &&
echo Data for commit0. >b &&
git update-index --add a &&
git update-index --add b &&
tree0=$(git write-tree) &&
commit0=$(echo setup | git commit-tree $tree0) &&
git update-ref refs/heads/master $commit0 &&
git clone ./. clone1 &&
git clone ./. clone2 &&
GIT_DIR=clone2/.git git branch new2 &&
echo Data for commit1. >clone2/b &&
GIT_DIR=clone2/.git git add clone2/b &&
GIT_DIR=clone2/.git git commit -m new2
Now, the line before the last one executes git add clone2/b with GIT_DIR set.
I'd expect that to add b inside clone2, but instead it adds an
inexistent clone2/clone2/b, and if I stop at this line, then the
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: clone2/b
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
Is this the intended behavior? It looks like that's not what the test
meant to do anyway...
And if I change it to (cd clone2 && git add b), then the commits look
reasonable, but step 6 fails.