Skip to content

Commit 88499b2

Browse files
jrngitster
authored andcommitted
update-ref --stdin: pass transaction around explicitly
This makes it more obvious at a glance where the output of functions parsing the --stdin stream goes. No functional change intended. Signed-off-by: Jonathan Nieder <[email protected]> Reviewed-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ab5ac95 commit 88499b2

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

builtin/update-ref.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ static const char * const git_update_ref_usage[] = {
1212
NULL
1313
};
1414

15-
static struct ref_transaction *transaction;
16-
1715
static char line_termination = '\n';
1816
static int update_flags;
1917

@@ -176,7 +174,8 @@ static int parse_next_sha1(struct strbuf *input, const char **next,
176174
* depending on how line_termination is set.
177175
*/
178176

179-
static const char *parse_cmd_update(struct strbuf *input, const char *next)
177+
static const char *parse_cmd_update(struct ref_transaction *transaction,
178+
struct strbuf *input, const char *next)
180179
{
181180
struct strbuf err = STRBUF_INIT;
182181
char *refname;
@@ -209,7 +208,8 @@ static const char *parse_cmd_update(struct strbuf *input, const char *next)
209208
return next;
210209
}
211210

212-
static const char *parse_cmd_create(struct strbuf *input, const char *next)
211+
static const char *parse_cmd_create(struct ref_transaction *transaction,
212+
struct strbuf *input, const char *next)
213213
{
214214
struct strbuf err = STRBUF_INIT;
215215
char *refname;
@@ -239,7 +239,8 @@ static const char *parse_cmd_create(struct strbuf *input, const char *next)
239239
return next;
240240
}
241241

242-
static const char *parse_cmd_delete(struct strbuf *input, const char *next)
242+
static const char *parse_cmd_delete(struct ref_transaction *transaction,
243+
struct strbuf *input, const char *next)
243244
{
244245
struct strbuf err = STRBUF_INIT;
245246
char *refname;
@@ -273,7 +274,8 @@ static const char *parse_cmd_delete(struct strbuf *input, const char *next)
273274
return next;
274275
}
275276

276-
static const char *parse_cmd_verify(struct strbuf *input, const char *next)
277+
static const char *parse_cmd_verify(struct ref_transaction *transaction,
278+
struct strbuf *input, const char *next)
277279
{
278280
struct strbuf err = STRBUF_INIT;
279281
char *refname;
@@ -317,7 +319,7 @@ static const char *parse_cmd_option(struct strbuf *input, const char *next)
317319
return next + 8;
318320
}
319321

320-
static void update_refs_stdin(void)
322+
static void update_refs_stdin(struct ref_transaction *transaction)
321323
{
322324
struct strbuf input = STRBUF_INIT;
323325
const char *next;
@@ -332,13 +334,13 @@ static void update_refs_stdin(void)
332334
else if (isspace(*next))
333335
die("whitespace before command: %s", next);
334336
else if (starts_with(next, "update "))
335-
next = parse_cmd_update(&input, next + 7);
337+
next = parse_cmd_update(transaction, &input, next + 7);
336338
else if (starts_with(next, "create "))
337-
next = parse_cmd_create(&input, next + 7);
339+
next = parse_cmd_create(transaction, &input, next + 7);
338340
else if (starts_with(next, "delete "))
339-
next = parse_cmd_delete(&input, next + 7);
341+
next = parse_cmd_delete(transaction, &input, next + 7);
340342
else if (starts_with(next, "verify "))
341-
next = parse_cmd_verify(&input, next + 7);
343+
next = parse_cmd_verify(transaction, &input, next + 7);
342344
else if (starts_with(next, "option "))
343345
next = parse_cmd_option(&input, next + 7);
344346
else
@@ -373,6 +375,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
373375

374376
if (read_stdin) {
375377
struct strbuf err = STRBUF_INIT;
378+
struct ref_transaction *transaction;
376379

377380
transaction = ref_transaction_begin(&err);
378381
if (!transaction)
@@ -381,7 +384,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
381384
usage_with_options(git_update_ref_usage, options);
382385
if (end_null)
383386
line_termination = '\0';
384-
update_refs_stdin();
387+
update_refs_stdin(transaction);
385388
if (ref_transaction_commit(transaction, msg, &err))
386389
die("%s", err.buf);
387390
ref_transaction_free(transaction);

0 commit comments

Comments
 (0)