Skip to content

Commit 20adca9

Browse files
committed
Merge branch 'ps/update-ref-trans-hook-doc'
Doc update. * ps/update-ref-trans-hook-doc: githooks.txt: clarify documentation on reference-transaction hook githooks.txt: replace mentions of SHA-1 specific properties
2 parents 960f466 + 23c781f commit 20adca9

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

Documentation/githooks.txt

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ given); `template` (if a `-t` option was given or the
138138
configuration option `commit.template` is set); `merge` (if the
139139
commit is a merge or a `.git/MERGE_MSG` file exists); `squash`
140140
(if a `.git/SQUASH_MSG` file exists); or `commit`, followed by
141-
a commit SHA-1 (if a `-c`, `-C` or `--amend` option was given).
141+
a commit object name (if a `-c`, `-C` or `--amend` option was given).
142142

143143
If the exit status is non-zero, `git commit` will abort.
144144

@@ -231,19 +231,19 @@ named remote is not being used both values will be the same.
231231
Information about what is to be pushed is provided on the hook's standard
232232
input with lines of the form:
233233

234-
<local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF
234+
<local ref> SP <local object name> SP <remote ref> SP <remote object name> LF
235235

236236
For instance, if the command +git push origin master:foreign+ were run the
237237
hook would receive a line like the following:
238238

239239
refs/heads/master 67890 refs/heads/foreign 12345
240240

241-
although the full, 40-character SHA-1s would be supplied. If the foreign ref
242-
does not yet exist the `<remote SHA-1>` will be 40 `0`. If a ref is to be
243-
deleted, the `<local ref>` will be supplied as `(delete)` and the `<local
244-
SHA-1>` will be 40 `0`. If the local commit was specified by something other
245-
than a name which could be expanded (such as `HEAD~`, or a SHA-1) it will be
246-
supplied as it was originally given.
241+
although the full object name would be supplied. If the foreign ref does not
242+
yet exist the `<remote object name>` will be the all-zeroes object name. If a
243+
ref is to be deleted, the `<local ref>` will be supplied as `(delete)` and the
244+
`<local object name>` will be the all-zeroes object name. If the local commit
245+
was specified by something other than a name which could be expanded (such as
246+
`HEAD~`, or an object name) it will be supplied as it was originally given.
247247

248248
If this hook exits with a non-zero status, `git push` will abort without
249249
pushing anything. Information about why the push is rejected may be sent
@@ -268,7 +268,7 @@ input a line of the format:
268268
where `<old-value>` is the old object name stored in the ref,
269269
`<new-value>` is the new object name to be stored in the ref and
270270
`<ref-name>` is the full name of the ref.
271-
When creating a new ref, `<old-value>` is 40 `0`.
271+
When creating a new ref, `<old-value>` is the all-zeroes object name.
272272

273273
If the hook exits with non-zero status, none of the refs will be
274274
updated. If the hook exits with zero, updating of individual refs can
@@ -473,7 +473,8 @@ reference-transaction
473473

474474
This hook is invoked by any Git command that performs reference
475475
updates. It executes whenever a reference transaction is prepared,
476-
committed or aborted and may thus get called multiple times.
476+
committed or aborted and may thus get called multiple times. The hook
477+
does not cover symbolic references (but that may change in the future).
477478

478479
The hook takes exactly one argument, which is the current state the
479480
given reference transaction is in:
@@ -492,6 +493,14 @@ receives on standard input a line of the format:
492493

493494
<old-value> SP <new-value> SP <ref-name> LF
494495

496+
where `<old-value>` is the old object name passed into the reference
497+
transaction, `<new-value>` is the new object name to be stored in the
498+
ref and `<ref-name>` is the full name of the ref. When force updating
499+
the reference regardless of its current value or when the reference is
500+
to be created anew, `<old-value>` is the all-zeroes object name. To
501+
distinguish these cases, you can inspect the current value of
502+
`<ref-name>` via `git rev-parse`.
503+
495504
The exit status of the hook is ignored for any state except for the
496505
"prepared" state. In the "prepared" state, a non-zero exit status will
497506
cause the transaction to be aborted. The hook will not be called with
@@ -550,7 +559,7 @@ command-dependent arguments may be passed in the future.
550559
The hook receives a list of the rewritten commits on stdin, in the
551560
format
552561

553-
<old-sha1> SP <new-sha1> [ SP <extra-info> ] LF
562+
<old-object-name> SP <new-object-name> [ SP <extra-info> ] LF
554563

555564
The 'extra-info' is again command-dependent. If it is empty, the
556565
preceding SP is also omitted. Currently, no commands pass any
@@ -566,7 +575,7 @@ rebase::
566575
For the 'squash' and 'fixup' operation, all commits that were
567576
squashed are listed as being rewritten to the squashed commit.
568577
This means that there will be several lines sharing the same
569-
'new-sha1'.
578+
'new-object-name'.
570579
+
571580
The commits are guaranteed to be listed in the order that they were
572581
processed by rebase.

0 commit comments

Comments
 (0)