зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
fc4937c372
Коммит
82330950d9
|
@ -251,17 +251,14 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int batch_one_object(const char *obj_name, struct batch_options *opt,
|
static void batch_one_object(const char *obj_name, struct batch_options *opt,
|
||||||
struct expand_data *data)
|
struct expand_data *data)
|
||||||
{
|
{
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
struct object_context ctx;
|
struct object_context ctx;
|
||||||
int flags = opt->follow_symlinks ? GET_SHA1_FOLLOW_SYMLINKS : 0;
|
int flags = opt->follow_symlinks ? GET_SHA1_FOLLOW_SYMLINKS : 0;
|
||||||
enum follow_symlinks_result result;
|
enum follow_symlinks_result result;
|
||||||
|
|
||||||
if (!obj_name)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
result = get_sha1_with_context(obj_name, flags, data->sha1, &ctx);
|
result = get_sha1_with_context(obj_name, flags, data->sha1, &ctx);
|
||||||
if (result != FOUND) {
|
if (result != FOUND) {
|
||||||
switch (result) {
|
switch (result) {
|
||||||
|
@ -286,7 +283,7 @@ static int batch_one_object(const char *obj_name, struct batch_options *opt,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.mode == 0) {
|
if (ctx.mode == 0) {
|
||||||
|
@ -294,13 +291,13 @@ static int batch_one_object(const char *obj_name, struct batch_options *opt,
|
||||||
(uintmax_t)ctx.symlink_path.len,
|
(uintmax_t)ctx.symlink_path.len,
|
||||||
ctx.symlink_path.buf);
|
ctx.symlink_path.buf);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sha1_object_info_extended(data->sha1, &data->info, LOOKUP_REPLACE_OBJECT) < 0) {
|
if (sha1_object_info_extended(data->sha1, &data->info, LOOKUP_REPLACE_OBJECT) < 0) {
|
||||||
printf("%s missing\n", obj_name);
|
printf("%s missing\n", obj_name);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_expand(&buf, opt->format, expand_format, data);
|
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,
|
||||||
print_object_or_die(opt, data);
|
print_object_or_die(opt, data);
|
||||||
batch_write(opt, "\n", 1);
|
batch_write(opt, "\n", 1);
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int batch_objects(struct batch_options *opt)
|
static int batch_objects(struct batch_options *opt)
|
||||||
|
@ -367,9 +363,7 @@ static int batch_objects(struct batch_options *opt)
|
||||||
data.rest = p;
|
data.rest = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = batch_one_object(buf.buf, opt, &data);
|
batch_one_object(buf.buf, opt, &data);
|
||||||
if (retval)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strbuf_release(&buf);
|
strbuf_release(&buf);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче