git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* BUG: git request-pull broken for plain branches
@ 2014-06-25  9:55 Uwe Kleine-König
  2014-06-25 12:05 ` Linus Torvalds
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2014-06-25  9:55 UTC (permalink / raw)
  To: Linus Torvalds, Junio C Hamano; +Cc: git, kernel

Hello,

I have git from Debian's 2.0.0-2 package:

	$ git version
	git version 2.0.0

git request-pull is broken for me:

	$ git rev-parse HEAD
	9e065e4a5a58308f1a0da4bb80b830929dfa90b3
	$ git ls-remote origin | grep 9e065e4a5a58308f1a0da4bb80b830929dfa90b3
	9e065e4a5a58308f1a0da4bb80b830929dfa90b3	refs/heads/ukl/for-mainline
	$ git request-pull origin/master origin HEAD > /dev/null
	warn: No match for commit 9e065e4a5a58308f1a0da4bb80b830929dfa90b3 found at origin
	warn: Are you sure you pushed 'HEAD' there?

The same happens on 2.0.0.421.g786a89d.

The problem is in git-request-pull.sh's find_matching_ref. This code has
more than one problem (looking on 2.0.0.421.g786a89d):

	- find_matching_ref doesn't assign to $found if none of the if
	  conditions in the loop match (this results in my problem);
	- find_matching_ref happily overwrites $found even if the
	  previous ref was better according to the metric specified
	  above the definition of find_matching_ref; and
	- the output generated uses $pretty_remote without asserting
	  that it matches $ref. In my case this results in a branch
	  specification of "HEAD" even if I fix find_matching_ref to
	  return refs/heads/ukl/for-mainline.

I tried to add this case to t/t5150-request-pull.sh, but didn't
understand how after starring at it for half an hour. :-(

Bisection points on 024d34cb0813 (request-pull: more strictly match
local/remote branches) as first bad commit. Apart from introducing the
warning, it also changes the branch spec from "ukl/for-mainline" (which
is correct) to the name of the current branch (which is bogus). Also
024d34cb0813 makes 5 out of 7 tests in t/t5150-request-pull.sh fail.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: BUG: git request-pull broken for plain branches
  2014-06-25  9:55 BUG: git request-pull broken for plain branches Uwe Kleine-König
@ 2014-06-25 12:05 ` Linus Torvalds
  2014-06-25 13:21   ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Torvalds @ 2014-06-25 12:05 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Junio C Hamano, Git Mailing List, kernel

On Wed, Jun 25, 2014 at 2:55 AM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
>         $ git rev-parse HEAD
>         9e065e4a5a58308f1a0da4bb80b830929dfa90b3
>         $ git ls-remote origin | grep 9e065e4a5a58308f1a0da4bb80b830929dfa90b3
>         9e065e4a5a58308f1a0da4bb80b830929dfa90b3        refs/heads/ukl/for-mainline
>         $ git request-pull origin/master origin HEAD > /dev/null
>         warn: No match for commit 9e065e4a5a58308f1a0da4bb80b830929dfa90b3 found at origin
>         warn: Are you sure you pushed 'HEAD' there?

Notice how "HEAD" does not match.

The error message is perhaps misleading. It's not enough to match the
commit. You need to match the branch name too. git used to guess the
branch name (from the commit), and it often guessed wrongly. So now
they need to match.

So you should do

    git request-pull origin/master origin ukl/for-mainline

to let request-pull know that you're requesting a pull for "ukl/for-mainline".

If you have another name for that branch locally (ie you did something
like "git push origin local:remote"), then you can say

    git request-pull origin/master origin local-name:remote-name

to specify what the branch to be pulled is called locally vs remotely.

In other words, what used to be "pick some branch randomly" is now
"you need to _specify_ the branch".

                Linus

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

* Re: BUG: git request-pull broken for plain branches
  2014-06-25 12:05 ` Linus Torvalds
@ 2014-06-25 13:21   ` Uwe Kleine-König
  2014-06-25 20:41     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Kleine-König @ 2014-06-25 13:21 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, Git Mailing List, kernel

Hello Linus,

