threads / discuss / 14209

gitweb/gitk: empty merge diffs

Subject: gitweb/gitk: empty merge diffs

## tl;dr

2 messages between Jun 29, 2008 and Jun 29, 2008.

replies: 1people: 2as markdown or json

Lea Wiemann· Jun 29, 2008, 15:57 UTC · lore

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).

Gitk doesn't seem to allow me to view the merge diff at all.

Gitweb only shows "Trivial merge" in the commitdiff view. In the commit view, I can get the merge diff I want by clicking the "diff" link behind the first parent.

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.

===== 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: =====

rm -rf test-repo.tmp mkdir test-repo.tmp cd test-repo.tmp

git init

echo File 1 > file1 echo File 2 > file2 git add file1 file2 git commit -m 'initial commit'

git branch mybranch

echo Addition to file 1 >> file1 git commit -a -m 'change file1 on master' echo Another addition to file 1 >> file1 git commit -a -m 'change file1 on master'

git checkout mybranch echo Addition to file 2 >> file2 git commit -a -m 'change file2 on mybranch' echo Another addition to file 2 >> file2 git commit -a -m 'change file2 on mybranch'

git checkout master git merge 'merge mybranch into master' HEAD mybranch

Jakub Narebski· Jun 29, 2008, 17:21 UTC · re: Lea Wiemann · lore

Re: gitweb/gitk: empty merge diffs

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

← back to recent threads