Skip to content

Commit d2ea03d

Browse files
committed
Merge branch 'ps/transactional-update-ref-stdin'
"git update-ref --stdin" learned a handful of new verbs to let the user control ref update transactions more explicitly, which helps as an ingredient to implement two-phase commit-style atomic ref-updates across multiple repositories. * ps/transactional-update-ref-stdin: update-ref: implement interactive transaction handling update-ref: read commands in a line-wise fashion update-ref: move transaction handling into `update_refs_stdin()` update-ref: pass end pointer instead of strbuf update-ref: drop unused argument for `parse_refname` update-ref: organize commands in an array strbuf: provide function to append whole lines git-update-ref.txt: add missing word refs: fix segfault when aborting empty transaction
2 parents 6eacc39 + e48cf33 commit d2ea03d

File tree

6 files changed

+363
-75
lines changed

6 files changed

+363
-75
lines changed

Documentation/git-update-ref.txt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ performs all modifications together. Specify commands of the form:
6666
delete SP <ref> [SP <oldvalue>] LF
6767
verify SP <ref> [SP <oldvalue>] LF
6868
option SP <opt> LF
69+
start LF
70+
prepare LF
71+
commit LF
72+
abort LF
6973

7074
With `--create-reflog`, update-ref will create a reflog for each ref
7175
even if one would not ordinarily be created.
@@ -83,6 +87,10 @@ quoting:
8387
delete SP <ref> NUL [<oldvalue>] NUL
8488
verify SP <ref> NUL [<oldvalue>] NUL
8589
option SP <opt> NUL
90+
start NUL
91+
prepare NUL
92+
commit NUL
93+
abort NUL
8694

8795
In this format, use 40 "0" to specify a zero value, and use the empty
8896
string to specify a missing value.
@@ -107,13 +115,31 @@ delete::
107115

108116
verify::
109117
Verify <ref> against <oldvalue> but do not change it. If
110-
<oldvalue> zero or missing, the ref must not exist.
118+
<oldvalue> is zero or missing, the ref must not exist.
111119

112120
option::
113121
Modify behavior of the next command naming a <ref>.
114122
The only valid option is `no-deref` to avoid dereferencing
115123
a symbolic ref.
116124

125+
start::
126+
Start a transaction. In contrast to a non-transactional session, a
127+
transaction will automatically abort if the session ends without an
128+
explicit commit.
129+
130+
prepare::
131+
Prepare to commit the transaction. This will create lock files for all
132+
queued reference updates. If one reference could not be locked, the
133+
transaction will be aborted.
134+
135+
commit::
136+
Commit all reference updates queued for the transaction, ending the
137+
transaction.
138+
139+
abort::
140+
Abort the transaction, releasing all locks if the transaction is in
141+
prepared state.
142+
117143
If all <ref>s can be locked with matching <oldvalue>s
118144
simultaneously, all modifications are performed. Otherwise, no
119145
modifications are performed. Note that while each individual

0 commit comments

Comments
 (0)