Re: [RFC PATCH] Make 'git request-pull' more strict about matching local/remote branches
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 22, 2014, 21:46 UTC
- Message-ID
- <xmqq1tzzy9ip.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <alpine.LFD.2.11.1401221243090.18459@i7.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 13 quoted lines
> This means that git request-pull will never rewrite the ref-name you gave > it. If the local branch name is "xyzzy", that is the only branch name > that request-pull will ask the other side to fetch. > > If the remote has that branch under a different name, that's your problem > and git request-pull will not try to fix it up (but git request-pull will > warn about the fact that no exact matching branch is found, and you can > edit the end result to then have the remote name you want if it doesn't > match your local one). > > The new "find local ref" code will also complain loudly if you give an > ambiguous refname (eg you have both a tag and a branch with that same > name, and you don't specify "heads/name" or "tags/name").
I agree with the basic direction, especially the part "we will never rewrite", is quite attractive.
But this part might be a bit problematic. $3=master will almost always have refs/heads/master and refs/remotes/origin/master listed because the call to "show-ref" comes before "rev-parse --verify", no?
Show 12 quoted lines
> +head=$(git symbolic-ref -q "${3-HEAD}")
> +head=${head:-$(git show-ref "${3-HEAD}" | cut -d' ' -f2)}
> +head=${head:-$(git rev-parse --quiet --verify "$3")}
> +
> +# None of the above? Bad.
> +test -z "$head" && die "fatal: Not a valid revision: $3"
> +
> +# This also verifies that the resulting head is unique:
> +# "git show-ref" could have shown multiple matching refs..
> headrev=$(git rev-parse --verify --quiet "$head"^0)
> -if test -z "$headrev"
> +test -z "$headrev" && die "fatal: Ambiguous revision: $3"... and it would die here. $3=for-linus may be the most common case on the kernel list, and remotes/origin/for-linus may be unlikely to appear in the real life (hmph, really? perhaps people keep track of what they pushed out the last time with it, I dunno).