@matheusbsbs / matheus-bagliano / commits / 859a4dbcad
Fork 0

Make GIT_INDEX_FILE apply to git-commit

Currently, when committing, git-commit ignore the value of GIT_INDEX_FILE, and always use $GIT_DIR/index. This patch fix it. Signed-off-by: Rémi Vanicat <vanicat@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Rémi Vanicat committed Nov 11, 2007 at 13:28 UTC 859a4dbcadd200ae955fe36d0c4fb3f4bce0e032
2 files changed +33 -1
git-commit.sh
+1 -1
@@ -26,7 +26,7 @@ refuse_partial () {
26 }
27
28 TMP_INDEX=
29 -THIS_INDEX="$GIT_DIR/index"
29 +THIS_INDEX="${GIT_INDEX_FILE:-$GIT_DIR/index}"
30 NEXT_INDEX="$GIT_DIR/next-index$$"
31 rm -f "$NEXT_INDEX"
32 save_index () {
t/t7500-commit.sh
+32
@@ -93,4 +93,36 @@ test_expect_success 'commit message from file should override template' '
93 commit_msg_is "standard input msg<unknown>"
94 '
95
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 +
128 test_done