rev-list: disable object/refname ambiguity check with --stdin
[gitweb.git] / builtin / cat-file.c
index b2ca775a80f54fcceba344d5545fe3cb34ba0184..cc863ff78c1b7f4029f8c3a2011c5bd0054a3b84 100644 (file)
@@ -260,6 +260,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)";
@@ -281,11 +283,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
@@ -300,12 +301,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[] = {