File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ refuse_partial () {
2626}
2727
2828TMP_INDEX=
29- THIS_INDEX=" $GIT_DIR /index"
29+ THIS_INDEX=" ${GIT_INDEX_FILE :- $ GIT_DIR/ index} "
3030NEXT_INDEX=" $GIT_DIR /next-index$$ "
3131rm -f " $NEXT_INDEX "
3232save_index () {
Original file line number Diff line number Diff line change @@ -93,4 +93,36 @@ test_expect_success 'commit message from file should override template' '
9393 commit_msg_is "standard input msg"
9494'
9595
96+ test_expect_success ' using alternate GIT_INDEX_FILE (1)' '
97+
98+ cp .git/index saved-index &&
99+ (
100+ echo some new content >file &&
101+ GIT_INDEX_FILE=.git/another_index &&
102+ export GIT_INDEX_FILE &&
103+ git add file &&
104+ git commit -m "commit using another index" &&
105+ git diff-index --exit-code HEAD &&
106+ git diff-files --exit-code
107+ ) &&
108+ cmp .git/index saved-index >/dev/null
109+
110+ '
111+
112+ test_expect_success ' using alternate GIT_INDEX_FILE (2)' '
113+
114+ cp .git/index saved-index &&
115+ (
116+ rm -f .git/no-such-index &&
117+ GIT_INDEX_FILE=.git/no-such-index &&
118+ export GIT_INDEX_FILE &&
119+ git commit -m "commit using nonexistent index" &&
120+ test -z "$(git ls-files)" &&
121+ test -z "$(git ls-tree HEAD)"
122+
123+ ) &&
124+ cmp .git/index saved-index >/dev/null
125+
126+ '
127+
96128test_done
You can’t perform that action at this time.
0 commit comments