{"thread":{"id":"36531","subject":"git subtree issue in more recent versions","startedAt":"2014-04-29T00:50:01Z","lastAt":"2014-04-29T18:22:01Z","messageCount":2,"participants":["Kevin Cagle (kcagle) [CONT - Type 2]","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"240097","messageId":"55893188F2F68B4B9819D7F9452F981D09FCDF67@NTXBOIMBX01.micron.com","threadId":"36531","inReplyTo":null,"subject":"git subtree issue in more recent versions","fromName":"Kevin Cagle (kcagle) [CONT - Type 2]","fromEmail":"kcagle@micron.com","sentAt":"2014-04-29T00:50:01Z","receivedAt":"2014-04-29T00:50:01Z","isPatch":false,"sender":{"key":"kcagle@micron.com","avatar":null},"body":"Hi,\n\nI've discovered a bug in git subtree related to annotated tags. The command 'git subtree' will fail if you use an annotated tag as the <refspec>. e.g.:\n\n$ git subtree add -P oldGit https://github.com/git/git.git tags/v1.9.2\n\nWill produce this error:\n\n10ff115f5c572299de4e04ade0d7adb3c75fbf1f is not a valid 'commit' object\n\nThe bug isn't found in 1.7.1 (installed subtree manually) but is found in 1.9.0 and 2.0.0.rc1. \n\nIt's related to the git fetch putting the \"wrong\" SHA1 in .git/FETCH_HEAD. Thus, if you do:\n\n$ git ls-remote https://github.com/git/git.git | grep v1.9.2\n\nYou'll see this:\n10ff115f5c572299de4e04ade0d7adb3c75fbf1f        refs/tags/v1.9.2\n0bc85abb7aa9b24b093253018801a0fb43d01122        refs/tags/v1.9.2^{}\n\nAn older version will put the 0bc85a in FETCH_HEAD but newer versions will put 10ff11 which will not work. I'm new to Git so I don't know when/why that was changed but somewhere along the way, that change broke git subtree add. :( A workaround is to use lightweight tags but that's not suitable for some. \n\nThanks,\nKevin\n"},{"id":"240191","messageId":"xmqqa9b4kncm.fsf@gitster.dls.corp.google.com","threadId":"36531","inReplyTo":"55893188F2F68B4B9819D7F9452F981D09FCDF67@NTXBOIMBX01.micron.com","subject":"Re: git subtree issue in more recent versions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-04-29T18:22:01Z","receivedAt":"2014-04-29T18:22:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kevin Cagle (kcagle) [CONT - Type 2]\" <kcagle@micron.com> writes:\n\n> $ git subtree add -P oldGit https://github.com/git/git.git tags/v1.9.2\n>\n> Will produce this error:\n>\n> 10ff115f5c572299de4e04ade0d7adb3c75fbf1f is not a valid 'commit' object\n>\n> The bug isn't found in 1.7.1 (installed subtree manually) but is found in 1.9.0 and 2.0.0.rc1. \n>\n> It's related to the git fetch putting the \"wrong\" SHA1 in .git/FETCH_HEAD.\n\nThe change 7a2b128d is very much deliberate; we wanted not to lose\ninformation that the user was trying to pull a tag not a commit,\nbecause not unwrapping a tag to a commit it points at too early is\nessential to allow pulling and merging a signed tag, which was\nreleased as part of the 1.7.9 that happened in late January 2012\n(whew, is it already more than two years ago?  time flies).\n\n    commit 7a2b128d13d880635e7317a9208cfa42a660f143\n    Author: Linus Torvalds <torvalds@linux-foundation.org>\n    Date:   Wed Nov 2 19:19:34 2011 -0700\n\n    fetch: do not store peeled tag object names in FETCH_HEAD\n    \n    We do not want to record tags as parents of a merge when the user does\n    \"git pull $there tag v1.0\" to merge tagged commit, but that is not a good\n    enough excuse to peel the tag down to commit when storing in FETCH_HEAD.\n    The caller of underlying \"git fetch $there tag v1.0\" may have other uses\n    of information contained in v1.0 tag in mind.\n\nIf the caller of \"fetch\" (like the codepath in subtree) must see a\ncommit object, it needs to unwrap the tag itself in the new (eh, not\nso new, though ;-) world order.\n"}]}