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

Re: [PATCH 2/3] gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiff

From
Jakub Narebski <jnareb@gmail.com>
Date
Oct 25, 2006, 08:03 UTC
Message-ID
<200610251003.22526.jnareb@gmail.com>
In-Reply-To
<7v1woxf1v9.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 13 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> Filter out commit ID output that git-diff-tree adds when called with
>> only one <tree-ish> (not only for --stdin) in git_commit and
>> git_commitdiff.
> 
> I initially wondered why this, or other existing such sripping,
> is necessary in the first place.
> 
> The collected result is given to git_difftree_body() and it
> feeds parse_difftree_raw_line() with it.  Interestingly enough,
> it _is_ prepared to handle the line with the commit object
> name.

Perhaps I was overeager in adding that. The only place it was used was git_tree_blame in the proof-of-concept/RFC patch which added "tree_blame" view, and even there it was discarded solution: using git-diff-tree can give only commit which changed the file to current version; it cannot find commit which changed tree/directory (latest commit which changed any of its files).

This can be useful if at any time we need to parse git-diff-tree --stdin
output.
 
> However, the very initial part of git_difftree_body assumes that
> the array it gets does not have the commit object name (i.e. it
> counts the array members and says "N files changed").

The same is true for git_patchset_body. Moreover if I remember correctly they count elements of @difftree array (or do equivalent of counting) _before_ parsing.

> So I think your change is probably a good one, but I suspect you
> probably are better off to make parse_difftree_raw_line() to
> barf when it gets the commit object name to make sure that all
> callers strip it at the same time; 
I'd rather not do that, and leave parse_difftree_raw_line generic.
>                                    better yet, perhaps you can 
> have a single function that invokes git-diff-tree -r (with
> different parameters) and returns the result that is already
> only the difftree body lines?

That would be good idea... if not for the fact that git_commitdiff uses --patch-with-raw format... but that would make it only slightly more complicated (strip commit-id, or rather tree-ish from output, and stop on end of raw part i.e. on first empty line).

I'll do that (unless someone else would do this first).
-- 
Jakub Narebski
Previous: Junio C HamanoNext: Jakub Narebski
Message 5 of 8 in “gitweb: Improvements to commitdiff oview”
  1. 0/3 gitweb: Improvements to commitdiff oviewJakub Narebski, Oct 24, 2006
  2. 1/3 gitweb: Get rid of git_print_simplified_logJakub Narebski, Oct 24, 2006
  3. 2/3 gitweb: Filter out commit ID from @difftree in git_commit and git_commitdiffJakub Narebski, Oct 24, 2006
  4. Junio C HamanoOct 25, 2006
  5. Jakub NarebskiOct 25, 2006
  6. 4/3 gitweb: Use --no-commit-id in git_commit and git_commitdiffJakub Narebski, Oct 25, 2006
  7. 2/3 gitweb: Use --no-commit-id in git_commit and git_commitdiffJakub Narebski, Oct 25, 2006
  8. 3/3 gitweb: Print commit message without title in commitdiff only if there is anyJakub Narebski, Oct 24, 2006

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.