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

Re: crash upon "commit removedfile/newfile removedfile"

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 16, 2022, 21:21 UTC
Message-ID
<xmqqv8wdk308.fsf@gitster.g>
In-Reply-To
<YjJECDbAV0DXUTMB@lena.dartmouth.edu>
Yaroslav Halchenko <yoh@onerussian.com> writes:
Show 7 quoted lines
> 	+ rm p1
> 	+ mkdir p1
> 	+ touch p1/p2
> 	+ git add p1/p2
> 	+ git commit -m 2 p1/p2 p1
> 	error: 'p1' does not have a commit checked out
> 	fatal: updating files failed

Interesting. In this toy example, all the user wants to do is to remove p1 and add p1/p2, so an obvious workaround is to just say "git commit" without any pathspec. But in real life, there may be cases where the user has already staged more than what the first commit wants to have in the index, and want to limit it to a subset by using a pathspec.

I _think_ the response from the command, seeing that the path 'p1' that was previously a file got turned into a directory, is that it is guessing that you are trying to replace 'p1' with a submodule, but because 'p1' is not yet a repository, it cannot 'git add' the commit from the 'p1' submodule to include it in the commit. The guess is wrong and it is a bug that it does not notice it---it knows the user added 'p1/p2' to the index, so 'p1' clearly is a mere subdirectory and not a submodule, so it could have known better than saying "does not have a commit checked out".

By the way, program exit with non-zero status, with "fatal: message", is a controlled error exit, not a crash. Please reserve the word "crash" to describe uncontrolled program death.

Thanks.
Previous: Yaroslav Halchenko
Message 2 of 2 in “crash upon "commit removedfile/newfile removedfile"”
  1. Yaroslav HalchenkoMar 16, 2022
  2. Junio C HamanoMar 16, 2022

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.