update-ref.c: extract a new function, parse_next_sha1()
commit3afcc4637452100c68b469de7757dd2b45b4d29c
authorMichael Haggerty <mhagger@alum.mit.edu>
Mon, 7 Apr 2014 13:48:05 +0000 (7 15:48 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Apr 2014 19:09:13 +0000 (7 12:09 -0700)
treea807097b5fffd560f9dd598745e7264d29a60fd1
parent191f241b528c10e242d045bde2cef70fb013a6e5
update-ref.c: extract a new function, parse_next_sha1()

Replace three functions, update_store_new_sha1(),
update_store_old_sha1(), and parse_next_arg(), with a single function,
parse_next_sha1().  The new function takes care of a whole argument,
including checking whether it is there, converting it to an SHA-1, and
emitting errors on EOF or for invalid values.  The return value
indicates whether the argument was present or absent, which requires
a bit of intelligence because absent values are represented
differently depending on whether "-z" was used.

The new interface means that the calling functions, parse_cmd_*(),
don't have to interpret the result differently based on the
line_termination mode that is in effect.  It also means that
parse_cmd_create() can distinguish unambiguously between an empty new
value and a zeros new value, which fixes a failure in t1400.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/update-ref.c
t/t1400-update-ref.sh