From: Junio C Hamano <gitster@pobox.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Brandon Williams <bwilliams.eng@gmail.com>,
Jacob Keller <jacob.keller@gmail.com>,
Tomo Krajina <tkrajina@gmail.com>
Subject: Re: [PATCH v3 3/3] refspec: make @ a synonym of HEAD
Date: Wed, 25 Nov 2020 15:53:42 -0800 [thread overview]
Message-ID: <xmqqpn41at89.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20201125233443.63130-4-felipe.contreras@gmail.com> (Felipe Contreras's message of "Wed, 25 Nov 2020 17:34:43 -0600")
Felipe Contreras <felipe.contreras@gmail.com> writes:
> 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.
next prev parent reply other threads:[~2020-11-25 23:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-25 23:34 [PATCH v3 0/3] refspec: make @ a synonym of HEAD Felipe Contreras
2020-11-25 23:34 ` [PATCH v3 1/3] tests: push: improve cleanup of HEAD tests Felipe Contreras
2020-11-25 23:34 ` [PATCH v3 2/3] tests: push: trivial cleanup Felipe Contreras
2020-11-25 23:34 ` [PATCH v3 3/3] refspec: make @ a synonym of HEAD Felipe Contreras
2020-11-25 23:53 ` Junio C Hamano [this message]
2020-11-25 23:42 ` [PATCH v3 0/3] " Junio C Hamano
2020-11-27 11:07 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqpn41at89.fsf@gitster.c.googlers.com \
--to=gitster@pobox.com \
--cc=bwilliams.eng@gmail.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=jacob.keller@gmail.com \
--cc=peff@peff.net \
--cc=tkrajina@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).