{"thread":{"id":"2822","subject":"git-merge fails when trying to merge from a tag","startedAt":"2005-12-13T17:55:16Z","lastAt":"2005-12-14T00:00:12Z","messageCount":3,"participants":["Carl Baldwin","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"13571","messageId":"20051213175516.GA3695@hpsvcnb.fc.hp.com","threadId":"2822","inReplyTo":null,"subject":"git-merge fails when trying to merge from a tag","fromName":"Carl Baldwin","fromEmail":"cnb@fc.hp.com","sentAt":"2005-12-13T17:55:16Z","receivedAt":"2005-12-13T17:55:16Z","isPatch":false,"sender":{"key":"cnb@fc.hp.com","avatar":null},"body":"Greetings,\n\nI just tried to merge using a tag object.  I expected this to work just fine\nsince the tag refers to a commit object and is therefore committish.  The very\nsame merge command except with '^{}' appended to the tag name to select the\ncommit object worked just fine.  Below you'll find some interesting output.\n\nCheers,\nCarl\n\nPS  I used git-bisect for the first time this morning.  I was VERY impressed.\nAnyway, on to the output...\n\n% git --version\ngit version 0.99.9m\n\n% git merge \"Merging release-0.3.1\" HEAD refs/tags/release-0.3.1\nTrying really trivial in-index merge...\nfatal: Merge requires file-level merging\nNope.\nMerging HEAD with refs/tags/release-0.3.1\nMerging:\ndf17837d378c5ee07a26c97ac1bfc3fb3f7bacbb Fix test of  string\nf2aa1e01ae0f1b0ea9354f2ea2c7444b5efc8ac5 Merging release-0.2.1\nfound 1 common ancestor(s):\n43c6310a463aee1c2cbd882b81a596e429bc7f6c Commit msg\nAuto-merging scripts/config.sh\n\nfatal: 4c29c70d1d290807c2757eabaefb607b8fd7b595 is not a valid 'commit' object\n\n% git-cat-file tag 4c29c70d1d290807c2757eabaefb607b8fd7b595\nobject f2aa1e01ae0f1b0ea9354f2ea2c7444b5efc8ac5\ntype commit\ntag release-0.3.1\ntagger Carl N. Baldwin <carl@ecbaldwin.net> 1134493064 -0700\n... (The rest of the tag object looks just as you'd expect)\n\n% git checkout -f # To reset changes done by failed merge\n% git merge \"Merging release-0.3.1\" HEAD refs/tags/release-0.3.1^{}\nTrying really trivial in-index merge...\nfatal: Merge requires file-level merging\nNope.\nMerging HEAD with refs/tags/release-0.3.1^{}\nMerging:\ndf17837d378c5ee07a26c97ac1bfc3fb3f7bacbb Fix test of  string\nf2aa1e01ae0f1b0ea9354f2ea2c7444b5efc8ac5 Merging release-0.2.1\nfound 1 common ancestor(s):\n43c6310a463aee1c2cbd882b81a596e429bc7f6c Commit msg\nAuto-merging scripts/config.sh\n\nMerge 5612809ea11c9709e3a5282f8002c1f993e127d6, made by recursive.\n scripts/config.sh |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\n-- \n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n Carl Baldwin                        Systems VLSI Laboratory\n Hewlett Packard Company\n MS 88                               work: 970 898-1523\n 3404 E. Harmony Rd.                 work: Carl.N.Baldwin@hp.com\n Fort Collins, CO 80525              home: Carl@ecBaldwin.net\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"},{"id":"13574","messageId":"7vy82o951s.fsf@assigned-by-dhcp.cox.net","threadId":"2822","inReplyTo":"20051213175516.GA3695@hpsvcnb.fc.hp.com","subject":"Re: git-merge fails when trying to merge from a tag","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-13T19:21:19Z","receivedAt":"2005-12-13T19:21:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carl Baldwin <cnb@fc.hp.com> writes:\n\n> I just tried to merge using a tag object.\n\nThanks for the report.\n\n> % git merge \"Merging release-0.3.1\" HEAD refs/tags/release-0.3.1\n\nOnce I considered changing commit-tree to take any committish\nafter -p, but thought the command is a low level primitive and\nthe user should know what he is doing, but apparently, git-merge\ndoes not know what it is doing ;-).\n\nIn fact, I never use \"merge\" myself, and haven't noticed this\nbreakage until now (you would notice that the Everyday document\nnever talks about \"git merge\").  Instead, I always do this:\n\n\t$ git pull . tag release-0.3.1\n\nBut you are right.  It is advertised as the end-user\ncommand and demonstrated in the tutorial.\n\nHow about this patch?  I haven't looked at what (old)\ngit-resolve and git-octopus commands do --- they may need\nsimilar parameter massaging.\n\n-- >8 --\n[PATCH] allow merging any committish\n\nAlthough \"git-merge\" is advertised as the end-user level command\n(instead of being a \"git-pull\" backend), it was not prepared to\ntake tag objects that point at commits and barfed when fed one.\nSanitize the input while we validate them, for which we already\nhave a loop.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\ndiff --git a/git-merge.sh b/git-merge.sh\nindex a221daa..d25ae4b 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -97,11 +97,14 @@ head=$(git-rev-parse --verify \"$1\"^0) ||\n shift\n \n # All the rest are remote heads\n+remoteheads=\n for remote\n do\n-\tgit-rev-parse --verify \"$remote\"^0 >/dev/null ||\n+\tremotehead=$(git-rev-parse --verify \"$remote\"^0) ||\n \t    die \"$remote - not something we can merge\"\n+\tremoteheads=\"${remoteheads}$remotehead \"\n done\n+set x $remoteheads ; shift\n \n case \"$#\" in\n 1)\n"},{"id":"13596","messageId":"20051214000012.GA13925@hpsvcnb.fc.hp.com","threadId":"2822","inReplyTo":"7vy82o951s.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-merge fails when trying to merge from a tag","fromName":"Carl Baldwin","fromEmail":"cnb@fc.hp.com","sentAt":"2005-12-14T00:00:12Z","receivedAt":"2005-12-14T00:00:12Z","isPatch":false,"sender":{"key":"cnb@fc.hp.com","avatar":null},"body":"On Tue, Dec 13, 2005 at 11:21:19AM -0800, Junio C Hamano wrote:\n> Carl Baldwin <cnb@fc.hp.com> writes:\n> \n> > I just tried to merge using a tag object.\n> \n> Thanks for the report.\n> \n> > % git merge \"Merging release-0.3.1\" HEAD refs/tags/release-0.3.1\n> \n> Once I considered changing commit-tree to take any committish\n> after -p, but thought the command is a low level primitive and\n> the user should know what he is doing, but apparently, git-merge\n> does not know what it is doing ;-).\n> \n> In fact, I never use \"merge\" myself, and haven't noticed this\n> breakage until now (you would notice that the Everyday document\n> never talks about \"git merge\").  Instead, I always do this:\n> \n> \t$ git pull . tag release-0.3.1\n\nI've done this also.  Personally, I feel a little more in control with a\nfetch, merge, tag type of flow.  Maybe its just me but I couldn't get\nused to pull doing it all for me so I like to split the operation so\nthat I can easily run a diff-tree between the two if I want after\nperforming the fetch.\n\nWhile we're on the subject.  It might be nice if merge behaved a little\nmore like pull (without the fetch of course).  At the moment, I've got\nto give merge three arguments whereas pull is happy with just one of\nthem.\n\nSo, sometimes I would like to type this\n% git merge <head>\n\nmuch like one would type\n% git pull . <head>\n\nRather than typing\n% git merge \"Message\" HEAD <head>\n\nBut, this might not be an easy API change to make.  I suppose I could\njust type 'git pull . <head>' and be satisfied but my thought process\ntells be that I'm merging branches rather than pulling so I usually\ndon't think about it.  I'm really just typing my stream of thought at\nthis point so I'll wrap it up.\n\nThanks,\nCarl\n\n> But you are right.  It is advertised as the end-user\n> command and demonstrated in the tutorial.\n> \n> How about this patch?  I haven't looked at what (old)\n> git-resolve and git-octopus commands do --- they may need\n> similar parameter massaging.\n> \n> -- >8 --\n> [PATCH] allow merging any committish\n> \n> Although \"git-merge\" is advertised as the end-user level command\n> (instead of being a \"git-pull\" backend), it was not prepared to\n> take tag objects that point at commits and barfed when fed one.\n> Sanitize the input while we validate them, for which we already\n> have a loop.\n> \n> Signed-off-by: Junio C Hamano <junkio@cox.net>\n> ---\n> diff --git a/git-merge.sh b/git-merge.sh\n> index a221daa..d25ae4b 100755\n> --- a/git-merge.sh\n> +++ b/git-merge.sh\n> @@ -97,11 +97,14 @@ head=$(git-rev-parse --verify \"$1\"^0) ||\n>  shift\n>  \n>  # All the rest are remote heads\n> +remoteheads=\n>  for remote\n>  do\n> -\tgit-rev-parse --verify \"$remote\"^0 >/dev/null ||\n> +\tremotehead=$(git-rev-parse --verify \"$remote\"^0) ||\n>  \t    die \"$remote - not something we can merge\"\n> +\tremoteheads=\"${remoteheads}$remotehead \"\n>  done\n> +set x $remoteheads ; shift\n>  \n>  case \"$#\" in\n>  1)\n> \n> \n\n-- \n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n Carl Baldwin                        Systems VLSI Laboratory\n Hewlett Packard Company\n MS 88                               work: 970 898-1523\n 3404 E. Harmony Rd.                 work: Carl.N.Baldwin@hp.com\n Fort Collins, CO 80525              home: Carl@ecBaldwin.net\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"}]}