All of lore.kernel.org
 help / color / mirror / Atom feed
* How to generate pull-request with info of signed tag
@ 2011-12-16  6:35 Aneesh Kumar K.V
  2011-12-16 16:22 ` Junio C Hamano
  2011-12-16 16:56 ` Re* " Junio C Hamano
  0 siblings, 2 replies; 12+ messages in thread
From: Aneesh Kumar K.V @ 2011-12-16  6:35 UTC (permalink / raw)
  To: Git Mailing List, Junio C Hamano


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

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

* Re: How to generate pull-request with info of signed tag
  2011-12-16  6:35 How to generate pull-request with info of signed tag Aneesh Kumar K.V
@ 2011-12-16 16:22 ` Junio C Hamano
  2011-12-16 16:56 ` Re* " Junio C Hamano
  1 sibling, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2011-12-16 16:22 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: Git Mailing List

"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:

> 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.

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

* Re* How to generate pull-request with info of signed tag
  2011-12-16  6:35 How to generate pull-request with info of signed tag Aneesh Kumar K.V
  2011-12-16 16:22 ` Junio C Hamano
@ 2011-12-16 16:56 ` Junio C Hamano
  2011-12-17 13:27   ` Aneesh Kumar K.V
  1 sibling, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2011-12-16 16:56 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: Git Mailing List, Junio C Hamano

"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:

> 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.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-request-pull.sh |   46 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/git-request-pull.sh b/git-request-pull.sh
index c6a5b7a..7b5c777 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -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

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-16 16:56 ` Re* " Junio C Hamano
@ 2011-12-17 13:27   ` Aneesh Kumar K.V
  2011-12-17 19:47     ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Aneesh Kumar K.V @ 2011-12-17 13:27 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Junio C Hamano

On Fri, 16 Dec 2011 08:56:14 -0800, Junio C Hamano <gitster@pobox.com> wrote:
> "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:
> 
> > 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.
> 

Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

-aneesh

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-17 13:27   ` Aneesh Kumar K.V
@ 2011-12-17 19:47     ` Junio C Hamano
  2011-12-19 16:10       ` Aneesh Kumar K.V
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2011-12-17 19:47 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: Git Mailing List

"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:

> Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>
> -aneesh

Thanks.

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-17 19:47     ` Junio C Hamano
@ 2011-12-19 16:10       ` Aneesh Kumar K.V
  2011-12-19 19:55         ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Aneesh Kumar K.V @ 2011-12-19 16:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

On Sat, 17 Dec 2011 11:47:44 -0800, Junio C Hamano <gitster@pobox.com> wrote:
> "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:
> 
> > Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> >
> > -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

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-19 16:10       ` Aneesh Kumar K.V
@ 2011-12-19 19:55         ` Junio C Hamano
  2011-12-19 20:06           ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2011-12-19 19:55 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: Git Mailing List

"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:

> 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.

> 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.

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-19 19:55         ` Junio C Hamano
@ 2011-12-19 20:06           ` Junio C Hamano
  2011-12-21  6:30             ` Aneesh Kumar K.V
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2011-12-19 20:06 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Aneesh Kumar K.V

Junio C Hamano <gitster@pobox.com> writes:

> 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.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-request-pull.sh     |    4 +---
 t/t5150-request-pull.sh |    2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/git-request-pull.sh b/git-request-pull.sh
index 7b5c777..d7ba117 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -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;
 		}
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
index aec842f..da25bc2 100755
--- a/t/t5150-request-pull.sh
+++ b/t/t5150-request-pull.sh
@@ -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
 	}
-- 
1.7.8.370.gb3269

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-19 20:06           ` Junio C Hamano
@ 2011-12-21  6:30             ` Aneesh Kumar K.V
  2011-12-21  7:03               ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Aneesh Kumar K.V @ 2011-12-21  6:30 UTC (permalink / raw)
  To: Junio C Hamano, Git Mailing List

On Mon, 19 Dec 2011 12:06:55 -0800, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > 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.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  git-request-pull.sh     |    4 +---
>  t/t5150-request-pull.sh |    2 +-
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/git-request-pull.sh b/git-request-pull.sh
> index 7b5c777..d7ba117 100755
> --- a/git-request-pull.sh
> +++ b/git-request-pull.sh
> @@ -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;
>  		}
> diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
> index aec842f..da25bc2 100755
> --- a/t/t5150-request-pull.sh
> +++ b/t/t5150-request-pull.sh
> @@ -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

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-21  6:30             ` Aneesh Kumar K.V
@ 2011-12-21  7:03               ` Junio C Hamano
  2011-12-21 16:51                 ` Aneesh Kumar K.V
  0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2011-12-21  7:03 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: Git Mailing List

"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:

> 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.

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-21  7:03               ` Junio C Hamano
@ 2011-12-21 16:51                 ` Aneesh Kumar K.V
  2011-12-21 18:39                   ` Junio C Hamano
  0 siblings, 1 reply; 12+ messages in thread
From: Aneesh Kumar K.V @ 2011-12-21 16:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

On Tue, 20 Dec 2011 23:03:57 -0800, Junio C Hamano <gitster@pobox.com> wrote:
> "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:
> 
> > 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.
> 

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

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

* Re: Re* How to generate pull-request with info of signed tag
  2011-12-21 16:51                 ` Aneesh Kumar K.V
@ 2011-12-21 18:39                   ` Junio C Hamano
  0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2011-12-21 18:39 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: Git Mailing List

"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:

> 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

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.

> [master@QEMU]$ git fetch github for-anthony
>>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".

> 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

Sounds sane, too.

> 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.

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

end of thread, other threads:[~2011-12-21 18:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-16  6:35 How to generate pull-request with info of signed tag Aneesh Kumar K.V
2011-12-16 16:22 ` Junio C Hamano
2011-12-16 16:56 ` Re* " Junio C Hamano
2011-12-17 13:27   ` Aneesh Kumar K.V
2011-12-17 19:47     ` Junio C Hamano
2011-12-19 16:10       ` Aneesh Kumar K.V
2011-12-19 19:55         ` Junio C Hamano
2011-12-19 20:06           ` Junio C Hamano
2011-12-21  6:30             ` Aneesh Kumar K.V
2011-12-21  7:03               ` Junio C Hamano
2011-12-21 16:51                 ` Aneesh Kumar K.V
2011-12-21 18:39                   ` Junio C Hamano

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.