git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Left-over COMMIT_EDITMSG file in gitdir

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 8, 2018, 22:09 UTC
Message-ID
<CA+55aFzaxTrki92C8ih3M3BtYHU3BG8P2SWwvdWiTXZWFDH=1Q@mail.gmail.com>
This may be intentional, but if so, it's not obvious..
Back long long ago, the original "git commit" shell script got rewritten in C.

In that rewrite, removing some temporary files seems to have been left out. At least one: .git/COMMIT_EDITMSG.

In the original commit.sh shell script, we can find this:
  rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"

after creating the commit. In the C implementation, we do have a number of "unlink(...)" calls:

        unlink(git_path_cherry_pick_head());
        unlink(git_path_revert_head());
        unlink(git_path_merge_head());
        unlink(git_path_merge_msg());
        unlink(git_path_merge_mode());
        unlink(git_path_squash_msg());
but no
        unlink(git_path_commit_editmsg());
and that *seems* to be an oversight.

Similarly, builtin/tag,c leaves a stale TAG_EDITMSG file behind. Again, that actually did exist in the original shell script, which used to do

  trap 'rm -f "$GIT_DIR"/TAG_TMP* "$GIT_DIR"/TAG_FINALMSG
"$GIT_DIR"/TAG_EDITMSG' 0
which caused that file to be removed at exit.

I guess I really don't care much, but those two files struck me when I was doing a "git gc --prune=now" and looked at what was still left in the .git directory..

If this is all intentional, never mind.
               Linus
Next: Junio C Hamano
Message 1 of 2 in “Left-over COMMIT_EDITMSG file in gitdir”
  1. Linus TorvaldsFeb 8, 2018
  2. Junio C HamanoFeb 8, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.