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

Make "git resolve" less scary

From
Linus Torvalds <torvalds@osdl.org>
Date
Aug 30, 2005, 05:36 UTC
Message-ID
<Pine.LNX.4.58.0508292230300.3243@g5.osdl.org>

When we resolve a merge between two branches, and it removes a file in the current branch, we notify the person doing the resolve with a big nice notice like

	Removing xyzzy
which is all well and good.

HOWEVER, we also do this when the file was actually removed in the current branch, and we're merging with another branch that didn't have it removed (or, indeed, if the other branch _did_ have it removed, but the common parent was far enough back that the file still existed in there).

And that just doesn't make sense. In that case we're not removing anything: the file didn't exist in the branch we're merging into in the first place. So the message just makes people nervous, and makes no sense.

This has been around forever, but I never bothered to do anything about it.

Until now.

The trivial fix is to only talk about removing files if the file existed in the branch we're merging into, but will not exist in the result.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/git-merge-one-file-script b/git-merge-one-file-script
--- a/git-merge-one-file-script
+++ b/git-merge-one-file-script
@@ -21,7 +21,9 @@ case "${1:-.}${2:-.}${3:-.}" in
 # Deleted in both or deleted in one and unchanged in the other
 #
 "$1.." | "$1.$1" | "$1$1.")
-	echo "Removing $4"
+	if [ "$2" ]; then
+		echo "Removing $4"
+	fi
 	if test -f "$4"; then
 		rm -f -- "$4"
 	fi &&
Message 1 of 1 in “Make "git resolve" less scary”
  1. Linus TorvaldsAug 30, 2005

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.