{"thread":{"id":"10803","subject":"[PATCH v3] Make GIT_INDEX_FILE apply to git-commit","startedAt":"2007-11-11T12:28:08Z","lastAt":"2007-11-12T18:41:29Z","messageCount":3,"participants":["Rémi Vanicat","Junio C Hamano","Remi Vanicat"],"isPatch":true,"patchVersion":3,"patchTotal":null},"messages":[{"id":"59313","messageId":"87r6ixj7af.dlv@vanicat.homelinux.org","threadId":"10803","inReplyTo":null,"subject":"[PATCH v3] Make GIT_INDEX_FILE apply to git-commit","fromName":"Rémi Vanicat","fromEmail":"vanicat@debian.org","sentAt":"2007-11-11T12:28:08Z","receivedAt":"2007-11-11T12:28:08Z","isPatch":true,"sender":{"key":"vanicat@debian.org","avatar":"https://gravatar.com/avatar/cd491a7f4c221349809a60f88fc21326b97cce2a705e318898aa74851db92409?d=mp&s=160"},"body":"Currently, when committing, git-commit ignore the value of\nGIT_INDEX_FILE, and always use $GIT_DIR/index. This patch\nfix it.\n\nSigned-off-by: Rémi Vanicat <vanicat@debian.org>\n---\n git-commit.sh     |    2 +-\n t/t7500-commit.sh |   13 +++++++++++++\n 2 files changed, 14 insertions(+), 1 deletions(-)\n\ndiff --git a/git-commit.sh b/git-commit.sh\nindex fcb8443..6490045 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -26,7 +26,7 @@ refuse_partial () {\n }\n \n TMP_INDEX=\n-THIS_INDEX=\"$GIT_DIR/index\"\n+THIS_INDEX=\"${GIT_INDEX_FILE:-$GIT_DIR/index}\"\n NEXT_INDEX=\"$GIT_DIR/next-index$$\"\n rm -f \"$NEXT_INDEX\"\n save_index () {\ndiff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\nindex abbf54b..3e5abef 100755\n--- a/t/t7500-commit.sh\n+++ b/t/t7500-commit.sh\n@@ -93,4 +93,17 @@ test_expect_success 'commit message from file should override template' '\n        commit_msg_is \"standard input msg\"\n '\n \n+test_expect_success 'using GIT_INDEX_FILE' '\n+\n+       echo \"some new content\" >file &&\n+       GIT_INDEX_FILE=.git/another_index git add file &&\n+       GIT_INDEX_FILE=.git/another_index \\\n+               git commit -m \"commit using another index\" &&\n+       git reset HEAD &&\n+       git diff HEAD -- file >current &&\n+       touch empty-file &&\n+       diff empty-file current\n+\n+'\n+\n test_done\n-- \n1.5.3.5\n"},{"id":"59371","messageId":"7vlk94d043.fsf@gitster.siamese.dyndns.org","threadId":"10803","inReplyTo":"87r6ixj7af.dlv@vanicat.homelinux.org","subject":"Re: [PATCH v3] Make GIT_INDEX_FILE apply to git-commit","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-11T19:59:40Z","receivedAt":"2007-11-11T19:59:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Rémi Vanicat <vanicat@debian.org> writes:\n\n> @@ -26,7 +26,7 @@ refuse_partial () {\n>  }\n>  \n>  TMP_INDEX=\n> -THIS_INDEX=\"$GIT_DIR/index\"\n> +THIS_INDEX=\"${GIT_INDEX_FILE:-$GIT_DIR/index}\"\n>  NEXT_INDEX=\"$GIT_DIR/next-index$$\"\n>  rm -f \"$NEXT_INDEX\"\n>  save_index () {\n\nThis is just a \"purist\" question, but I wonder if we want to\ndifferentiate the case where GIT_INDEX_FILE is set to empty and\nGIT_INDEX_FILE is not set at all?\n\n> diff --git a/t/t7500-commit.sh b/t/t7500-commit.sh\n> index abbf54b..3e5abef 100755\n> --- a/t/t7500-commit.sh\n> +++ b/t/t7500-commit.sh\n> @@ -93,4 +93,17 @@ test_expect_success 'commit message from file should override template' '\n>         commit_msg_is \"standard input msg\"\n>  '\n>  \n> +test_expect_success 'using GIT_INDEX_FILE' '\n> +\n> +       echo \"some new content\" >file &&\n> +       GIT_INDEX_FILE=.git/another_index git add file &&\n> +       GIT_INDEX_FILE=.git/another_index \\\n> +               git commit -m \"commit using another index\" &&\n\nTests that git-commit does not choke on committing the addion a\nnew 'file'.\n\n> +       git reset HEAD &&\n> +       git diff HEAD -- file >current &&\n> +       touch empty-file &&\n> +       diff empty-file current\n\nClobbers the index that the above GIT_INDEX_FILE trick should\nnot have touched before making sure of that, which is bad, and\nthen makes sure that the new file actually has the right\ncontents.\n\nSo, what I would suggest is:\n\n * Your \"GIT_INDEX_FILE=... git-commit\" test -- git-commit\n   should not fail;\n\n + Test that the path you modified in the above commit (in this\n   case, 'file') matches between index you used in the commit\n   and the resulting commit;\n\n * Test that the path you modified in the above commit matches\n   between the HEAD, the alternate index and the work tree (your\n   latter test).\n\n + Test that the original index the above wanted to preserve was\n   not clobbered by git-commit;\n\n + Test git-commit runs sensibly even when it is given a\n   nonexistent file as GIT_INDEX_FILE.\n\nPerhaps like this, instead of your patch to t/t7500:\n\n\ttest_expect_success 'using alternate GIT_INDEX_FILE (1)' '\n\t\n\t\tcp .git/index saved-index &&\n\t\t(\n\t\t\techo some new content >file &&\n\t\t        GIT_INDEX_FILE=.git/another_index &&\n\t\t\texport GIT_INDEX_FILE &&\n\t\t\tgit add file &&\n\t\t\tgit commit -m \"commit using another index\" &&\n\t\t\tgit diff-index --exit-code HEAD &&\n\t\t\tgit diff-files --exit-code\n\t\t) &&\n\t\tcmp .git/index saved-index >/dev/null\n\t\n\t'\n\t\n\ttest_expect_success 'using alternate GIT_INDEX_FILE (2)' '\n\t\n\t\tcp .git/index saved-index &&\n\t\t(\n\t\t\trm -f .git/no-such-index &&\n\t\t\tGIT_INDEX_FILE=.git/no-such-index &&\n\t\t\texport GIT_INDEX_FILE &&\n\t\t\tgit commit -m \"commit using nonexistent index\" &&\n\t\t\ttest -z \"$(git ls-files)\" &&\n\t\t\ttest -z \"$(git ls-tree HEAD)\"\n\t\n\t\t) &&\n\t\tcmp .git/index saved-index >/dev/null\n\t\n\t'\n"},{"id":"59548","messageId":"87d4ufi9wm.dlv@vanicat.homelinux.org","threadId":"10803","inReplyTo":"7vlk94d043.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v3] Make GIT_INDEX_FILE apply to git-commit","fromName":"Remi Vanicat","fromEmail":"vanicat@debian.org","sentAt":"2007-11-12T18:41:29Z","receivedAt":"2007-11-12T18:41:29Z","isPatch":true,"sender":{"key":"vanicat@debian.org","avatar":"https://gravatar.com/avatar/cd491a7f4c221349809a60f88fc21326b97cce2a705e318898aa74851db92409?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Rémi Vanicat <vanicat@debian.org> writes:\n>\n>> @@ -26,7 +26,7 @@ refuse_partial () {\n>>  }\n>>  \n>>  TMP_INDEX=\n>> -THIS_INDEX=\"$GIT_DIR/index\"\n>> +THIS_INDEX=\"${GIT_INDEX_FILE:-$GIT_DIR/index}\"\n>>  NEXT_INDEX=\"$GIT_DIR/next-index$$\"\n>>  rm -f \"$NEXT_INDEX\"\n>>  save_index () {\n>\n> This is just a \"purist\" question, but I wonder if we want to\n> differentiate the case where GIT_INDEX_FILE is set to empty and\n> GIT_INDEX_FILE is not set at all?\n\nWell, It's my first patch to git, and I overlook it\n\n> So, what I would suggest is:\n>\n>  * Your \"GIT_INDEX_FILE=... git-commit\" test -- git-commit\n>    should not fail;\n>\n>  + Test that the path you modified in the above commit (in this\n>    case, 'file') matches between index you used in the commit\n>    and the resulting commit;\n>\n>  * Test that the path you modified in the above commit matches\n>    between the HEAD, the alternate index and the work tree (your\n>    latter test).\n>\n>  + Test that the original index the above wanted to preserve was\n>    not clobbered by git-commit;\n>\n>  + Test git-commit runs sensibly even when it is given a\n>    nonexistent file as GIT_INDEX_FILE.\n>\n> Perhaps like this, instead of your patch to t/t7500:\n>\n> \ttest_expect_success 'using alternate GIT_INDEX_FILE (1)' '\n> \t\n> \t\tcp .git/index saved-index &&\n> \t\t(\n> \t\t\techo some new content >file &&\n> \t\t        GIT_INDEX_FILE=.git/another_index &&\n> \t\t\texport GIT_INDEX_FILE &&\n> \t\t\tgit add file &&\n> \t\t\tgit commit -m \"commit using another index\" &&\n> \t\t\tgit diff-index --exit-code HEAD &&\n> \t\t\tgit diff-files --exit-code\n> \t\t) &&\n> \t\tcmp .git/index saved-index >/dev/null\n> \t\n> \t'\n> \t\n> \ttest_expect_success 'using alternate GIT_INDEX_FILE (2)' '\n> \t\n> \t\tcp .git/index saved-index &&\n> \t\t(\n> \t\t\trm -f .git/no-such-index &&\n> \t\t\tGIT_INDEX_FILE=.git/no-such-index &&\n> \t\t\texport GIT_INDEX_FILE &&\n> \t\t\tgit commit -m \"commit using nonexistent index\" &&\n> \t\t\ttest -z \"$(git ls-files)\" &&\n> \t\t\ttest -z \"$(git ls-tree HEAD)\"\n> \t\n> \t\t) &&\n> \t\tcmp .git/index saved-index >/dev/null\n> \t\n> \t'\n\nSeem, good, I will use this.\n\n-- \nRémi Vanicat\n"}]}