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

Re: git-merge fails when trying to merge from a tag

From
Junio C Hamano <junkio@cox.net>
Date
Dec 13, 2005, 19:21 UTC
Message-ID
<7vy82o951s.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20051213175516.GA3695@hpsvcnb.fc.hp.com>
Carl Baldwin <cnb@fc.hp.com> writes:
> I just tried to merge using a tag object.
Thanks for the report.
> % git merge "Merging release-0.3.1" HEAD refs/tags/release-0.3.1

Once I considered changing commit-tree to take any committish after -p, but thought the command is a low level primitive and the user should know what he is doing, but apparently, git-merge does not know what it is doing ;-).

In fact, I never use "merge" myself, and haven't noticed this breakage until now (you would notice that the Everyday document never talks about "git merge"). Instead, I always do this:

	$ git pull . tag release-0.3.1

But you are right. It is advertised as the end-user command and demonstrated in the tutorial.

How about this patch? I haven't looked at what (old) git-resolve and git-octopus commands do --- they may need similar parameter massaging.

-- >8 -- [PATCH] allow merging any committish

Although "git-merge" is advertised as the end-user level command (instead of being a "git-pull" backend), it was not prepared to take tag objects that point at commits and barfed when fed one. Sanitize the input while we validate them, for which we already have a loop.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/git-merge.sh b/git-merge.sh
index a221daa..d25ae4b 100755
--- a/git-merge.sh
+++ b/git-merge.sh
@@ -97,11 +97,14 @@ head=$(git-rev-parse --verify "$1"^0) ||
 shift
 
 # All the rest are remote heads
+remoteheads=
 for remote
 do
-	git-rev-parse --verify "$remote"^0 >/dev/null ||
+	remotehead=$(git-rev-parse --verify "$remote"^0) ||
 	    die "$remote - not something we can merge"
+	remoteheads="${remoteheads}$remotehead "
 done
+set x $remoteheads ; shift
 
 case "$#" in
 1)
Previous: Carl BaldwinNext: Carl Baldwin
Message 2 of 3 in “git-merge fails when trying to merge from a tag”
  1. Carl BaldwinDec 13, 2005
  2. Junio C HamanoDec 13, 2005
  3. Carl BaldwinDec 14, 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.