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

Re: gitweb/gitk: empty merge diffs

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 29, 2008, 17:21 UTC
Message-ID
<m34p7ci2ch.fsf@localhost.localdomain>
In-Reply-To
<4867B105.7070208@gmail.com>
Lea Wiemann <lewiemann@gmail.com> writes:
> I'm trying to get the diff of a merge ("git diff master^1 master")
> with gitk and gitweb, but both of them only show empty diffs (you can
> try yourself using the test script below).

Note that if you are handcrafting gitweb URL, gitweb does not allow "master^1" as value of 'hp' ($hash_parent) parameter due to overly strict validation (checking) of this parameter: only values suitable as refnames, or (shortened) SHA-1 identifiers are accepted.

> Gitk doesn't seem to allow me to view the merge diff at all.
> 
> Gitweb only shows "Trivial merge" in the commitdiff view.  

Because it _is_ trivial (tree level) merge, see documentation of diff format for merges in git-diff(1) or Documentation/diff-format.txt:

  Note that 'combined diff' lists only files which were modified from
  all parents.

If combined diff raw (difftree) format lists nothing, gitweb denotes this as "Trivial merge".

> In the commit view, I can get the merge diff I want by clicking the
> "diff" link behind the first parent.
You can also click on the "commitdiff" link in the navbar (at top of
the page), or you can click on commit title to switch between 'commit'
and 'commitdiff' views.
 
> Why is this a "trivial merge", and what's the reason for gitweb not
> displaying the diff to the first parent in the commitdiff view?  I'm
> kinda confused here.

Lets take git.git repository as an example. Gitweb can display both combined diff output for merge commit, and compact combined (--cc) output (default); if you however provide both parents it would always display ordinary diff. The "diff" links in the 'commit' view you have mentioned, and "1"/"2"/... links in treediff part of combined merge output in 'commitdiff' view, always display ordinary diff.

Default compact combined diff of a merge commit (c.f. "git show pu")
  http://repo.or.cz/w/git.git?a=commitdiff;h=58829d79 ('pu' branch)
Diff to first parent (c.f. "git diff pu^1 pu")
  http://repo.or.cz/w/git.git?a=commitdiff;h=58829d79;hp=c944eebd
Diff to second parent (c.f. "git diff pu^2 pu")
Warning: large diff, and it takes some time to be displayed!
  http://repo.or.cz/w/git.git?a=commitdiff;h=58829d79;hp=f1646543
Show 13 quoted lines
> ===== Graph: =====
> 
> *   master      merge mybranch into master
> |\
> | * mybranch    change file2 on mybranch
> | * mybranch~1  change file2 on mybranch
> * | master~1    change file1 on master
> * | master~2    change file1 on master
> |/
> * mybranch~2    initial commit
> 
> 
> ===== Script to set up the repository: =====
Well, you can display diff to first parent in gitweb, see
  http://localhost/gitweb.cgi/test-repo.git?a=commitdiff;h=36c2b5d0;hp=62868699
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Lea Wiemann
Message 2 of 2 in “gitweb/gitk: empty merge diffs”
  1. Lea WiemannJun 29, 2008
  2. Jakub NarebskiJun 29, 2008

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.