On Wed, Jun 25, 2014 at 05:05:51AM -0700, Linus Torvalds wrote:
> On Wed, Jun 25, 2014 at 2:55 AM, Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> >
> >         $ git rev-parse HEAD
> >         9e065e4a5a58308f1a0da4bb80b830929dfa90b3
> >         $ git ls-remote origin | grep 9e065e4a5a58308f1a0da4bb80b830929dfa90b3
> >         9e065e4a5a58308f1a0da4bb80b830929dfa90b3        refs/heads/ukl/for-mainline
> >         $ git request-pull origin/master origin HEAD > /dev/null
> >         warn: No match for commit 9e065e4a5a58308f1a0da4bb80b830929dfa90b3 found at origin
> >         warn: Are you sure you pushed 'HEAD' there?
> 
> Notice how "HEAD" does not match.
> 
> The error message is perhaps misleading. It's not enough to match the
> commit. You need to match the branch name too. git used to guess the
> branch name (from the commit), and it often guessed wrongly. So now
> they need to match.
> 
> So you should do
> 
>     git request-pull origin/master origin ukl/for-mainline
> 
> to let request-pull know that you're requesting a pull for "ukl/for-mainline".
> 
> If you have another name for that branch locally (ie you did something
> like "git push origin local:remote"), then you can say
> 
>     git request-pull origin/master origin local-name:remote-name
> 
> to specify what the branch to be pulled is called locally vs remotely.
> 
> In other words, what used to be "pick some branch randomly" is now
> "you need to _specify_ the branch".
ah, got it. Still some of my concerns stay valid and I also have some
new ones:

 - if there is a branch and a tag on the remote side that match what I
   specified the outcome depends on the order of git-ls-remote. (minor
   nit.)
 - if I have to specify the remote name now, why do I have to also
   specify my local ref? Isn't the respective $sha1 of the remote side
   enough to do what is needed?
 - Isn't $found = $sha1; silly because I cannot pull a rev, only a ref?
   (side note:

   	git pull linus d91d66e88ea95b6dd21958834414009614385153

   gives no error message, only returns 1 and does nothing else.)
 - Is the result of

 	git request-pull $somecommit origin

   what is intended? For me it does

   	...
	are available in the git repository at:

	  $repository

	for you to fetch changes ...

   if the remote HEAD matches the local one. I'd prefer to have an
   explicit branch name there, or at least HEAD.

I liked git guessing the branch name, maybe we can teach it to guess a
bit better than it did before 2.0? Something like:

 - if there is a unique match on the remote side, use it.
 - if there are >= 1 match on the remote side and exactly one matches
   what I specified as <end>, use it.
 - if there are >= 1 match on the remote side and exactly one of them is
   a tag, use the tag
 - if there are two matches on the remote side, and one is "HEAD",
   pick the other one.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

* Re: BUG: git request-pull broken for plain branches
  2014-06-25 13:21   ` Uwe Kleine-König
@ 2014-06-25 20:41     ` Junio C Hamano
  2014-06-26  7:06       ` Uwe Kleine-König
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2014-06-25 20:41 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Linus Torvalds, Git Mailing List, kernel

Uwe Kleine-König  <u.kleine-koenig@pengutronix.de> writes:

> Hello Linus,
>
> On Wed, Jun 25, 2014 at 05:05:51AM -0700, Linus Torvalds wrote:
>> On Wed, Jun 25, 2014 at 2:55 AM, Uwe Kleine-König
>> <u.kleine-koenig@pengutronix.de> wrote:
>> >
>> >         $ git rev-parse HEAD
>> >         9e065e4a5a58308f1a0da4bb80b830929dfa90b3
>> >         $ git ls-remote origin | grep 9e065e4a5a58308f1a0da4bb80b830929dfa90b3
>> >         9e065e4a5a58308f1a0da4bb80b830929dfa90b3        refs/heads/ukl/for-mainline
>> >         $ git request-pull origin/master origin HEAD > /dev/null
>> >         warn: No match for commit 9e065e4a5a58308f1a0da4bb80b830929dfa90b3 found at origin
>> >         warn: Are you sure you pushed 'HEAD' there?
>> 
>> Notice how "HEAD" does not match.
>> 
>> The error message is perhaps misleading. It's not enough to match the
>> commit. You need to match the branch name too. git used to guess the
>> branch name (from the commit), and it often guessed wrongly. So now
>> they need to match.
>> 
>> So you should do
>> 
>>     git request-pull origin/master origin ukl/for-mainline
>> 
>> to let request-pull know that you're requesting a pull for "ukl/for-mainline".

Or

	git request-pull origin/master origin HEAD:ukl/for-mainline


I am not Linus, and do not speak for him, but FWIW here are some
comments on the ideas.

> I liked git guessing the branch name, maybe we can teach it to guess a
> bit better than it did before 2.0? Something like:
>
>  - if there is a unique match on the remote side, use it.

I am on the fence but slightly leaning to the negative side on this
one.  The branch/ref the object was took from when "git pull" is run
does matter, because the name is recorded in the merge summary, so
we cannot say "There are refs that happen to point at the object you
wanted to be pulled, so we'll pick one of them let the integrator
pull from that ref we randomly chose" is not something we would
want.  "If there is a unique one, that must be the one the user has
meant; there is nothing else possible" feels like a strong argument,
and I was actually contemplating about doing an enhancement on top
of Linus's original myself along that line, back when we queued that
patch exactly for that reason.

But a counter-argument, in the context of Linus's change in question
being primarily to avoid end-user mistakes resulting in a bogus
request, is that the ref on the remote that happens to match the
object but is different from what the user named may be a totally
unrelated branch before the user actually has pushed the set of
changes the request is going to ask to be pulled.  The mistake that
this extra strictness tries to avoid is to compose request-pull
before pushing what to be pulled and then forgetting to push.

>  - if there are >= 1 match on the remote side and exactly one matches
>    what I specified as <end>, use it.

The original change by Linus being about avoiding mistakes by
requiring the user to name what to be pulled, i.e. <end>, this point
of "other refs also happen to point at the same object" is made
irrelevant---if <end> does have the object the user named to be
pulled, that should be used regardless of where other refs point at.

>  - if there are >= 1 match on the remote side and exactly one of them is
>    a tag, use the tag
>
>  - if there are two matches on the remote side, and one is "HEAD",
>    pick the other one.

Assuming that <end> does not match the object in these two cases
(otherwise your second condition would have caught it), they share
the same potential objection as the first one.

I dunno.

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

* Re: BUG: git request-pull broken for plain branches
  2014-06-25 20:41     ` Junio C Hamano
