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

Re: [PATCHv3 4/4] rm: add absorb a submodules git dir before deletion

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 14, 2016, 23:55 UTC
Message-ID
<xmqqlgvivze9.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20161214224101.6211-5-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 6 quoted lines
>  			if (list.entry[i].is_submodule) {
>  				if (is_empty_dir(path)) {
> +					if (rmdir(path))
> +						die_errno("git rm: '%s'", path);
> +				} else if (file_exists(path))
> +					/* non empty directory: */
Lose colon?
> +					remove_directory_or_die(path);
... otherwise?  I.e.
				else
					???

If we are running "git rm -f <path>", then the path could be a submodule in the index and on the filesystem, it could be (1) already missing, as the user removed an empty submodule directory she is not interested in, (2) a non-directory, e.g. a file or a symbolic link, perhaps because she was trying to reorganize the superproject working tree but decided against it, or (3) something else?

(1) is perfectly OK; we end up with a result without the path, which is what "git rm -f" wanted to do anyway. I am not sure what should happen in (2), and what other corner cases there are for (3), though.

And use of file_exists(path) in the above patch may trigger a strange error message in case (2), as remove_directory_or_die() would say "path is not a directory", to which the user will say "Yes I know, I wanted you to remove it with 'git rm -f'".

Previous: Stefan Beller
Message 8 of 8 in “[PATCHv3 0/4] git-rm absorbs submodule git directory before deletion”
  1. Stefan BellerDec 14, 2016
  2. 2/4 submodule: modernize ok_to_remove_submodule to use argv_arrayStefan Beller, Dec 14, 2016
  3. 1/4 submodule.h: add extern keyword to functionsStefan Beller, Dec 14, 2016
  4. 3/4 submodule: add flags to ok_to_remove_submoduleStefan Beller, Dec 14, 2016
  5. Brandon WilliamsDec 14, 2016
  6. Junio C HamanoDec 14, 2016
  7. 4/4 rm: add absorb a submodules git dir before deletionStefan Beller, Dec 14, 2016
  8. Junio C HamanoDec 14, 2016

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.