Skip to content

Commit 280b74c

Browse files
committed
Merge branch 'kn/clarify-update-ref-doc'
Doc update, as a preparation to enhance "git update-ref --stdin". * kn/clarify-update-ref-doc: githooks: use {old,new}-oid instead of {old,new}-value update-ref: use {old,new}-oid instead of {old,new}value
2 parents a4a1453 + 5b1967a commit 280b74c

File tree

4 files changed

+67
-67
lines changed

4 files changed

+67
-67
lines changed

Documentation/git-update-ref.txt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ git-update-ref - Update the object name stored in a ref safely
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git update-ref' [-m <reason>] [--no-deref] (-d <ref> [<oldvalue>] | [--create-reflog] <ref> <newvalue> [<oldvalue>] | --stdin [-z])
11+
'git update-ref' [-m <reason>] [--no-deref] (-d <ref> [<old-oid>] | [--create-reflog] <ref> <new-oid> [<old-oid>] | --stdin [-z])
1212

1313
DESCRIPTION
1414
-----------
15-
Given two arguments, stores the <newvalue> in the <ref>, possibly
15+
Given two arguments, stores the <new-oid> in the <ref>, possibly
1616
dereferencing the symbolic refs. E.g. `git update-ref HEAD
17-
<newvalue>` updates the current branch head to the new object.
17+
<new-oid>` updates the current branch head to the new object.
1818

19-
Given three arguments, stores the <newvalue> in the <ref>,
19+
Given three arguments, stores the <new-oid> in the <ref>,
2020
possibly dereferencing the symbolic refs, after verifying that
21-
the current value of the <ref> matches <oldvalue>.
22-
E.g. `git update-ref refs/heads/master <newvalue> <oldvalue>`
23-
updates the master branch head to <newvalue> only if its current
24-
value is <oldvalue>. You can specify 40 "0" or an empty string
25-
as <oldvalue> to make sure that the ref you are creating does
21+
the current value of the <ref> matches <old-oid>.
22+
E.g. `git update-ref refs/heads/master <new-oid> <old-oid>`
23+
updates the master branch head to <new-oid> only if its current
24+
value is <old-oid>. You can specify 40 "0" or an empty string
25+
as <old-oid> to make sure that the ref you are creating does
2626
not exist.
2727

2828
It also allows a "ref" file to be a symbolic pointer to another
@@ -56,15 +56,15 @@ ref symlink to some other tree, if you have copied a whole
5656
archive by creating a symlink tree).
5757

5858
With `-d` flag, it deletes the named <ref> after verifying it
59-
still contains <oldvalue>.
59+
still contains <old-oid>.
6060

6161
With `--stdin`, update-ref reads instructions from standard input and
6262
performs all modifications together. Specify commands of the form:
6363

64-
update SP <ref> SP <newvalue> [SP <oldvalue>] LF
65-
create SP <ref> SP <newvalue> LF
66-
delete SP <ref> [SP <oldvalue>] LF
67-
verify SP <ref> [SP <oldvalue>] LF
64+
update SP <ref> SP <new-oid> [SP <old-oid>] LF
65+
create SP <ref> SP <new-oid> LF
66+
delete SP <ref> [SP <old-oid>] LF
67+
verify SP <ref> [SP <old-oid>] LF
6868
option SP <opt> LF
6969
start LF
7070
prepare LF
@@ -82,10 +82,10 @@ specify a missing value, omit the value and its preceding SP entirely.
8282
Alternatively, use `-z` to specify in NUL-terminated format, without
8383
quoting:
8484

85-
update SP <ref> NUL <newvalue> NUL [<oldvalue>] NUL
86-
create SP <ref> NUL <newvalue> NUL
87-
delete SP <ref> NUL [<oldvalue>] NUL
88-
verify SP <ref> NUL [<oldvalue>] NUL
85+
update SP <ref> NUL <new-oid> NUL [<old-oid>] NUL
86+
create SP <ref> NUL <new-oid> NUL
87+
delete SP <ref> NUL [<old-oid>] NUL
88+
verify SP <ref> NUL [<old-oid>] NUL
8989
option SP <opt> NUL
9090
start NUL
9191
prepare NUL
@@ -100,22 +100,22 @@ recognizes as an object name. Commands in any other format or a
100100
repeated <ref> produce an error. Command meanings are:
101101

102102
update::
103-
Set <ref> to <newvalue> after verifying <oldvalue>, if given.
104-
Specify a zero <newvalue> to ensure the ref does not exist
105-
after the update and/or a zero <oldvalue> to make sure the
103+
Set <ref> to <new-oid> after verifying <old-oid>, if given.
104+
Specify a zero <new-oid> to ensure the ref does not exist
105+
after the update and/or a zero <old-oid> to make sure the
106106
ref does not exist before the update.
107107

108108
create::
109-
Create <ref> with <newvalue> after verifying it does not
110-
exist. The given <newvalue> may not be zero.
109+
Create <ref> with <new-oid> after verifying it does not
110+
exist. The given <new-oid> may not be zero.
111111

112112
delete::
113-
Delete <ref> after verifying it exists with <oldvalue>, if
114-
given. If given, <oldvalue> may not be zero.
113+
Delete <ref> after verifying it exists with <old-oid>, if
114+
given. If given, <old-oid> may not be zero.
115115

116116
verify::
117-
Verify <ref> against <oldvalue> but do not change it. If
118-
<oldvalue> is zero or missing, the ref must not exist.
117+
Verify <ref> against <old-oid> but do not change it. If
118+
<old-oid> is zero or missing, the ref must not exist.
119119

120120
option::
121121
Modify the behavior of the next command naming a <ref>.
@@ -141,7 +141,7 @@ abort::
141141
Abort the transaction, releasing all locks if the transaction is in
142142
prepared state.
143143

144-
If all <ref>s can be locked with matching <oldvalue>s
144+
If all <ref>s can be locked with matching <old-oid>s
145145
simultaneously, all modifications are performed. Otherwise, no
146146
modifications are performed. Note that while each individual
147147
<ref> is updated or deleted atomically, a concurrent reader may
@@ -161,7 +161,7 @@ formatted as:
161161

162162
Where "oldsha1" is the 40 character hexadecimal value previously
163163
stored in <ref>, "newsha1" is the 40 character hexadecimal value of
164-
<newvalue> and "committer" is the committer's name, email address
164+
<new-oid> and "committer" is the committer's name, email address
165165
and date in the standard Git committer ident format.
166166

167167
Optionally with -m:

Documentation/githooks.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ This hook executes once for the receive operation. It takes no
275275
arguments, but for each ref to be updated it receives on standard
276276
input a line of the format:
277277

278-
<old-value> SP <new-value> SP <ref-name> LF
278+
<old-oid> SP <new-oid> SP <ref-name> LF
279279

280-
where `<old-value>` is the old object name stored in the ref,
281-
`<new-value>` is the new object name to be stored in the ref and
280+
where `<old-oid>` is the old object name stored in the ref,
281+
`<new-oid>` is the new object name to be stored in the ref and
282282
`<ref-name>` is the full name of the ref.
283-
When creating a new ref, `<old-value>` is the all-zeroes object name.
283+
When creating a new ref, `<old-oid>` is the all-zeroes object name.
284284

285285
If the hook exits with non-zero status, none of the refs will be
286286
updated. If the hook exits with zero, updating of individual refs can
@@ -503,13 +503,13 @@ given reference transaction is in:
503503
For each reference update that was added to the transaction, the hook
504504
receives on standard input a line of the format:
505505

506-
<old-value> SP <new-value> SP <ref-name> LF
506+
<old-oid> SP <new-oid> SP <ref-name> LF
507507

508-
where `<old-value>` is the old object name passed into the reference
509-
transaction, `<new-value>` is the new object name to be stored in the
508+
where `<old-oid>` is the old object name passed into the reference
509+
transaction, `<new-oid>` is the new object name to be stored in the
510510
ref and `<ref-name>` is the full name of the ref. When force updating
511511
the reference regardless of its current value or when the reference is
512-
to be created anew, `<old-value>` is the all-zeroes object name. To
512+
to be created anew, `<old-oid>` is the all-zeroes object name. To
513513
distinguish these cases, you can inspect the current value of
514514
`<ref-name>` via `git rev-parse`.
515515

builtin/update-ref.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include "repository.h"
1010

1111
static const char * const git_update_ref_usage[] = {
12-
N_("git update-ref [<options>] -d <refname> [<old-val>]"),
13-
N_("git update-ref [<options>] <refname> <new-val> [<old-val>]"),
12+
N_("git update-ref [<options>] -d <refname> [<old-oid>]"),
13+
N_("git update-ref [<options>] <refname> <new-oid> [<old-oid>]"),
1414
N_("git update-ref [<options>] --stdin [-z]"),
1515
NULL
1616
};
@@ -77,14 +77,14 @@ static char *parse_refname(const char **next)
7777
}
7878

7979
/*
80-
* The value being parsed is <oldvalue> (as opposed to <newvalue>; the
80+
* The value being parsed is <old-oid> (as opposed to <new-oid>; the
8181
* difference affects which error messages are generated):
8282
*/
8383
#define PARSE_SHA1_OLD 0x01
8484

8585
/*
8686
* For backwards compatibility, accept an empty string for update's
87-
* <newvalue> in binary mode to be equivalent to specifying zeros.
87+
* <new-oid> in binary mode to be equivalent to specifying zeros.
8888
*/
8989
#define PARSE_SHA1_ALLOW_EMPTY 0x02
9090

@@ -140,7 +140,7 @@ static int parse_next_oid(const char **next, const char *end,
140140
goto invalid;
141141
} else if (flags & PARSE_SHA1_ALLOW_EMPTY) {
142142
/* With -z, treat an empty value as all zeros: */
143-
warning("%s %s: missing <newvalue>, treating as zero",
143+
warning("%s %s: missing <new-oid>, treating as zero",
144144
command, refname);
145145
oidclr(oid);
146146
} else {
@@ -158,14 +158,14 @@ static int parse_next_oid(const char **next, const char *end,
158158

159159
invalid:
160160
die(flags & PARSE_SHA1_OLD ?
161-
"%s %s: invalid <oldvalue>: %s" :
162-
"%s %s: invalid <newvalue>: %s",
161+
"%s %s: invalid <old-oid>: %s" :
162+
"%s %s: invalid <new-oid>: %s",
163163
command, refname, arg.buf);
164164

165165
eof:
166166
die(flags & PARSE_SHA1_OLD ?
167-
"%s %s: unexpected end of input when reading <oldvalue>" :
168-
"%s %s: unexpected end of input when reading <newvalue>",
167+
"%s %s: unexpected end of input when reading <old-oid>" :
168+
"%s %s: unexpected end of input when reading <new-oid>",
169169
command, refname);
170170
}
171171

@@ -194,7 +194,7 @@ static void parse_cmd_update(struct ref_transaction *transaction,
194194

195195
if (parse_next_oid(&next, end, &new_oid, "update", refname,
196196
PARSE_SHA1_ALLOW_EMPTY))
197-
die("update %s: missing <newvalue>", refname);
197+
die("update %s: missing <new-oid>", refname);
198198

199199
have_old = !parse_next_oid(&next, end, &old_oid, "update", refname,
200200
PARSE_SHA1_OLD);
@@ -225,10 +225,10 @@ static void parse_cmd_create(struct ref_transaction *transaction,
225225
die("create: missing <ref>");
226226

227227
if (parse_next_oid(&next, end, &new_oid, "create", refname, 0))
228-
die("create %s: missing <newvalue>", refname);
228+
die("create %s: missing <new-oid>", refname);
229229

230230
if (is_null_oid(&new_oid))
231-
die("create %s: zero <newvalue>", refname);
231+
die("create %s: zero <new-oid>", refname);
232232

233233
if (*next != line_termination)
234234
die("create %s: extra input: %s", refname, next);
@@ -260,7 +260,7 @@ static void parse_cmd_delete(struct ref_transaction *transaction,
260260
have_old = 0;
261261
} else {
262262
if (is_null_oid(&old_oid))
263-
die("delete %s: zero <oldvalue>", refname);
263+
die("delete %s: zero <old-oid>", refname);
264264
have_old = 1;
265265
}
266266

t/t1400-update-ref.sh

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ test_expect_success 'stdin fails create with no ref' '
622622
test_expect_success 'stdin fails create with no new value' '
623623
echo "create $a" >stdin &&
624624
test_must_fail git update-ref --stdin <stdin 2>err &&
625-
grep "fatal: create $a: missing <newvalue>" err
625+
grep "fatal: create $a: missing <new-oid>" err
626626
'
627627

628628
test_expect_success 'stdin fails create with too many arguments' '
@@ -640,7 +640,7 @@ test_expect_success 'stdin fails update with no ref' '
640640
test_expect_success 'stdin fails update with no new value' '
641641
echo "update $a" >stdin &&
642642
test_must_fail git update-ref --stdin <stdin 2>err &&
643-
grep "fatal: update $a: missing <newvalue>" err
643+
grep "fatal: update $a: missing <new-oid>" err
644644
'
645645

646646
test_expect_success 'stdin fails update with too many arguments' '
@@ -765,21 +765,21 @@ test_expect_success 'stdin update ref fails with wrong old value' '
765765
test_expect_success 'stdin update ref fails with bad old value' '
766766
echo "update $c $m does-not-exist" >stdin &&
767767
test_must_fail git update-ref --stdin <stdin 2>err &&
768-
grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
768+
grep "fatal: update $c: invalid <old-oid>: does-not-exist" err &&
769769
test_must_fail git rev-parse --verify -q $c
770770
'
771771

772772
test_expect_success 'stdin create ref fails with bad new value' '
773773
echo "create $c does-not-exist" >stdin &&
774774
test_must_fail git update-ref --stdin <stdin 2>err &&
775-
grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
775+
grep "fatal: create $c: invalid <new-oid>: does-not-exist" err &&
776776
test_must_fail git rev-parse --verify -q $c
777777
'
778778

779779
test_expect_success 'stdin create ref fails with zero new value' '
780780
echo "create $c " >stdin &&
781781
test_must_fail git update-ref --stdin <stdin 2>err &&
782-
grep "fatal: create $c: zero <newvalue>" err &&
782+
grep "fatal: create $c: zero <new-oid>" err &&
783783
test_must_fail git rev-parse --verify -q $c
784784
'
785785

@@ -803,7 +803,7 @@ test_expect_success 'stdin delete ref fails with wrong old value' '
803803
test_expect_success 'stdin delete ref fails with zero old value' '
804804
echo "delete $a " >stdin &&
805805
test_must_fail git update-ref --stdin <stdin 2>err &&
806-
grep "fatal: delete $a: zero <oldvalue>" err &&
806+
grep "fatal: delete $a: zero <old-oid>" err &&
807807
git rev-parse $m >expect &&
808808
git rev-parse $a >actual &&
809809
test_cmp expect actual
@@ -1027,7 +1027,7 @@ test_expect_success 'stdin -z fails create with no ref' '
10271027
test_expect_success 'stdin -z fails create with no new value' '
10281028
printf $F "create $a" >stdin &&
10291029
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1030-
grep "fatal: create $a: unexpected end of input when reading <newvalue>" err
1030+
grep "fatal: create $a: unexpected end of input when reading <new-oid>" err
10311031
'
10321032

10331033
test_expect_success 'stdin -z fails create with too many arguments' '
@@ -1045,27 +1045,27 @@ test_expect_success 'stdin -z fails update with no ref' '
10451045
test_expect_success 'stdin -z fails update with too few args' '
10461046
printf $F "update $a" "$m" >stdin &&
10471047
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1048-
grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
1048+
grep "fatal: update $a: unexpected end of input when reading <old-oid>" err
10491049
'
10501050

10511051
test_expect_success 'stdin -z emits warning with empty new value' '
10521052
git update-ref $a $m &&
10531053
printf $F "update $a" "" "" >stdin &&
10541054
git update-ref -z --stdin <stdin 2>err &&
1055-
grep "warning: update $a: missing <newvalue>, treating as zero" err &&
1055+
grep "warning: update $a: missing <new-oid>, treating as zero" err &&
10561056
test_must_fail git rev-parse --verify -q $a
10571057
'
10581058

10591059
test_expect_success 'stdin -z fails update with no new value' '
10601060
printf $F "update $a" >stdin &&
10611061
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1062-
grep "fatal: update $a: unexpected end of input when reading <newvalue>" err
1062+
grep "fatal: update $a: unexpected end of input when reading <new-oid>" err
10631063
'
10641064

10651065
test_expect_success 'stdin -z fails update with no old value' '
10661066
printf $F "update $a" "$m" >stdin &&
10671067
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1068-
grep "fatal: update $a: unexpected end of input when reading <oldvalue>" err
1068+
grep "fatal: update $a: unexpected end of input when reading <old-oid>" err
10691069
'
10701070

10711071
test_expect_success 'stdin -z fails update with too many arguments' '
@@ -1083,7 +1083,7 @@ test_expect_success 'stdin -z fails delete with no ref' '
10831083
test_expect_success 'stdin -z fails delete with no old value' '
10841084
printf $F "delete $a" >stdin &&
10851085
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1086-
grep "fatal: delete $a: unexpected end of input when reading <oldvalue>" err
1086+
grep "fatal: delete $a: unexpected end of input when reading <old-oid>" err
10871087
'
10881088

10891089
test_expect_success 'stdin -z fails delete with too many arguments' '
@@ -1101,7 +1101,7 @@ test_expect_success 'stdin -z fails verify with too many arguments' '
11011101
test_expect_success 'stdin -z fails verify with no old value' '
11021102
printf $F "verify $a" >stdin &&
11031103
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1104-
grep "fatal: verify $a: unexpected end of input when reading <oldvalue>" err
1104+
grep "fatal: verify $a: unexpected end of input when reading <old-oid>" err
11051105
'
11061106

11071107
test_expect_success 'stdin -z fails option with unknown name' '
@@ -1160,7 +1160,7 @@ test_expect_success 'stdin -z update ref fails with wrong old value' '
11601160
test_expect_success 'stdin -z update ref fails with bad old value' '
11611161
printf $F "update $c" "$m" "does-not-exist" >stdin &&
11621162
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1163-
grep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&
1163+
grep "fatal: update $c: invalid <old-oid>: does-not-exist" err &&
11641164
test_must_fail git rev-parse --verify -q $c
11651165
'
11661166

@@ -1178,14 +1178,14 @@ test_expect_success 'stdin -z create ref fails with bad new value' '
11781178
git update-ref -d "$c" &&
11791179
printf $F "create $c" "does-not-exist" >stdin &&
11801180
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1181-
grep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&
1181+
grep "fatal: create $c: invalid <new-oid>: does-not-exist" err &&
11821182
test_must_fail git rev-parse --verify -q $c
11831183
'
11841184

11851185
test_expect_success 'stdin -z create ref fails with empty new value' '
11861186
printf $F "create $c" "" >stdin &&
11871187
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1188-
grep "fatal: create $c: missing <newvalue>" err &&
1188+
grep "fatal: create $c: missing <new-oid>" err &&
11891189
test_must_fail git rev-parse --verify -q $c
11901190
'
11911191

@@ -1209,7 +1209,7 @@ test_expect_success 'stdin -z delete ref fails with wrong old value' '
12091209
test_expect_success 'stdin -z delete ref fails with zero old value' '
12101210
printf $F "delete $a" "$Z" >stdin &&
12111211
test_must_fail git update-ref -z --stdin <stdin 2>err &&
1212-
grep "fatal: delete $a: zero <oldvalue>" err &&
1212+
grep "fatal: delete $a: zero <old-oid>" err &&
12131213
git rev-parse $m >expect &&
12141214
git rev-parse $a >actual &&
12151215
test_cmp expect actual

0 commit comments

Comments
 (0)