Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 381701

Summary: Stashed files not shown in Commit Viewer
Product: [Technology] EGit Reporter: Stefan Lay <stefan.lay>
Component: UIAssignee: Project Inbox <egit.ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: frank.jakop, nobody, robin, to.pfeifer
Version: unspecifiedKeywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 420936    

Description Stefan Lay CLA 2012-06-05 09:10:13 EDT
Sometimes the commit viewer is empty when it is opened for "Stashed Changes".

This can be reproduced with the following repo:

https://bugs.eclipse.org/bugs/attachment.cgi?id=216830
Comment 1 Frank Jakop CLA 2012-12-04 11:37:54 EST
I can reproduce this bug constantly with EGit 2.1.0.201209190230-r when I stash staged changes. Double-clicking the stash shows the message but no files/branches.

The stash can be applied though.

This is *very* confusing for our developers.
Comment 2 Tobias Pfeifer CLA 2013-01-31 03:46:38 EST
jgit seems to cause this bug:
-org.eclipse.egit.ui.internal.commit.RepositoryCommit:getDiffs() returns an empty array. This is due to line 156 where FileDiff.compute() returns an empty array.
-at FileDiff.compute() on line 102 the method matchAnyParent() returns false whereas I think this method should return true.
I'll try to find a fix for that (though I'm not familiar with jgit's internals yet)
Comment 3 Tobias Pfeifer CLA 2013-01-31 11:12:39 EST
A stash always consists of two commits. The first to record changes that were made to the working directory, the second to record the state of the index.
See discussion section at http://www.kernel.org/pub/software/scm/git/docs/git-stash.html

Git has to restore both your index and your working directory when applying a stashed commit and thus it needs to distinguish between working directory and index.

Let me give a more detailed explanation what stashing can result in:
Case 1:
You edit a file in your repository and save it. Then the changes are considered to be on your working directory (the working directory then differs from your HEAD). The changed file is listed in "Unstaged Changes" in the git staging view. Stashing now results in a commit that records your working directory (containing the changed file) and an empty parent commit that records your index.

Case 2:
You edit and save a file and then add the file to the index (by either right-click on the file->team->add to index or move the file from "Unstaged Changes" to "Staged Changes" in the git staging view). Then the changes are considered to be on your index (note: the changes still remain on your working directory). Stashing now results in an empty commit that records your working directory (empty because your working directory doesn't differ from your files on the index) and a parent commit that records your index (containing the changed files).

Case 3:
Just like in case 2 you edit, save and add a file to the index. But before stashing you make further changes on your working directory. Stashing then results in a commit containing the recent changes and a parent commit that contains the changes that were added to the index.

No this is what EGit does:
When double-clicking on a stash in egit's repository view, the commit viewer that opens only shows the commit that records the changes in the working directory. So if you haven't had any changes in your working directory when you were stashing, the diff viewer will not show any touched files (even if you've stashed changes made to the index). In fact it would be incorrect to show changes made to the index in this view (since these changes are not part of the commit that is displayed).

In my opinion it's misleading to just show the commit that records the state of the working directory when double-clicking on a stash in the repository view. I would expect to either see both commits or to choose what to display.

As a workaround you can display the stashed changes made to the index by double-clicking on the stash (this opens the commit viewer showing stashed changes to the working directory) and then clicking on the second parent id (at the top most right corner). This leads to the stashed changes made to the index (note that the commit id changes but neither the message nor author and time stamp changes, indicating that both commits belongs to the stash)
Comment 4 Robin Stocker CLA 2014-04-25 14:37:43 EDT
*** Bug 433466 has been marked as a duplicate of this bug. ***
Comment 5 Robin Stocker CLA 2014-06-10 09:07:13 EDT
There's been some work in bug 436224, marking this as a duplicate.

*** This bug has been marked as a duplicate of bug 436224 ***