diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2014-09-02 14:11:21 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-09-03 10:04:19 -0700 |
commit | 88499b296b5f62338d7fa4019c7b5f9012b4ab88 (patch) | |
tree | e9550960ceb61dd6c91099c6d7e8066213b66b9c /builtin | |
parent | update-ref --stdin: narrow scope of err strbuf (diff) | |
download | tgif-88499b296b5f62338d7fa4019c7b5f9012b4ab88.tar.xz |
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>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/update-ref.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/builtin/update-ref.c b/builtin/update-ref.c index 866bbee67e..54a48c0cfa 100644 --- a/builtin/update-ref.c +++ b/builtin/update-ref.c @@ -12,8 +12,6 @@ static const char * const git_update_ref_usage[] = { NULL }; -static struct ref_transaction *transaction; - static char line_termination = '\n'; static int update_flags; @@ -176,7 +174,8 @@ static int parse_next_sha1(struct strbuf *input, const char **next, * depending on how line_termination is set. */ -static const char *parse_cmd_update(struct strbuf *input, const char *next) +static const char *parse_cmd_update(struct ref_transaction *transaction, + struct strbuf *input, const char *next) { struct strbuf err = STRBUF_INIT; char *refname; @@ -209,7 +208,8 @@ static const char *parse_cmd_update(struct strbuf *input, const char *next) return next; } -static const char *parse_cmd_create(struct strbuf *input, const char *next) +static const char *parse_cmd_create(struct ref_transaction *transaction, + struct strbuf *input, const char *next) { struct strbuf err = STRBUF_INIT; char *refname; @@ -239,7 +239,8 @@ static const char *parse_cmd_create(struct strbuf *input, const char *next) return next; } -static const char *parse_cmd_delete(struct strbuf *input, const char *next) +static const char *parse_cmd_delete(struct ref_transaction *transaction, + struct strbuf *input, const char *next) { struct strbuf err = STRBUF_INIT; char *refname; @@ -273,7 +274,8 @@ static const char *parse_cmd_delete(struct strbuf *input, const char *next) return next; } -static const char *parse_cmd_verify(struct strbuf *input, const char *next) +static const char *parse_cmd_verify(struct ref_transaction *transaction, + struct strbuf *input, const char *next) { struct strbuf err = STRBUF_INIT; char *refname; @@ -317,7 +319,7 @@ static const char *parse_cmd_option(struct strbuf *input, const char *next) return next + 8; } -static void update_refs_stdin(void) +static void update_refs_stdin(struct ref_transaction *transaction) { struct strbuf input = STRBUF_INIT; const char *next; @@ -332,13 +334,13 @@ static void update_refs_stdin(void) else if (isspace(*next)) die("whitespace before command: %s", next); else if (starts_with(next, "update ")) - next = parse_cmd_update(&input, next + 7); + next = parse_cmd_update(transaction, &input, next + 7); else if (starts_with(next, "create ")) - next = parse_cmd_create(&input, next + 7); + next = parse_cmd_create(transaction, &input, next + 7); else if (starts_with(next, "delete ")) - next = parse_cmd_delete(&input, next + 7); + next = parse_cmd_delete(transaction, &input, next + 7); else if (starts_with(next, "verify ")) - next = parse_cmd_verify(&input, next + 7); + next = parse_cmd_verify(transaction, &input, next + 7); else if (starts_with(next, "option ")) next = parse_cmd_option(&input, next + 7); else @@ -373,6 +375,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) if (read_stdin) { struct strbuf err = STRBUF_INIT; + struct ref_transaction *transaction; transaction = ref_transaction_begin(&err); if (!transaction) @@ -381,7 +384,7 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix) usage_with_options(git_update_ref_usage, options); if (end_null) line_termination = '\0'; - update_refs_stdin(); + update_refs_stdin(transaction); if (ref_transaction_commit(transaction, msg, &err)) die("%s", err.buf); ref_transaction_free(transaction); |