summaryrefslogtreecommitdiff
path: root/builtin/cat-file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-25 18:07:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-03-25 18:07:36 (GMT)
commitd4c6e9fb6f0db328a40905a3555f8f41d37aaec5 (patch)
treea2a2df7ccf5d3bcb7f8c170756b2541a1307a52c /builtin/cat-file.c
parentec8cd4fc111266e005d1a1bc3d4b388564105ce2 (diff)
parent4c30d50402c17d2569151820b92cea110ad1d240 (diff)
downloadgit-d4c6e9fb6f0db328a40905a3555f8f41d37aaec5.zip
git-d4c6e9fb6f0db328a40905a3555f8f41d37aaec5.tar.gz
git-d4c6e9fb6f0db328a40905a3555f8f41d37aaec5.tar.bz2
Merge branch 'jk/warn-on-object-refname-ambiguity'
* jk/warn-on-object-refname-ambiguity: rev-list: disable object/refname ambiguity check with --stdin cat-file: restore warn_on_object_refname_ambiguity flag cat-file: fix a minor memory leak in batch_objects cat-file: refactor error handling of batch_objects
Diffstat (limited to 'builtin/cat-file.c')
-rw-r--r--builtin/cat-file.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index d5a93e0..7073304 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -269,6 +269,8 @@ static int batch_objects(struct batch_options *opt)
{
struct strbuf buf = STRBUF_INIT;
struct expand_data data;
+ int save_warning;
+ int retval = 0;
if (!opt->format)
opt->format = "%(objectname) %(objecttype) %(objectsize)";
@@ -297,11 +299,10 @@ static int batch_objects(struct batch_options *opt)
* warn) ends up dwarfing the actual cost of the object lookups
* themselves. We can work around it by just turning off the warning.
*/
+ save_warning = warn_on_object_refname_ambiguity;
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
@@ -316,12 +317,14 @@ 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;
+ strbuf_release(&buf);
+ warn_on_object_refname_ambiguity = save_warning;
+ return retval;
}
static const char * const cat_file_usage[] = {