Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH v2 2/4] textconv: support for cat_file

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:48:56

Clément Poulain [off-list ref] writes:
quoted hunk
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -9,6 +9,7 @@
+	struct object_context obj_context = OBJECT_CONTEXT_INIT;
 
-	if (get_sha1(obj_name, sha1))
+	if (get_sha1_with_context(obj_name, sha1, &obj_context))
Do you really need to initialize obj_context here? I'd say the
semantics of get_sha1_with_context should be "give me a pointer to an
object_context, and I'll fill it in with the object context, whatever
be its initial value", just like

int i;
scanf("%d", &i);

doesn't require i to be initialized.
+	case 'c':
+		if (!obj_context.path)
+			die("git cat-file --textconv %s: <object> must be <sha1:path>",
+			    obj_name);
obj_context.path is an array contained in the struct. It is always
non-null. Just tried:

$ ./git cat-file --textconv 99f036302a7e6d884369d1d3f4ce428e437cbccd | head
fatal: git cat-file --textconv: unable to run textconv on 99f036302a7e6d884369d1d3f4ce428e437cbccd

you want to check that obj_context.path contains an empty string.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help