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

Bug 363405

Summary: untracking a file present in HEAD can't be committed using commit dialog
Product: [Technology] EGit Reporter: Matthias Sohn <matthias.sohn>
Component: UIAssignee: Matthias Sohn <matthias.sohn>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: ed, joshua.lester, kane.mx, kane.zhu, mn, zanetu
Version: 1.2   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Matthias Sohn CLA 2011-11-09 18:24:48 EST
- untrack a file which is present in HEAD
- commit this change using the commit dialog
- this fails with error message claiming that commit is empty

org.eclipse.team.core.TeamException: An internal error occurred
at org.eclipse.egit.core.op.CommitOperation.commit(CommitOperation.java:282)
at org.eclipse.egit.core.op.CommitOperation$1.run(CommitOperation.java:207)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2326)
at org.eclipse.egit.core.op.CommitOperation.execute(CommitOperation.java:217)
at org.eclipse.egit.ui.internal.commit.CommitUI$2.run(CommitUI.java:217)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: No changes
at org.eclipse.jgit.api.CommitCommand.createTemporaryIndex(CommitCommand.java:406)
at org.eclipse.jgit.api.CommitCommand.call(CommitCommand.java:192)
at org.eclipse.egit.core.op.CommitOperation.commit(CommitOperation.java:271)
... 6 more
Comment 1 Matthias Sohn CLA 2011-11-09 18:29:01 EST
first round of debugging revealed that
- untrack correctly removes the file to be untracked from the index
- but CommitOperation.addUntracked() adds it again to the index since it doesn't check if the file is present in HEAD and hence erroneously concludes that the untracked file should be staged
- maybe we should pass the IndexDiff into the CommitOperation to provide the more detailed information needed there
Comment 2 Matthias Sohn CLA 2011-11-10 18:56:26 EST
proposed egit fix 
http://egit.eclipse.org/r/#change,4598 
and jgit fix 
http://egit.eclipse.org/r/#change,4597
for review
Comment 3 Mykola Nikishov CLA 2012-03-03 11:12:54 EST
[Batch change] Remove passed Target Milestones

If anyone on CC list is going to fix/implement this, feel free to assign a new, post-1.3/2.0, target milestone.
Comment 4 Matthias Sohn CLA 2013-04-29 18:51:44 EDT
This is hard to fix since the commit dialog uses jgit's equivalent of commit -o and according to the git reference documentation "commit -o" explicitly ignores the index state so we need a different way to commit untracked files using the commit dialog.

I'd rather try to get rid of the non-gitish commit dialog instead of fixing this.
I am only using the staging view to create commits these days.

Hence closing this bug as won't fix, feel free to reopen if you intend to spend the effort to rewrite the commit dialog.
Comment 5 Matthias Sohn CLA 2016-04-12 19:57:25 EDT
since 4.3 the "Commit..." action by default opens the Staging View and no longer the commit dialog. The commit dialog can still be reenabled by unsetting the preference
"Team > Git > Committing > Use Staging View for committing instead of Commit Dialog"