{"thread":{"id":"12079","subject":"[PATCH/maint review] Protect get_author_ident_from_commit() from filenames in work tree","startedAt":"2008-02-13T21:45:33Z","lastAt":"2008-02-13T21:45:33Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"68676","messageId":"7vy79oo7ia.fsf@gitster.siamese.dyndns.org","threadId":"12079","inReplyTo":null,"subject":"[PATCH/maint review] Protect get_author_ident_from_commit() from filenames in work tree","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-13T21:45:33Z","receivedAt":"2008-02-13T21:45:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"We used to use \"cat-file commit $commit\" to extract the original\nauthor information from existing commit, but an earlier commit\n5ac2715 (Consistent message encoding while reusing log from an\nexisting commit) changed it to use \"git show -s $commit\".  If\nyou have a file in your work tree that can be interpreted as a\nvalid object name (e.g. \"HEAD\"), this conversion will not work.\n\nDisambiguate by marking the end of revision parameter on the\ncomand line with an explicit \"--\" to fix this.\n\nThis breakage is most visible with rebase when a file called\n\"HEAD\" exists in the worktree.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n git-sh-setup.sh               |    2 +-\n t/t3404-rebase-interactive.sh |   22 ++++++++++++++++++++++\n 2 files changed, 23 insertions(+), 1 deletions(-)\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex aae1409..f388275 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -119,7 +119,7 @@ get_author_ident_from_commit () {\n \t}\n \t'\n \tencoding=$(git config i18n.commitencoding || echo UTF-8)\n-\tgit show -s --pretty=raw --encoding=\"$encoding\" \"$1\" |\n+\tgit show -s --pretty=raw --encoding=\"$encoding\" \"$1\" -- |\n \tLANG=C LC_ALL=C sed -ne \"$pick_author_script\"\n }\n \ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex e33ea4e..e5ed745 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -340,4 +340,26 @@ test_expect_success 'rebase a commit violating pre-commit' '\n \n '\n \n+test_expect_success 'rebase with a file named HEAD in worktree' '\n+\n+\trm -fr .git/hooks &&\n+\tgit reset --hard &&\n+\tgit checkout -b branch3 A &&\n+\n+\t(\n+\t\tGIT_AUTHOR_NAME=\"Squashed Away\" &&\n+\t\texport GIT_AUTHOR_NAME &&\n+\t\t>HEAD &&\n+\t\tgit add HEAD &&\n+\t\tgit commit -m \"Add head\" &&\n+\t\t>BODY &&\n+\t\tgit add BODY &&\n+\t\tgit commit -m \"Add body\"\n+\t) &&\n+\n+\tFAKE_LINES=\"1 squash 2\" git rebase -i to-be-rebased &&\n+\ttest \"$(git show -s --pretty=format:%an)\" = \"Squashed Away\"\n+\n+'\n+\n test_done\n-- \n1.5.4.1.1278.gc75be\n"}]}