git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Documentation/githooks: Explain pre-rebase parameters

From
W. Trevor King <wking@tremily.us>
Date
Feb 19, 2013, 11:03 UTC
Message-ID
<c19c03f51d71a58fa3795f665fe4a4c0461fa58f.1361271116.git.wking@tremily.us>
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?

Cheers, Trevor

 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.
 
 post-checkout
 ~~~~~~~~~~~~~
-- 
1.8.1.336.g94702dd
Next: Thomas Rast
Message 1 of 11 in “Documentation/githooks: Explain pre-rebase parameters”
  1. Documentation/githooks: Explain pre-rebase parametersW. Trevor King, Feb 19, 2013
  2. Thomas RastFeb 19, 2013
  3. W. Trevor KingFeb 19, 2013
  4. Junio C HamanoFeb 19, 2013
  5. Junio C HamanoFeb 19, 2013
  6. W. Trevor KingFeb 20, 2013
  7. Junio C HamanoFeb 20, 2013
  8. Documentation/githooks: Explain pre-rebase parametersW. Trevor King, Feb 23, 2013
  9. Junio C HamanoFeb 23, 2013
  10. W. Trevor KingFeb 23, 2013
  11. Junio C HamanoFeb 24, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.