Skip to content

Commit 8233095

Browse files
peffgitster
authored andcommitted
cat-file: stop returning value from batch_one_object
If batch_one_object returns an error code, we stop reading input. However, it will only do so if we feed it NULL, which cannot happen; we give it the "buf" member of a strbuf, which is always non-NULL. We did originally stop on other errors (like a missing object), but this was changed in 3c076db (cat-file --batch / --batch-check: do not exit if hashes are missing, 2008-06-09). These days we keep going for any per-object error (and print "missing" when necessary). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent fc4937c commit 8233095

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

builtin/cat-file.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,14 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
251251
}
252252
}
253253

254-
static int batch_one_object(const char *obj_name, struct batch_options *opt,
255-
struct expand_data *data)
254+
static void batch_one_object(const char *obj_name, struct batch_options *opt,
255+
struct expand_data *data)
256256
{
257257
struct strbuf buf = STRBUF_INIT;
258258
struct object_context ctx;
259259
int flags = opt->follow_symlinks ? GET_SHA1_FOLLOW_SYMLINKS : 0;
260260
enum follow_symlinks_result result;
261261

262-
if (!obj_name)
263-
return 1;
264-
265262
result = get_sha1_with_context(obj_name, flags, data->sha1, &ctx);
266263
if (result != FOUND) {
267264
switch (result) {
@@ -286,21 +283,21 @@ static int batch_one_object(const char *obj_name, struct batch_options *opt,
286283
break;
287284
}
288285
fflush(stdout);
289-
return 0;
286+
return;
290287
}
291288

292289
if (ctx.mode == 0) {
293290
printf("symlink %"PRIuMAX"\n%s\n",
294291
(uintmax_t)ctx.symlink_path.len,
295292
ctx.symlink_path.buf);
296293
fflush(stdout);
297-
return 0;
294+
return;
298295
}
299296

300297
if (sha1_object_info_extended(data->sha1, &data->info, LOOKUP_REPLACE_OBJECT) < 0) {
301298
printf("%s missing\n", obj_name);
302299
fflush(stdout);
303-
return 0;
300+
return;
304301
}
305302

306303
strbuf_expand(&buf, opt->format, expand_format, data);
@@ -312,7 +309,6 @@ static int batch_one_object(const char *obj_name, struct batch_options *opt,
312309
print_object_or_die(opt, data);
313310
batch_write(opt, "\n", 1);
314311
}
315-
return 0;
316312
}
317313

318314
static int batch_objects(struct batch_options *opt)
@@ -367,9 +363,7 @@ static int batch_objects(struct batch_options *opt)
367363
data.rest = p;
368364
}
369365

370-
retval = batch_one_object(buf.buf, opt, &data);
371-
if (retval)
372-
break;
366+
batch_one_object(buf.buf, opt, &data);
373367
}
374368

375369
strbuf_release(&buf);

0 commit comments

Comments
 (0)