How to determine why there are fewer files in the diff view than the commit view - Bitbucket Server

Still need help?

The Atlassian Community is here for you.

Ask the community

Purpose

Within Bitbucket Server's GUI, a pull request's "Commits" view may list more files than what is seen in the "Diff" view. This is an analysis of how/why that may occur.

Cause

This issue can occur when changes are cherry picked on source and/or target branch, rebasing or changes being merged from other branches.

The pull request diff shows the actual changes that would be applied to the target branch as a result of merging the source branch into it. This could mean that the changes for example.file already exist on master and the pull request would not actually make any changes to the file. This can be a result of cherry-picking, rebasing, or the changes being merged from other branches.

Example Scenario

  1. A file named b.rb is added committed and pushed to the master branch.
  2. A feature branch named feature/diff_tester is created.
  3. An exact copy of b.rb along with a new file, called a.rb is added, committed and pushed to the feature branch.
  4. A pull request is created to merge the feature (source) branch back into the master (target) branch.

As is shown in the image below, the "Commits" view in the pull request shows both a.rb and b.rb:

 

The "Diff" view, however, only shows the a.rb file:

This is because when the feature branch is merged into the master branch, the only difference will be the a.rb file as both master and feature branch contain the exact same b.rb file.
We can simulate what Bitbucket Server is displaying by doing the following in a local clone of the example repository with local branches for source-branch and master.

 

How to test from command line

In a working copy run the following and make note of the output – replace <source-branch> with the name of the source branch:

  1. git checkout master
  2. git merge <source-branch> --no-commit
  3. git status

 

 

The output will be similar to this:
[nhansberry:~/dev/diff_test] git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
[nhansberry:~/dev/diff_test] git merge feature/diff_tester --no-commit
Automatic merge went well; stopped before committing as requested
[nhansberry:~/dev/diff_test] git status
On branch master
Your branch is up-to-date with 'origin/master'.
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)
 
Changes to be committed:
 
 new file:   a.rb

 



Last modified on Feb 19, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.