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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Clément Poulain <clement.poulain@xxxxxxxxxxxxxxx> writes:

> --- 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/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]