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

Re: Merge: "git rm bla": "bla: needs merge", but still removes file "bla"

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 17, 2019, 16:44 UTC
Message-ID
<xmqqd0i81ui4.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<5D2ED50D020000A100032435@gwsmtp.uni-regensburg.de>
"Ulrich Windl" <Ulrich.Windl@rz.uni-regensburg.de> writes:
Show 7 quoted lines
> I just had "an interesting case" for a merge with conflicts:
> The merge re-introduced a file that had been renamed (say old one is "bla", and the new one is "foo").
> After merging the changes from bla into foo, I added foo, trying to remove bla:
>> git add foo
>> git rm bla
> bla: needs merge
> rm 'bla'

Yeah, I think I've known about this for a long time. We have an internal call to "update-index --refresh" before starting to remove, because we need to know which path is up-to-date wrt the index, and the machinery for refreshing the index by default gives the "needs merge" message. We never bothered to squelch it.

Perhaps this one-liner would be a sufficient fix.
 builtin/rm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/rm.c b/builtin/rm.c
index 2eacda42b4..19ce95a901 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -273,7 +273,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 	parse_pathspec(&pathspec, 0,
 		       PATHSPEC_PREFER_CWD,
 		       prefix, argv);
-	refresh_index(&the_index, REFRESH_QUIET, &pathspec, NULL, NULL);
+	refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &pathspec, NULL, NULL);
 
 	seen = xcalloc(pathspec.nr, 1);
 
Previous: Ulrich WindlNext: Junio C Hamano
Message 2 of 6 in “Merge: "git rm bla": "bla: needs merge", but still removes file "bla"”
  1. Ulrich WindlJul 17, 2019
  2. Junio C HamanoJul 17, 2019
  3. rm: resolving by removal is not a warning-worthy eventJunio C Hamano, Jul 17, 2019
  4. Jeff KingJul 18, 2019
  5. Junio C HamanoJul 18, 2019
  6. Jeff KingJul 18, 2019

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.