Skip to content

Commit d4c6e9f

Browse files
committed
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
2 parents ec8cd4f + 4c30d50 commit d4c6e9f

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

builtin/cat-file.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ static int batch_objects(struct batch_options *opt)
269269
{
270270
struct strbuf buf = STRBUF_INIT;
271271
struct expand_data data;
272+
int save_warning;
273+
int retval = 0;
272274

273275
if (!opt->format)
274276
opt->format = "%(objectname) %(objecttype) %(objectsize)";
@@ -297,11 +299,10 @@ static int batch_objects(struct batch_options *opt)
297299
* warn) ends up dwarfing the actual cost of the object lookups
298300
* themselves. We can work around it by just turning off the warning.
299301
*/
302+
save_warning = warn_on_object_refname_ambiguity;
300303
warn_on_object_refname_ambiguity = 0;
301304

302305
while (strbuf_getline(&buf, stdin, '\n') != EOF) {
303-
int error;
304-
305306
if (data.split_on_whitespace) {
306307
/*
307308
* Split at first whitespace, tying off the beginning
@@ -316,12 +317,14 @@ static int batch_objects(struct batch_options *opt)
316317
data.rest = p;
317318
}
318319

319-
error = batch_one_object(buf.buf, opt, &data);
320-
if (error)
321-
return error;
320+
retval = batch_one_object(buf.buf, opt, &data);
321+
if (retval)
322+
break;
322323
}
323324

324-
return 0;
325+
strbuf_release(&buf);
326+
warn_on_object_refname_ambiguity = save_warning;
327+
return retval;
325328
}
326329

327330
static const char * const cat_file_usage[] = {

revision.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,10 @@ static void read_revisions_from_stdin(struct rev_info *revs,
15751575
{
15761576
struct strbuf sb;
15771577
int seen_dashdash = 0;
1578+
int save_warning;
1579+
1580+
save_warning = warn_on_object_refname_ambiguity;
1581+
warn_on_object_refname_ambiguity = 0;
15781582

15791583
strbuf_init(&sb, 1000);
15801584
while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) {
@@ -1596,7 +1600,9 @@ static void read_revisions_from_stdin(struct rev_info *revs,
15961600
}
15971601
if (seen_dashdash)
15981602
read_pathspec_from_stdin(revs, &sb, prune);
1603+
15991604
strbuf_release(&sb);
1605+
warn_on_object_refname_ambiguity = save_warning;
16001606
}
16011607

16021608
static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)

0 commit comments

Comments
 (0)