How to generate pull-request with info of signed tag
Hi,
I am using git from master branch and wanted to try the signed pull request. I have pushed the signed tag to repo.or.cz, but not sure how to generate pull request with signed tag information ? git-pull-request insist on a branch on the server and put the branch details in the pull-request text, It do add tag description but not the tag name and still put "repo-name branch" name in the txt. Shouldn't that be "repo-name tag-name" so that one can cut-paste that in pull request ?
-aneesh
Re* How to generate pull-request with info of signed tag
Quoted 3 lines · Aneesh Kumar K.V
I am using git from master branch and wanted to try the signed pull request. I have pushed the signed tag to repo.or.cz, but not sure how to generate pull request with signed tag information?
The correct script should grok the following command line:
$ git request-pull v1.7.7.4 git://git.kernel.org/pub/scm/git/git.git v1.7.7.5
and include
are available in the git repository at
git://git.kernel.org/.../git.git tag v1.7.7.5
for you to fetch changes up to 66c1...
but we didn't loosen the code that inspects the publishing repository to allow asking for a tag that points at an older part of the history to be pulled.
Here is an update.
-- >8 --
Subject: request-pull: update the "pull" command generation logic
The old code that insisted on asking for the tip of a branch to be pulled were not updated when we started allowing for a tag to be pulled. When a tag points at an older part of the history and there is no branch that points at the tagged commit, the script failed to say which ref is to be pulled.
--- git-request-pull.sh | 46 +++++++++++++++++++++++++++++++++++++--------- 1 files changed, 37 insertions(+), 9 deletions(-)
git-request-pull.sh +37 -9
@@ -57,12 +57,40 @@ headrev=$(git rev-parse --verify "$head"^0) || exit merge_base=$(git merge-base $baserev $headrev) || die "fatal: No commits in common between $base and $head" -find_matching_branch="/^$headrev "'refs\/heads\//{ - s/^.* refs\/heads\/// - p - q -}' -branch=$(git ls-remote "$url" | sed -n -e "$find_matching_branch") +# $head is the token given from the command line. If a ref with that +# name exists at the remote and their values match, we should use it. +# Otherwise find a ref that matches $headrev. +find_matching_ref=' + sub abbr { + my $ref = shift; + if ($ref =~ s|refs/heads/||) { + return $ref; + } elsif ($ref =~ s|refs/tags/||) { + return "tag $ref"; + } else { + return $ref; + } + } + + my ($exact, $found); + while (<STDIN>) { + my ($sha1, $ref, $deref) = /^(\S+)\s+(\S+?)(\^\{\})?$/; + next unless ($sha1 eq $ARGV[1]); + $found = abbr($ref); + if ($ref =~ m|/\Q$ARGV[0]\E$|) { + $exact = $found; + last; + } + } + if ($exact) { + print "$exact\n"; + } elsif ($found) { + print "$found\n"; + } +' + +ref=$(git ls-remote "$url" | perl -e "$find_matching_ref" "$head" "$headrev") + url=$(git ls-remote --get-url "$url") git show -s --format='The following changes since commit %H:
@@ -71,7 +99,7 @@ git show -s --format='The following changes since commit %H: are available in the git repository at: ' $baserev && -echo " $url${branch+ $branch}" && +echo " $url${ref+ $ref}" && git show -s --format=' for you to fetch changes up to %H:
@@ -81,7 +109,7 @@ for you to fetch changes up to %H: if test -n "$branch_name" then - echo "(from the branch description for $branch local branch)" + echo "(from the branch description for $branch_name local branch)" echo git config "branch.$branch_name.description" fi &&
@@ -101,7 +129,7 @@ fi && git shortlog ^$baserev $headrev && git diff -M --stat --summary $patch $merge_base..$headrev || status=1 -if test -z "$branch" +if test -z "$ref" then echo "warn: No branch of $url is at:" >&2 git show -s --format='warn: %h: %s' $headrev >&2
Aneesh Kumar K.V
Tested-byRe: Re* How to generate pull-request with info of signed tag
Quoted 14 lines · Junio C Hamano
Quoted 3 lines · Aneesh Kumar K.V
I am using git from master branch and wanted to try the signed pull request. I have pushed the signed tag to repo.or.cz, but not sure how to generate pull request with signed tag information?
The correct script should grok the following command line:
$ git request-pull v1.7.7.4 git://git.kernel.org/pub/scm/git/git.git v1.7.7.5and include
are available in the git repository at
Quoted 8 lines
git://git.kernel.org/.../git.gittag v1.7.7.5for you to fetch changes up to 66c1...
but we didn't loosen the code that inspects the publishing repository to allow asking for a tag that points at an older part of the history to be pulled.
-aneesh
Re: Re* How to generate pull-request with info of signed tag
Quoted 3 lines · Aneesh Kumar K.V
Tested-by Aneesh Kumar K.V <[email protected]>-aneesh
Thanks.
Re: Re* How to generate pull-request with info of signed tag
Quoted 7 lines · Junio C Hamano
Quoted 3 lines · Aneesh Kumar K.V
Tested-by Aneesh Kumar K.V <[email protected]>-aneesh
Thanks.
It would be nice to get the below working
git fetch git-url tag remote-tag-name:local-namespace/tag-name
That way we can make sure before merging i can cut-paste that url and the local tag name i wish to store this to. And then do a git-merge.
-aneesh
Re: Re* How to generate pull-request with info of signed tag
Quoted 3 lines · Aneesh Kumar K.V
It would be nice to get the below working
git fetch git-url tag remote-tag-name:local-namespace/tag-name
AFAIR "fetch tag $v" is a shorthand for "fetch refs/tags/$v:refs/tags/$" invented back when Linus was the maintainer of Git. You can say
$ git fetch $url refs/tags/remote-tag-name:refs/tags/whatever-tag-name-you-want
to rename their tag to whatever name in your local repository.
Come to think of it, the last patch I sent out on request pull was very wrong. The point of the recent change to allow you to pull this way (notice the lack of "tag")
$ git pull $url $signed_tag_name
is so that you do not have to contaminate your own ref namespace with tags that are used to leave audit trails in the history graph.
Quoted 2 lines
That way we can make sure before merging i can cut-paste that url and the local tag name i wish to store this to. And then do a git-merge.
Re: Re* How to generate pull-request with info of signed tag
Quoted 2 lines · Junio C Hamano
Come to think of it, the last patch I sent out on request pull was very wrong....
And this should fix it.
-- >8 --
Subject: [PATCH] request-pull: do not emit "tag" before the tagname
The whole point of the recent update to allow "git pull $url $tagname" is so that the integrator does not have to store the (signed) tag that is used to convey authenticity to be recorded in the resulting merge in the local repository's tag namespace. Asking for a merge be made with "git pull $url tag $tagname" defeats it.
Note that the request can become ambiguous if the requestor has a branch with the same name as the tag, but that is not a new problem limited to pulling. I wouldn't mind if somebody wants to add disambiguation to the find_matching_ref logic in the script as a separate patch, though.
--- git-request-pull.sh | 4 +--- t/t5150-request-pull.sh | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-)
git-request-pull.sh +1 -3
@@ -63,10 +63,8 @@ die "fatal: No commits in common between $base and $head" find_matching_ref=' sub abbr { my $ref = shift; - if ($ref =~ s|refs/heads/||) { + if ($ref =~ s|refs/heads/|| || $ref =~ s|refs/tags/||) { return $ref; - } elsif ($ref =~ s|refs/tags/||) { - return "tag $ref"; } else { return $ref; }
t/t5150-request-pull.sh +1 -1
@@ -180,7 +180,7 @@ test_expect_success 'request names an appropriate branch' ' read branch } <digest && { - test "$branch" = tag--full || + test "$branch" = full || test "$branch" = master || test "$branch" = for-upstream }
Signature · 1 line
1.7.8.370.gb3269
Re: Re* How to generate pull-request with info of signed tag
Quoted 48 lines · Junio C Hamano
Quoted 2 lines · Junio C Hamano
Come to think of it, the last patch I sent out on request pull was very wrong....
And this should fix it.
-- >8 --
Subject: [PATCH] request-pull: do not emit "tag" before the tagnameThe whole point of the recent update to allow "git pull $url $tagname" is so that the integrator does not have to store the (signed) tag that is used to convey authenticity to be recorded in the resulting merge in the local repository's tag namespace. Asking for a merge be made with "git pull $url tag $tagname" defeats it.
Note that the request can become ambiguous if the requestor has a branch with the same name as the tag, but that is not a new problem limited to pulling. I wouldn't mind if somebody wants to add disambiguation to the
find_matching_reflogic in the script as a separate patch, though.Signed-off-by Junio C Hamano <[email protected]>--- git-request-pull.sh | 4 +--- t/t5150-request-pull.sh | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-)git-request-pull.sh +1
-3@@ -63,10 +63,8 @@ die "fatal: No commits in common between $base and $head" find_matching_ref=' sub abbr { my $ref = shift; - if ($ref =~ s|refs/heads/||) { + if ($ref =~ s|refs/heads/|| || $ref =~ s|refs/tags/||) { return $ref; - } elsif ($ref =~ s|refs/tags/||) { - return "tag $ref"; } else { return $ref; }t/t5150-request-pull.sh +0
-0
t/t5150-request-pull.sh test_expect_success 'request names an appropriate branch' ' · line 186
Quoted 8 lines
t/t5150-request-pull.sh +1
-1@@ -180,7 +180,7 @@ test_expect_success 'request names an appropriate branch' ' read branch } <digest && { - test "$branch" = tag--full || + test "$branch" = full || test "$branch" = master || test "$branch" = for-upstream }
Also can we make .git/config remote stanza to have something like below
fetch = +refs/tags/*:refs/tags/abc/*
so that one can do
git fetch t-remote tag-name
and that get stored to abc/tag-name
-aneesh
Re: Re* How to generate pull-request with info of signed tag
Quoted 10 lines · Aneesh Kumar K.V
Also can we make .git/config remote stanza to have something like below
fetch = +refs/tags/*:refs/tags/abc/*so that one can do
git fetch t-remote tag-name
and that get stored to abc/tag-name
You can do whatever you want to your own config file without asking anybody.
Having said that, the point of the recent change to allow you to pull this way (notice the lack of "tag")
$ git pull $url $signed_tag_name
is so that you do not have to contaminate your own ref namespace with tags that are used to leave audit trails in the history graph.
Re: Re* How to generate pull-request with info of signed tag
Quoted 15 lines · Junio C Hamano
Quoted 10 lines · Aneesh Kumar K.V
Also can we make .git/config remote stanza to have something like below
fetch = +refs/tags/*:refs/tags/abc/*so that one can do
git fetch t-remote tag-name
and that get stored to abc/tag-name
You can do whatever you want to your own config file without asking anybody.
Quoted 8 lines
Having said that, the point of the recent change to allow you to pull this way (notice the lack of "tag")
$ git pull $url $signed_tag_nameis so that you do not have to contaminate your own ref namespace with tags that are used to leave audit trails in the history graph.
With an entry like below
[remote "github"]
fetch = +refs/tags/*:refs/tags/origin/*
url = git://github.com/kvaneesh/QEMU.git
when i do git fetch github for-anthony i get the below error
[master@QEMU]$ git fetch github for-anthony From git://github.com/kvaneesh/QEMU * tag for-anthony -> FETCH_HEAD [master@QEMU]$ less .git/config
Also trying to do
[master@QEMU]$ git fetch git://github.com/kvaneesh/QEMU.git for-anthony:aneesh/for-anthony error: Trying to write non-commit object 12916047784615b7d8b879d9d39be6c1559e1b1b to branch refs/heads/aneesh/for-anthony From git://github.com/kvaneesh/QEMU ! [new branch] for-anthony -> aneesh/for-anthony (unable to update local ref) * [new tag] for-anthony -> for-anthony
I understand that replacing the above with below works. But we should not be required to specify refs/tags there right ?
[master@QEMU]$ git fetch git://github.com/kvaneesh/QEMU.git refs/tags/for-anthony:refs/tags/aneesh/for-anthony
-aneesh
Re: Re* How to generate pull-request with info of signed tag
Quoted 7 lines · Aneesh Kumar K.V
With an entry like below
[remote "github"]
fetch = +refs/tags/*:refs/tags/origin/*
url =git://github.com/kvaneesh/QEMU.gitwhen i do git fetch github for-anthony i get the below error
When you give refspecs from the command line like that, the default refspec remote.github.fetch will not be used and what you configure there is immaterial.
Quoted 3 lines
[master@QEMU]$ git fetch github for-anthonyQuoted 1 line
From
git://github.com/kvaneesh/QEMU* tag for-anthony ->
FETCH_HEAD
Sounds sane.
Does "git cat-file -t FETCH_HEAD" report "tag" (it should)? After doing that fetch and inspecting "git log -p ..FETCH_HEAD", you should be able to do "git merge FETCH_HEAD" and it should be like you did "git pull github for-anthony".
Quoted 7 lines
Also trying to do
[master@QEMU]$ git fetch git://github.com/kvaneesh/QEMU.git for-anthony:aneesh/for-anthony error: Trying to write non-commit object 12916047784615b7d8b879d9d39be6c1559e1b1b to branch refs/heads/aneesh/for-anthonyQuoted 1 line
From
git://github.com/kvaneesh/QEMU! [new branch] for-anthony -> aneesh/for-anthony (unable to update local ref)
* [new tag] for-anthony -> for-anthony
Sounds sane, too.
Quoted 4 lines
I understand that replacing the above with below works. But we should not be required to specify refs/tags there right ?
[master@QEMU]$ git fetch git://github.com/kvaneesh/QEMU.git refs/tags/for-anthony:refs/tags/aneesh/for-anthony
If the "for-anthony" name is ambiguous between branches and tags, then you must disambiguate. I am guessing that the unqualified LHS "for-anthony" is found in the branch namespace of the remote, and that is why RHS is qualified with the same refs/heads/ prefix to store it to the branch namespace.
On the other hand, if "for-anthony" name is unambiguous, then you may have found a bug. I cannot tell.
Quoted 7 lines · Aneesh Kumar K.V
I am using git from master branch and wanted to try the signed pull request. I have pushed the signed tag to repo.or.cz, but not sure how to generate pull request with signed tag information ? git-pull-request insist on a branch on the server and put the branch details in the pull-request text, It do add tag description but not the tag name and still put "repo-name branch" name in the txt. Shouldn't that be "repo-name tag-name" so that one can cut-paste that in pull request ?
Yeah, you are right.