summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2014-01-07 17:10:15 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-01-07 14:31:10 -0800
commit07e23839459465c1319c7ce91afaf01d3e31a97e (patch)
treec9eaebc26b18e260241a476fff6207316239737c
parentsha1_name: don't resolve refs when core.warnambiguousrefs is false (diff)
downloadtgif-07e23839459465c1319c7ce91afaf01d3e31a97e.tar.xz
cat-file: refactor error handling of batch_objects
This just pulls the return value for the function out of the inner loop, so we can break out of the loop rather than do an early return. This will make it easier to put any cleanup for the function in one place. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/cat-file.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index b2ca775a80..6b65f56f44 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -260,6 +260,7 @@ static int batch_objects(struct batch_options *opt)
{
struct strbuf buf = STRBUF_INIT;
struct expand_data data;
+ int retval = 0;
if (!opt->format)
opt->format = "%(objectname) %(objecttype) %(objectsize)";
@@ -284,8 +285,6 @@ static int batch_objects(struct batch_options *opt)
warn_on_object_refname_ambiguity = 0;
while (strbuf_getline(&buf, stdin, '\n') != EOF) {
- int error;
-
if (data.split_on_whitespace) {
/*
* Split at first whitespace, tying off the beginning
@@ -300,12 +299,12 @@ static int batch_objects(struct batch_options *opt)
data.rest = p;
}
- error = batch_one_object(buf.buf, opt, &data);
- if (error)
- return error;
+ retval = batch_one_object(buf.buf, opt, &data);
+ if (retval)
+ break;
}
- return 0;
+ return retval;
}
static const char * const cat_file_usage[] = {