Re: [PATCH v2] diff -c -p: do not die on submodules
- From
Alex Riesen <raa.lkml@gmail.com>
- Date
- Apr 29, 2009, 21:50 UTC
- Message-ID
- <81b0412b0904291450w3d292ed5i3b2ab5164c0ae0f4@mail.gmail.com>
- In-Reply-To
- <7vy6tj8aur.fsf_-_@gitster.siamese.dyndns.org>
2009/4/29 Junio C Hamano <gitster@pobox.com>:
Show 5 quoted lines
> +
> + if (S_ISGITLINK(mode)) {
> + blob = xmalloc(100);
> + *size = snprintf(blob, 100,
> + "Subproject commit %s\n", sha1_to_hex(sha1));snprintf returns a signed value. It also has a bad record of returning negative values for obscure reasons (on obscure platforms, admittedly).
For this particular case,
strcpy(blob, "Subproject commit "); strcat(blob, sha1_to_hex(sha1)); strcat(blob, "\n"); *size = strlen(blob); /* that's a constant */
could be considered.