Thread (34 messages) 34 messages, 5 authors, 2021-07-05

Re: [PATCH 10/15] [GSOC] cat-file: add has_object_file() check

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-07-02 13:34:59

On Thu, Jul 01 2021, ZheNing Hu via GitGitGadget wrote:
quoted hunk ↗ jump to hunk
From: ZheNing Hu <redacted>

Use `has_object_file()` in `batch_one_object()` to check
whether the input object exists. This can help us reject
the missing oid when we let `cat-file --batch` use ref-filter
logic later.

Mentored-by: Christian Couder [off-list ref]
Mentored-by: Hariom Verma [off-list ref]
Signed-off-by: ZheNing Hu <redacted>
---
 builtin/cat-file.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 243fe6844bc..59a86412fd0 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -428,6 +428,13 @@ static void batch_one_object(const char *obj_name,
 		return;
 	}
 
+	if (!has_object_file(&data->oid)) {
+		printf("%s missing\n",
+		       obj_name ? obj_name : oid_to_hex(&data->oid));
+		fflush(stdout);
+		return;
+	}
+
 	batch_object_write(obj_name, scratch, opt, data);
 }
In 12/15 the old "missing" is removed, so is this strictly redundant to
what's in batch_object_write() for now, does it change anything?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help