From: Junio C Hamano <gitster@pobox.com>
To: "W. Trevor King" <wking@tremily.us>
Cc: Git <git@vger.kernel.org>
Subject: Re: [PATCH] Documentation/githooks: Explain pre-rebase parameters
Date: Tue, 19 Feb 2013 11:08:29 -0800 [thread overview]
Message-ID: <7vk3q45dg2.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <c19c03f51d71a58fa3795f665fe4a4c0461fa58f.1361271116.git.wking@tremily.us> (W. Trevor King's message of "Tue, 19 Feb 2013 06:03:24 -0500")
"W. Trevor King" <wking@tremily.us> writes:
> From: "W. Trevor King" <wking@tremily.us>
>
> Descriptions borrowed from templates/hooks--pre-rebase.sample.
>
> Signed-off-by: W. Trevor King <wking@tremily.us>
> ---
> I'm not 100% convinced about this, because the git-rebase.sh uses:
>
> "$GIT_DIR/hooks/pre-rebase" ${1+"$@"}
>
> I haven't been able to find documentation for the ${1+"$@"} syntax.
> Is it in POSIX? It's not in the Bash manual:
>
> $ man bash | grep '\${.*[+]'
> (${BASH_SOURCE[$i+1]}) where ${FUNCNAME[$i]} was called (or
> ${BASH_SOURCE[$i+1]}.
> ${BASH_SOURCE[$i+1]} at line number ${BASH_LINENO[$i]}. The
> ${parameter:+word}
>
> In my local tests, it seems equivalent to "$@".
>
> Also, it appears that the `git-rebase--*.sh` handlers don't use the
> pre-rebase hook. Is this intentional?
The codeflow of git-rebase front-end, when you start rebasing, will
call run_pre_rebase_hook before calling run_specific_rebase. It
will be redundant for handlers to then call it again, no?
In "rebase --continue" and later steps, you would not want to see
the hook trigger.
> Documentation/githooks.txt | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
> index b9003fe..bc837c6 100644
> --- a/Documentation/githooks.txt
> +++ b/Documentation/githooks.txt
> @@ -140,9 +140,10 @@ the outcome of 'git commit'.
> pre-rebase
> ~~~~~~~~~~
>
> -This hook is called by 'git rebase' and can be used to prevent a branch
> -from getting rebased.
> -
> +This hook is called by 'git rebase' and can be used to prevent a
> +branch from getting rebased. The hook takes two parameters: the
> +upstream the series was forked from and the branch being rebased. The
> +second parameter will be empty when rebasing the current branch.
Technically this is incorrect.
We call it with one or two parameters, and sometimes the second
parameter is _missing_, which is different from calling with an
empty string. For a script written in some scripting languages like
shell and perl, the distinction may not matter (i.e. $2 and $ARGV[1]
will be an empty string when stringified) but not all (accessing
sys.argv[2] may give you an IndexError in Python).
next prev parent reply other threads:[~2013-02-19 19:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 11:03 [PATCH] Documentation/githooks: Explain pre-rebase parameters W. Trevor King
2013-02-19 13:17 ` Thomas Rast
2013-02-19 13:23 ` W. Trevor King
2013-02-19 17:05 ` Junio C Hamano
2013-02-19 19:08 ` Junio C Hamano [this message]
2013-02-20 16:36 ` W. Trevor King
2013-02-20 17:23 ` Junio C Hamano
2013-02-23 15:27 ` [PATCH v2] " W. Trevor King
2013-02-23 21:21 ` Junio C Hamano
2013-02-23 21:35 ` W. Trevor King
2013-02-24 8:13 ` 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=7vk3q45dg2.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=wking@tremily.us \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.