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

crash upon "commit removedfile/newfile removedfile"

From
Yaroslav Halchenko <yoh@onerussian.com>
Date
Mar 16, 2022, 20:09 UTC
Message-ID
<YjJECDbAV0DXUTMB@lena.dartmouth.edu>
Dear Git Gurus,

Originally ran into in DANDI project [#127] while using datalad [#6558] which uses git and git-annex.

"git commit" seems to not tolerate well whenever both removed path which became a directory and a file under that directory are provided to commit invocation along with the new file path under that directory. But it is ok whenever removed paths (staged or not) are provided to commit.

A reproducer of the former defect and latter behavior is attached, and execution of it on my laptop provides output pasted in full below, where you can see the

	+ 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

problematic use case and git commits just fine whenever removed paths provided in commit invocation:

	+ rm p2 p3
	+ git add p2
	+ git commit -m 'removed and even staged one of them' p2 p3
	[master 209490a] removed and even staged one of them
	 2 files changed, 0 insertions(+), 0 deletions(-)
	 delete mode 100644 p2
	 delete mode 100644 p3

I think such inconsistent behavior is a defect in git. Ideally the former "git commit -m 2 p1/p2 p1" shouldn't crash.

	git version 2.35.1.473.g83b2b277ed
	+ git init
	Initialized empty Git repository in /home/yoh/.tmp/git-h0HvnyH/.git/
	+ touch p1
	+ git add p1
	+ git commit -m 1
	[master (root-commit) c9e0bff] 1
	 1 file changed, 0 insertions(+), 0 deletions(-)
	 create mode 100644 p1
	+ 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
	+ echo 'that did not work when imho should have!'
	that did not work when imho should have!
	+ git commit -m 2 p1/p2
	[master 446b8dc] 2
	 1 file changed, 0 insertions(+), 0 deletions(-)
	 rename p1 => p1/p2 (100%)
	+ echo 'done -- committed just fine'
	done -- committed just fine
	+ touch p2 p3
	+ git add p2 p3
	+ git commit -m 3 p2 p3
	[master 19ffa50] 3
	 2 files changed, 0 insertions(+), 0 deletions(-)
	 create mode 100644 p2
	 create mode 100644 p3
	+ rm p2 p3
	+ git add p2
	+ git commit -m 'removed and even staged one of them' p2 p3
	[master 209490a] removed and even staged one of them
	 2 files changed, 0 insertions(+), 0 deletions(-)
	 delete mode 100644 p2
	 delete mode 100644 p3
	+ echo 'and it worked just fine'

[#127] https://github.com/dandi/dandisets/issues/127#issuecomment-1066934910 [#6558] DataLad bugreport https://github.com/datalad/datalad/issues/6558

-- 
Yaroslav O. Halchenko
Center for Open Neuroscience     http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        
Next: Junio C Hamano
Message 1 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.