All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] contrib/subtree bugfix: Crash if FETCH_HEAD is tag
       [not found] <1399185212-17833-1-git-send-email-nod.helm@gmail.com>
@ 2014-05-07 21:53 ` James Denholm
  2014-05-08  1:04   ` James Denholm
  0 siblings, 1 reply; 2+ messages in thread
From: James Denholm @ 2014-05-07 21:53 UTC (permalink / raw)
  To: git; +Cc: Kevin Cagle, Junio C Hamano, James Denholm

On 4 May 2014 16:33:32 GMT+10:00, James Denholm <nod.helm@gmail.com> wrote:
>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 $?

I know that subtree isn't exactly the most popular or exciting part of
the project at the moment, but given that this is adding a subtree based
on an annotated tag is a reasonably sensible operation and (to me) the
fix seems reasonably trivial, could I get some eyes on this?

Regards,
James Denholm.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] contrib/subtree bugfix: Crash if FETCH_HEAD is tag
  2014-05-07 21:53 ` [PATCH] contrib/subtree bugfix: Crash if FETCH_HEAD is tag James Denholm
@ 2014-05-08  1:04   ` James Denholm
  0 siblings, 0 replies; 2+ messages in thread
From: James Denholm @ 2014-05-08  1:04 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Kevin Cagle, Junio C Hamano, James Denholm

After a closer look, it seems the initial patch wasn't correctly sent
to the list. Please disregard, I'm re-sending the patch entirely.

Regards,
James Denholm.

On 8 May 2014 07:53, James Denholm <nod.helm@gmail.com> wrote:
> On 4 May 2014 16:33:32 GMT+10:00, James Denholm <nod.helm@gmail.com> wrote:
>>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 $?
>
> I know that subtree isn't exactly the most popular or exciting part of
> the project at the moment, but given that this is adding a subtree based
> on an annotated tag is a reasonably sensible operation and (to me) the
> fix seems reasonably trivial, could I get some eyes on this?
>
> Regards,
> James Denholm.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-08  1:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1399185212-17833-1-git-send-email-nod.helm@gmail.com>
2014-05-07 21:53 ` [PATCH] contrib/subtree bugfix: Crash if FETCH_HEAD is tag James Denholm
2014-05-08  1:04   ` James Denholm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.