Re: [PATCH v3 3/3] refspec: make @ a synonym of HEAD
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 25, 2020, 23:53 UTC
- Message-ID
- <xmqqpn41at89.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20201125233443.63130-4-felipe.contreras@gmail.com>
Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 20 quoted lines
> Since commit 9ba89f484e git learned how to push to a remote branch using > the source @, for example: > > git push origin @:master > > However, if the right-hand side is missing, the push fails: > > git push origin @ > > It is obvious what is the desired behavior, and allowing the push makes > things more consistent. > > Additionally, @:master now has the same semantics as HEAD:master. > > Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> > --- > refspec.c | 5 +- > t/t5511-refspec.sh | 2 + > t/t5516-fetch-push.sh | 106 ++++++++++++++++++++++-------------------- > 3 files changed, 61 insertions(+), 52 deletions(-)
Sorry, but I cannot queue this version in today's pushout due to time constraints.
> -test_expect_success 'push with HEAD' ' > +for head in HEAD @; do
Style: replace "; " with a LF.
> + test_expect_success "push with $head" "
Don't open the test body with double-quote; keep using the original single-quote and the reference to $head is resolved while running the test, not when the test body is formulated before eval'ed.
Two benefits are
- (obvious) you do not need extra quoting, e.g. \$the_commit etc.
- in this case it does not matter, but it works intuitively when the variable has $IFS whitespace in it. If you write in the test body that is enclosed in a single-quote pair,
git push testrepo "$head"
would correctly give the contents of variable head as a single element in argv[] of "git push".
For the latter reason, it is encouraged to make it a habit to do so.
Thanks.