From: Jeff King <peff@peff.net>
To: "Øystein Walle" <oystwa@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] commit: inform pre-commit if --amend is used
Date: Mon, 24 Nov 2014 22:44:24 -0500 [thread overview]
Message-ID: <20141125034424.GA19161@peff.net> (raw)
In-Reply-To: <1416828111-4567-1-git-send-email-oystwa@gmail.com>
On Mon, Nov 24, 2014 at 12:21:51PM +0100, Øystein Walle wrote:
> This hook is invoked by 'git commit', and can be bypassed
> -with `--no-verify` option. It takes no parameter, and is
> +with `--no-verify` option. It takes one parameter which is "amend" if
> +`--amend` was used when committing and empty otherwise. It is
This interface change is OK for backwards compatibility, since existing
scripts would not look at the arguments (which are always empty
currently). And I think it is OK for adding new options in the future,
too, because the option is always present (just sometimes as an empty
string). Can we make the non-amend option something more verbose than
the empty string (like "noamend")? I have two reasons:
1. It is a bit more obvious when debugging or dumping arguments (e.g.,
via GIT_TRACE), especially if new options are added after the
first.
2. It makes it easier for a script to work on old and new versions of
git. It sees either "amend" or "noamend" for the two obvious cases,
and if it sees no argument, then it knows that it does not know
either way (it is running on an old version of git).
Technically one can tell the difference in shell between an empty
string and a missing argument, but it is sufficiently subtle that I
think "noamend" is a better route.
> +# a hook that checks if "amend" is passed as an argument
> +cat > "$HOOK" <<EOF
> +#!/bin/sh
> +test "\$1" = amend
> +EOF
Eric mentioned write_script already (and it would be nice to convert the
existing uses in t7503 to use it). You may also want to use "\EOF" to
inhibit interpolation in the here-document, which means you do not have
to quote variables inside the script.
-Peff
next prev parent reply other threads:[~2014-11-25 3:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-24 11:21 [PATCH] commit: inform pre-commit if --amend is used Øystein Walle
2014-11-24 23:14 ` Eric Sunshine
2014-11-25 3:44 ` Jeff King [this message]
2014-11-25 4:58 ` Junio C Hamano
2014-11-25 5:03 ` Jeff King
2014-11-27 14:40 ` Mark Levedahl
2014-11-28 5:18 ` Jeff King
2014-11-28 15:49 ` Mark Levedahl
2014-12-01 0:56 ` Junio C Hamano
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=20141125034424.GA19161@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=oystwa@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).