git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] diff -c -p: do not die on submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 29, 2009, 23:09 UTC
Message-ID
<7vr5zb5a6v.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<81b0412b0904291450w3d292ed5i3b2ab5164c0ae0f4@mail.gmail.com>
Alex Riesen <raa.lkml@gmail.com> writes:
Show 9 quoted lines
> 2009/4/29 Junio C Hamano <gitster@pobox.com>:
>> +
>> +       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).

The arena is sufficiently large that there is no way any broken snprintf can return negative here.

This is a copy from Linus's diff_populate_gitlink(), that dates back to 0478675 (Expose subprojects as special files to "git diff" machinery, 2007-04-15), and you have never seen any breakage, which should tell you something.

As I mentioned in the original patch, the codepath that reads one side of diff (either from a blob or from a work tree entity) in show_patch_diff() and grab_blob() in combine-diff.c should do the same thing as what diff_populate_filespec() in diff.c does, and these three functions need some refactoring to share more code. The patch however is about fixing the existing breakage without invasive refactoring.

Previous: Finn Arne GangstadNext: Junio C Hamano
Message 14 of 15 in “different git-merge behavior with regard to submodules in 1.6.2.4 vs. 1.6.2.1”
  1. Tim OlsenApr 28, 2009
  2. Junio C HamanoApr 28, 2009
  3. Finn Arne GangstadApr 28, 2009
  4. Clemens BuchacherApr 29, 2009
  5. Finn Arne GangstadApr 29, 2009
  6. Teach gitlinks to combine-diffJunio C Hamano, Apr 29, 2009
  7. diff -c -p: do not die on submodulesJunio C Hamano, Apr 29, 2009
  8. Alex RiesenApr 29, 2009
  9. Johannes SchindelinApr 29, 2009
  10. Alex RiesenApr 29, 2009
  11. Johannes SchindelinApr 29, 2009
  12. Alex RiesenApr 30, 2009
  13. Finn Arne GangstadApr 30, 2009
  14. Junio C HamanoApr 29, 2009
  15. Junio C HamanoApr 29, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.