{"thread":{"id":"47793","subject":"Left-over COMMIT_EDITMSG file in gitdir","startedAt":"2018-02-08T22:09:32Z","lastAt":"2018-02-08T22:18:42Z","messageCount":2,"participants":["Linus Torvalds","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"338784","messageId":"CA+55aFzaxTrki92C8ih3M3BtYHU3BG8P2SWwvdWiTXZWFDH=1Q@mail.gmail.com","threadId":"47793","inReplyTo":null,"subject":"Left-over COMMIT_EDITMSG file in gitdir","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2018-02-08T22:09:25Z","receivedAt":"2018-02-08T22:09:32Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"This may be intentional, but if so, it's not obvious..\n\nBack long long ago, the original \"git commit\" shell script got rewritten in C.\n\nIn that rewrite, removing some temporary files seems to have been left\nout. At least one: .git/COMMIT_EDITMSG.\n\nIn the original commit.sh shell script, we can find this:\n\n  rm -f \"$GIT_DIR/COMMIT_MSG\" \"$GIT_DIR/COMMIT_EDITMSG\" \"$GIT_DIR/SQUASH_MSG\"\n\nafter creating the commit.  In the C implementation, we do have a\nnumber of \"unlink(...)\" calls:\n\n        unlink(git_path_cherry_pick_head());\n        unlink(git_path_revert_head());\n        unlink(git_path_merge_head());\n        unlink(git_path_merge_msg());\n        unlink(git_path_merge_mode());\n        unlink(git_path_squash_msg());\n\nbut no\n\n        unlink(git_path_commit_editmsg());\n\nand that *seems* to be an oversight.\n\nSimilarly, builtin/tag,c leaves a stale TAG_EDITMSG file behind.\nAgain, that actually did exist in the original shell script, which\nused to do\n\n  trap 'rm -f \"$GIT_DIR\"/TAG_TMP* \"$GIT_DIR\"/TAG_FINALMSG\n\"$GIT_DIR\"/TAG_EDITMSG' 0\n\nwhich caused that file to be removed at exit.\n\nI guess I really don't care much, but those two files struck me when I\nwas doing a \"git gc --prune=now\" and looked at what was still left in\nthe .git directory..\n\nIf this is all intentional, never mind.\n\n               Linus\n"},{"id":"338786","messageId":"xmqqpo5fp1l1.fsf@gitster-ct.c.googlers.com","threadId":"47793","inReplyTo":"CA+55aFzaxTrki92C8ih3M3BtYHU3BG8P2SWwvdWiTXZWFDH=1Q@mail.gmail.com","subject":"Re: Left-over COMMIT_EDITMSG file in gitdir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-02-08T22:18:34Z","receivedAt":"2018-02-08T22:18:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> In that rewrite, removing some temporary files seems to have been left\n> out. At least one: .git/COMMIT_EDITMSG.\n>\n> In the original commit.sh shell script, we can find this:\n>\n>   rm -f \"$GIT_DIR/COMMIT_MSG\" \"$GIT_DIR/COMMIT_EDITMSG\" \"$GIT_DIR/SQUASH_MSG\"\n>\n> after creating the commit.  In the C implementation, we do have a\n> number of \"unlink(...)\" calls:\n> ...\n>\n> but no\n>\n>         unlink(git_path_commit_editmsg());\n>\n> and that *seems* to be an oversight.\n>\n> Similarly, builtin/tag,c leaves a stale TAG_EDITMSG file behind.\n> Again, that actually did exist in the original shell script, which\n> used to do\n>\n>   trap 'rm -f \"$GIT_DIR\"/TAG_TMP* \"$GIT_DIR\"/TAG_FINALMSG\n> \"$GIT_DIR\"/TAG_EDITMSG' 0\n>\n> which caused that file to be removed at exit.\n\nI do not think it was intentional---just a bug in the rewrite.\n\n"}]}