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 <jrnieder@gmail.com> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Sep 2, 2014 at 14:11 UTC 88499b296b5f62338d7fa4019c7b5f9012b4ab88
1 file changed +15 -12
builtin/update-ref.c
+15 -12
@@ -12,8 +12,6 @@ static const char * const git_update_ref_usage[] = {
12 NULL
13 };
14
15 -static struct ref_transaction *transaction;
16 -
15 static char line_termination = '\n';
16 static int update_flags;
17
@@ -176,7 +174,8 @@ static int parse_next_sha1(struct strbuf *input, const char **next,
174 * depending on how line_termination is set.
175 */
176
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)
179 {
180 struct strbuf err = STRBUF_INIT;
181 char *refname;
@@ -209,7 +208,8 @@ static const char *parse_cmd_update(struct strbuf *input, const char *next)
208 return next;
209 }
210
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)
213 {
214 struct strbuf err = STRBUF_INIT;
215 char *refname;
@@ -239,7 +239,8 @@ static const char *parse_cmd_create(struct strbuf *input, const char *next)
239 return next;
240 }
241
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)
244 {
245 struct strbuf err = STRBUF_INIT;
246 char *refname;
@@ -273,7 +274,8 @@ static const char *parse_cmd_delete(struct strbuf *input, const char *next)
274 return next;
275 }
276
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)
279 {
280 struct strbuf err = STRBUF_INIT;
281 char *refname;
@@ -317,7 +319,7 @@ static const char *parse_cmd_option(struct strbuf *input, const char *next)
319 return next + 8;
320 }
321
320 -static void update_refs_stdin(void)
322 +static void update_refs_stdin(struct ref_transaction *transaction)
323 {
324 struct strbuf input = STRBUF_INIT;
325 const char *next;
@@ -332,13 +334,13 @@ static void update_refs_stdin(void)
334 else if (isspace(*next))
335 die("whitespace before command: %s", next);
336 else if (starts_with(next, "update "))
335 - next = parse_cmd_update(&input, next + 7);
337 + next = parse_cmd_update(transaction, &input, next + 7);
338 else if (starts_with(next, "create "))
337 - next = parse_cmd_create(&input, next + 7);
339 + next = parse_cmd_create(transaction, &input, next + 7);
340 else if (starts_with(next, "delete "))
339 - next = parse_cmd_delete(&input, next + 7);
341 + next = parse_cmd_delete(transaction, &input, next + 7);
342 else if (starts_with(next, "verify "))
341 - next = parse_cmd_verify(&input, next + 7);
343 + next = parse_cmd_verify(transaction, &input, next + 7);
344 else if (starts_with(next, "option "))
345 next = parse_cmd_option(&input, next + 7);
346 else
@@ -373,6 +375,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
375
376 if (read_stdin) {
377 struct strbuf err = STRBUF_INIT;
378 + struct ref_transaction *transaction;
379
380 transaction = ref_transaction_begin(&err);
381 if (!transaction)
@@ -381,7 +384,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
384 usage_with_options(git_update_ref_usage, options);
385 if (end_null)
386 line_termination = '\0';
384 - update_refs_stdin();
387 + update_refs_stdin(transaction);
388 if (ref_transaction_commit(transaction, msg, &err))
389 die("%s", err.buf);
390 ref_transaction_free(transaction);