Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 379004 - false dirty working tree exception
Summary: false dirty working tree exception
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: All Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Kevin Sawicki CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-09 11:30 EDT by Mac Trzcinski CLA
Modified: 2012-06-06 13:23 EDT (History)
2 users (show)

See Also:


Attachments
commit graph screenshot (19.32 KB, image/png)
2012-05-11 17:46 EDT, Kevin Sawicki CLA
no flags Details
win 7 commit tree screenshot (5.04 KB, image/png)
2012-05-11 17:51 EDT, Mac Trzcinski CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mac Trzcinski CLA 2012-05-09 11:30:44 EDT
File mode check to determine 'dirty working tree' while merging fails even if the working tree is clean (verified with 'C' git implementation).

Proposed temporary fix:
Switch to suppress this check for API users when they are sure that they are not manipulating the working tree.

Code:
isWorktreeDirty() in org.eclipse.jgit.merge.ResolveMerger.java

Marking as major severity because might prevent users from merging.
Comment 1 Kevin Sawicki CLA 2012-05-09 13:46:15 EDT
Hi, can you provide the steps to reproduce this behavior?
Comment 2 Mac Trzcinski CLA 2012-05-09 14:34:05 EDT
My workflow is:
1) fetch remote branch to FETCH_HEAD
2) create temporary branch starting at FETCH_HEAD
3) fetch remote ref to FETCH_HEAD
4) cherry-pick last commit from FETCH_HEAD
this is were the cherry picking fails due to failing merge and gives DIRTY_WORKTREE as a cause


line 574 in ResolveMerger.java:
final boolean isDirty = nonTree(modeF)&& !(tw.idEqual(T_FILE, T_OURS) && modeO == modeF);

the three booleans that isDirty is evaluated from are true, false, false respectively
Comment 3 Mac Trzcinski CLA 2012-05-09 14:41:53 EDT
Both JGit Status (returned by StatusCommand) and 'C' git show clean working tree at this point. I have tried doing a mock commit just before cherry-picking and it didn't work either.
Comment 4 Kevin Sawicki CLA 2012-05-09 14:43:19 EDT
Did you happen to record the raw modes being reported for both files?
Comment 5 Mac Trzcinski CLA 2012-05-09 14:48:38 EDT
Took a sec to retrieve, here you go:

modeF = 33188
modeO = 33261
Comment 6 Chris Aniszczyk CLA 2012-05-09 15:55:12 EDT
You can also try to write a JUnit test that would help detect the problem.
Comment 7 Kevin Sawicki CLA 2012-05-09 17:06:21 EDT
For the failing commit, do you know which file in the commit (if there is more than one) is causing this?

Is it just a regular file? that exists in the current branch but is just being updated in the commit being cherry picked?

Just trying to find a reduction case to work from.
Comment 8 Mac Trzcinski CLA 2012-05-09 17:10:06 EDT
Yes, it's a regular text file (.py in my case) that is already in the branch and get's updated in the cherry-picked commit (insertion).
Comment 9 Kevin Sawicki CLA 2012-05-09 17:15:58 EDT
Have you tried other cherry picks that have completed normally or are all failing?
Comment 10 Mac Trzcinski CLA 2012-05-09 17:19:57 EDT
It's my first test case and I stopped there since the error seemed to have nothing to do with the file. I am not modifying it and 'C' git cherry-picks fine if I stop the execution at this point.
Comment 11 Kevin Sawicki CLA 2012-05-09 17:21:34 EDT
Could the file be changing from regular to executable in that commit where the cherry pick is failing?
Comment 12 Mac Trzcinski CLA 2012-05-09 17:36:51 EDT
Doesn't look like it is changing (at least not when JGit is used to reproduce with exception ignored). -rwxr-xr-x before and after
Comment 13 Kevin Sawicki CLA 2012-05-09 19:09:30 EDT
What version of JGit are you using?
Comment 14 Mac Trzcinski CLA 2012-05-10 11:06:54 EDT
I am now using the repository source code but I had the same problem when using the latest release.
Comment 15 Kevin Sawicki CLA 2012-05-10 12:19:32 EDT
Would it be possible to share the repository you are seeing the issue on?

That would make is much easier to debug.
Comment 16 Mac Trzcinski CLA 2012-05-10 13:25:14 EDT
Unfortunately no. There's nothing special about it though apart from the fact that it is ssh Gerrit based so ref is a Gerrit change.
Comment 17 Mac Trzcinski CLA 2012-05-11 13:10:03 EDT
Kevin, can you tell what the file modes that I have pulled tell you?
Comment 18 Kevin Sawicki CLA 2012-05-11 13:13:48 EDT
> modeF = 33188
> modeO = 33261

33188 (modeF) decodes to octal 100644 which means regular file
33261 (modeO) decodes to octal 100755 which means executable file
Comment 19 Mac Trzcinski CLA 2012-05-11 14:24:10 EDT
> Doesn't look like it is changing (at least not when JGit is used to reproduce
> with exception ignored). -rwxr-xr-x before and after

I need to take that back. I had checked it with msysgit which is bad at figuring out file modes.
Comment 20 Mac Trzcinski CLA 2012-05-11 16:24:27 EDT
Okay, I have some more information. The file permissions are not changed in the commit (X) that I cherry-pick. However, they are changing between parent of this commit and current head on the branch. Diff between A and D reads:

diff --git a/gobuild/gobuild.py b/gobuild/gobuild.py
index 8f487f4..2e9acfb 100755
--- a/gobuild/gobuild.py
+++ b/gobuild/gobuild.py


Before cherry-pick:
A---B---C---D
 \
  X

After cherry-pick:
A---B---C---D
             \
              X

Is it desirable to block cherry-picking changes from a file with different permissions? 'C' git seems to allow that.
Comment 21 Kevin Sawicki CLA 2012-05-11 17:36:14 EDT
Just to confirm, in your example, you are cherry picking commit X whose current parent is A and is being cherry picked onto D, and in commit B, C, or D a file is changed to executable that is also changed in X?
Comment 22 Mac Trzcinski CLA 2012-05-11 17:44:15 EDT
(In reply to comment #21)
> Just to confirm, in your example, you are cherry picking commit X whose current
> parent is A and is being cherry picked onto D, and in commit B, C, or D a file
> is changed to executable that is also changed in X?

Yes, I thought that's what I had written :) B, C and D are just symbolic in the example but the file has changed into executable somewhere on the way.
Comment 23 Kevin Sawicki CLA 2012-05-11 17:46:51 EDT
Created attachment 215509 [details]
commit graph screenshot

Yeah, it looked like the X commit was hanging off of C which I didn't completely get.
Comment 24 Mac Trzcinski CLA 2012-05-11 17:51:47 EDT
Created attachment 215510 [details]
win 7 commit tree screenshot
Comment 25 Mac Trzcinski CLA 2012-05-11 17:52:47 EDT
(In reply to comment #24)
> Created attachment 215510 [details]
> win 7 commit tree screenshot

Sorry, it's mono-spaced for me so I assumed it's like that for everyone.
Comment 26 Kevin Sawicki CLA 2012-05-12 15:23:55 EDT
Proposed fix pushed to https://git.eclipse.org/r/5961
Comment 27 Kevin Sawicki CLA 2012-06-06 13:23:06 EDT
This has been merged into stable-2.0 in commit 59a98b49d2bf1e4514967dfa0acbceea6b37dbd4