From: James Denholm <nod.helm@gmail.com>
To: git@vger.kernel.org
Cc: Kevin Cagle <kcagle@micron.com>,
Junio C Hamano <gitster@pobox.com>,
James Denholm <nod.helm@gmail.com>
Subject: [PATCH] contrib/subtree bugfix: Can't `add` annotated tag
Date: Thu, 8 May 2014 11:04:39 +1000 [thread overview]
Message-ID: <1399511079-1994-1-git-send-email-nod.helm@gmail.com> (raw)
cmd_add_commit() is passed FETCH_HEAD by cmd_add_repository, which is
then rev-parsed into an object ID. However, if the user is fetching a
tag rather than a branch HEAD, such as by executing:
$ git subtree add -P oldGit https://github.com/git/git.git tags/v1.8.0
The object ID is a tag and is never peeled, and the git commit-tree call
(line 561) slaps us in the face because it doesn't handle tag IDs.
Because peeling a committish ID doesn't do anything if it's already a
commit, fix by peeling[1] the object ID before assigning it to $rev, as
per the patch.
[*1*]: Via peel_committish(), from git:git-sh-setup.sh
Reported-by: Kevin Cagle <kcagle@micron.com>
Diagnosed-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: James Denholm <nod.helm@gmail.com>
---
NB: This bug doesn't surface when using --squash, as $rev is reassigned
to the squash commit via new_squash_commit before git commit-tree sees
it (though for simplicity, new_squash_commit now also sees the peeled
ID).
Also doesn't surface when using "git subtree merge", as git merge can
handle tag objects.
On a side note, if merging a tag without --squash, git merge recognises
that it's a tag and adds a note to the merge commit body. It may be
worth mimicking this when using "subtree merge --squash" or
"subtree add".
contrib/subtree/git-subtree.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index dc59a91..9453dae 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -538,7 +538,7 @@ cmd_add_commit()
{
revs=$(git rev-parse $default --revs-only "$@") || exit $?
set -- $revs
- rev="$1"
+ rev=$(peel_committish "$1")
debug "Adding $dir as '$rev'..."
git read-tree --prefix="$dir" $rev || exit $?
--
1.9.2
next reply other threads:[~2014-05-08 1:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 1:04 James Denholm [this message]
2014-05-08 17:38 ` [PATCH] contrib/subtree bugfix: Can't `add` annotated tag Junio C Hamano
2014-05-09 7:36 ` James Denholm
2014-05-12 7:29 ` James Denholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399511079-1994-1-git-send-email-nod.helm@gmail.com \
--to=nod.helm@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kcagle@micron.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).