@ 2014-06-26  7:06       ` Uwe Kleine-König
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Kleine-König @ 2014-06-26  7:06 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Linus Torvalds, Git Mailing List, kernel

Hi Junio,

On Wed, Jun 25, 2014 at 01:41:23PM -0700, Junio C Hamano wrote:
> Uwe Kleine-König  <u.kleine-koenig@pengutronix.de> writes:
> > On Wed, Jun 25, 2014 at 05:05:51AM -0700, Linus Torvalds wrote:
> >> On Wed, Jun 25, 2014 at 2:55 AM, Uwe Kleine-König
> >> <u.kleine-koenig@pengutronix.de> wrote:
> >> >
> >> >         $ git rev-parse HEAD
> >> >         9e065e4a5a58308f1a0da4bb80b830929dfa90b3
> >> >         $ git ls-remote origin | grep 9e065e4a5a58308f1a0da4bb80b830929dfa90b3
> >> >         9e065e4a5a58308f1a0da4bb80b830929dfa90b3        refs/heads/ukl/for-mainline
> >> >         $ git request-pull origin/master origin HEAD > /dev/null
> >> >         warn: No match for commit 9e065e4a5a58308f1a0da4bb80b830929dfa90b3 found at origin
> >> >         warn: Are you sure you pushed 'HEAD' there?
> >> 
> >> Notice how "HEAD" does not match.
> >> 
> >> The error message is perhaps misleading. It's not enough to match the
> >> commit. You need to match the branch name too. git used to guess the
> >> branch name (from the commit), and it often guessed wrongly. So now
> >> they need to match.
> >> 
> >> So you should do
> >> 
> >>     git request-pull origin/master origin ukl/for-mainline
> >> 
> >> to let request-pull know that you're requesting a pull for "ukl/for-mainline".
> 
> Or
> 
> 	git request-pull origin/master origin HEAD:ukl/for-mainline
> 
> I am not Linus, and do not speak for him, but FWIW here are some
> comments on the ideas.
> 
> > I liked git guessing the branch name, maybe we can teach it to guess a
> > bit better than it did before 2.0? Something like:
> >
> >  - if there is a unique match on the remote side, use it.
> 
> I am on the fence but slightly leaning to the negative side on this
> one.  The branch/ref the object was took from when "git pull" is run
> does matter, because the name is recorded in the merge summary, so
> we cannot say "There are refs that happen to point at the object you
> wanted to be pulled, so we'll pick one of them let the integrator
> pull from that ref we randomly chose" is not something we would
> want.  "If there is a unique one, that must be the one the user has
> meant; there is nothing else possible" feels like a strong argument,
> and I was actually contemplating about doing an enhancement on top
> of Linus's original myself along that line, back when we queued that
> patch exactly for that reason.
> 
> But a counter-argument, in the context of Linus's change in question
> being primarily to avoid end-user mistakes resulting in a bogus
> request, is that the ref on the remote that happens to match the
> object but is different from what the user named may be a totally
> unrelated branch before the user actually has pushed the set of
> changes the request is going to ask to be pulled.  The mistake that
> this extra strictness tries to avoid is to compose request-pull
> before pushing what to be pulled and then forgetting to push.
Sounds sensible. Then the enhancements that come to my mind are:

Change git-request-pull to explicitly take a remote ref as end. This
makes sure that it is actually there and the right remote name is
picked. Don't require to specify a local ref even if there is no
local matching ref, just use the remote sha1 to generate the diffstat
and summary.

Another thing I'd like to have is to make git-request-pull not generate
the usual output if there is no match. Optionally introduce a -f to get
back the (maybe bogus) output; in this case a local rev would be needed.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2014-06-26  7:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-25  9:55 BUG: git request-pull broken for plain branches Uwe Kleine-König
2014-06-25 12:05 ` Linus Torvalds
2014-06-25 13:21   ` Uwe Kleine-König
2014-06-25 20:41     ` Junio C Hamano
2014-06-26  7:06       ` Uwe Kleine-König

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