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

Re: [PATCH] rm: resolving by removal is not a warning-worthy event

From
Jeff King <peff@peff.net>
Date
Jul 18, 2019, 20:26 UTC
Message-ID
<20190718202656.GC22038@sigill.intra.peff.net>
In-Reply-To
<xmqqims0z99w.fsf_-_@gitster-ct.c.googlers.com>
On Wed, Jul 17, 2019 at 01:38:35PM -0700, Junio C Hamano wrote:
Show 23 quoted lines
> When resolving a conflict on a path in favor of removing it, using
> "git rm" on it is the standard way to do so.  The user however is
> greeted with a "needs merge" message during that operation:
> 
> 	$ git merge side-branch
> 	$ edit conflicted-path-1
> 	$ git add conflicted-path-1
> 	$ git rm conflicted-path-2
> 	conflicted-path-2: needs merge
> 	rm 'conflicted-path-2'
> 
> The removal by "git rm" does get performed, but an uninitiated user
> may find it confusing, "needs merge? so I need to resolve conflict
> before being able to remove it???"
> 
> The message is coming from "update-index --refresh" that is called
> internally to make sure "git rm" knows which paths are clean and
> which paths are dirty, in order to prevent removal of paths modified
> relative to the index without the "-f" option.  We somehow ended up
> not squelching this message which seeped through to the UI surface.
> 
> Use the same mechanism used by "git commit", "git describe", etc. to
> squelch the message.
Nicely explained, and the patch makes sense.
> +test_expect_success 'Resolving by removal is not a warning-worthy event' '
> +	git reset -q --hard &&
> +	test_when_finished "rm -f .git/index.lock msg && git reset -q --hard" &&
> +	qfwfq=$(echo qfwfq | git hash-object -w --stdin) &&

I'd have called this "$blob" for my own sanity in typing later lines, but OK. :)

Show 5 quoted lines
> +	do
> +		echo "100644 $qfwfq $stage	qfwfq"
> +	done | git update-index --index-info &&
> +	git rm qfwfq >msg &&
> +	test_i18ngrep ! "needs merge" msg &&
Should we capture stderr from "git rm", too, to cover all bases?
-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 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.