public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: James Denholm <nod.helm@gmail•com>
Cc: git@vger•kernel.org, Kevin Cagle <kcagle@micron•com>
Subject: Re: [PATCH v2] contrib/subtree bugfix: Can't `add` annotated tag
Date: Tue, 13 May 2014 12:34:13 -0700	[thread overview]
Message-ID: <xmqqa9alo4lm.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1399954138-2807-1-git-send-email-nod.helm@gmail.com> (James Denholm's message of "Tue, 13 May 2014 14:08:58 +1000")

James Denholm <nod.helm@gmail•com> writes:

> 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, pre-existing
> dependency of git-subtree.
>
> Reported-by: Kevin Cagle <kcagle@micron•com>
> Helped-by: Junio C Hamano <gitster@pobox•com>
> Signed-off-by: James Denholm <nod.helm@gmail•com>
> ---
> I felt that defining revp would be a little more self-documenting than
> using $rev^0.

That is a good decision, but as long as we are attempting to peel,
don't we want to stop the damage when it does not peel to a commit?

I'll tentatively queue this.  Thanks.

-- >8 --
From: James Denholm <nod.helm@gmail•com>
Date: Tue, 13 May 2014 14:08:58 +1000
Subject: [PATCH] contrib/subtree: allow adding an annotated tag

cmd_add_commit() is passed FETCH_HEAD by cmd_add_repository, which
is then rev-parsed into an object name.  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 name refers to a tag and is never peeled, and the git
commit-tree call (line 561) slaps us in the face because it doesn't
peel tags to commits.

Because peeling a committish doesn't do anything if it's already a
commit, fix by peeling the object name before assigning it to $rev,
using peel_committish() from git:git-sh-setup.sh, a pre-existing
dependency of git-subtree.

Reported-by: Kevin Cagle <kcagle@micron•com>
Helped-by: Junio C Hamano <gitster@pobox•com>
Signed-off-by: James Denholm <nod.helm@gmail•com>
Signed-off-by: Junio C Hamano <gitster@pobox•com>
---
 contrib/subtree/git-subtree.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index db925ca..fa1a583 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -558,8 +558,9 @@ cmd_add_commit()
 		commit=$(add_squashed_msg "$rev" "$dir" |
 			 git commit-tree $tree $headp -p "$rev") || exit $?
 	else
+		revp=$(peel_committish "$rev") &&
 		commit=$(add_msg "$dir" "$headrev" "$rev" |
-			 git commit-tree $tree $headp -p "$rev") || exit $?
+			 git commit-tree $tree $headp -p "$revp") || exit $?
 	fi
 	git reset "$commit" || exit $?
 	
-- 
2.0.0-rc3-404-gb0be553

  reply	other threads:[~2014-05-13 19:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13  4:08 [PATCH v2] contrib/subtree bugfix: Can't `add` annotated tag James Denholm
2014-05-13 19:34 ` Junio C Hamano [this message]
2014-05-13 23:02   ` James Denholm
2014-05-13 23:12     ` Junio C Hamano
2014-05-14 21:32       ` James Denholm
2014-05-14 21:40         ` Junio C Hamano
2014-05-14 22:50           ` 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=xmqqa9alo4lm.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=kcagle@micron$(echo .)com \
    --cc=nod.helm@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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