Re: [PATCH v2 2/4] textconv: support for cat_file
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Jun 8, 2010, 18:12 UTC
- Message-ID
- <vpq7hm95r7h.fsf@bauges.imag.fr>
- In-Reply-To
- <1276004958-13540-3-git-send-email-clement.poulain@ensimag.imag.fr>
Clément Poulain <clement.poulain@ensimag.imag.fr> writes:
Show 7 quoted lines
> --- 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/