get_short_sha1(): correctly disambiguate type-limited abbreviation
[gitweb.git] / builtin / cat-file.c
index 94632dbdb400f9a2986d10f06dd16119ce1b4e54..c27268ff30ab0e818b56f3e0a3ab56028083c6c1 100644 (file)
@@ -90,7 +90,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
        unsigned long size;
        struct object_context obj_context;
 
-       if (get_sha1_with_context(obj_name, sha1, &obj_context))
+       if (get_sha1_with_context(obj_name, 0, sha1, &obj_context))
                die("Not a valid object name %s", obj_name);
 
        buf = NULL;
@@ -187,6 +187,8 @@ static int batch_one_object(const char *obj_name, int print_contents)
        if (type <= 0) {
                printf("%s missing\n", obj_name);
                fflush(stdout);
+               if (print_contents == BATCH)
+                       free(contents);
                return 0;
        }