diff options
author | Robin Stocker <robin@nibor.org> | 2012-08-16 16:06:58 +0200 |
---|---|---|
committer | Robin Stocker <robin@nibor.org> | 2012-09-01 13:29:00 +0200 |
commit | 51c20b27acdef57dcb1d79ac995cd49f2e9c2f91 (patch) | |
tree | 6345c54adcd3fa5074dba16f445cb33bf3e8c562 /org.eclipse.jgit | |
parent | 0a9e010e14c96d97e902bf3c46ac1487ed6fbc18 (diff) | |
download | jgit-51c20b27acdef57dcb1d79ac995cd49f2e9c2f91.tar.gz jgit-51c20b27acdef57dcb1d79ac995cd49f2e9c2f91.zip |
DirCacheCheckout: Fix handling of files not in index
When a file is not in the index and neither contents nor mode differ
between "head" and "merge", the index state should be kept. If they
differ, a checkout conflict should occur. This is described in Git's
git-read-tree.txt.
JGit used to replace the index state with "merge" in both of the above
cases.
A confusing effect of this was that when one removed a file and then did
a rebase, the file silently reappeared again.
The changes to dir/file conflict handling are a consequence of this
change, as the index handling change made tests in DirCacheCheckoutTest
break. I compared these cases to C Git and the new behavior there also
matches what C Git does.
Bug: 387390
Change-Id: I5beb781f12172a68f98c67d4c8029eb51ceae62d
Signed-off-by: Robin Stocker <robin@nibor.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java index d43fef8477..9780993659 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java @@ -552,8 +552,8 @@ public class DirCacheCheckout { * ------------------------------------------------------------------ * 1 D D F Y N Y N Update * 2 D D F N N Y N Conflict - * 3 D F D Y N N Update - * 4 D F D N N N Update + * 3 D F D Y N N Keep + * 4 D F D N N N Conflict * 5 D F F Y N N Y Keep * 6 D F F N N N Y Keep * 7 F D F Y Y N N Update @@ -615,10 +615,7 @@ public class DirCacheCheckout { break; case 0xDFD: // 3 4 - // CAUTION: I put it into removed instead of updated, because - // that's what our tests expect - // updated.put(name, mId); - remove(name); + keep(dce); break; case 0xF0D: // 18 remove(name); @@ -703,12 +700,13 @@ public class DirCacheCheckout { /** * <pre> - * I (index) H M Result - * ------------------------------------------------------- - * 0 nothing nothing nothing (does not happen) - * 1 nothing nothing exists use M - * 2 nothing exists nothing remove path from index - * 3 nothing exists exists use M + * I (index) H M H==M Result + * ------------------------------------------- + * 0 nothing nothing nothing (does not happen) + * 1 nothing nothing exists use M + * 2 nothing exists nothing remove path from index + * 3 nothing exists exists yes keep index + * nothing exists exists no fail * </pre> */ @@ -716,8 +714,12 @@ public class DirCacheCheckout { update(name, mId, mMode); // 1 else if (m == null) remove(name); // 2 - else - update(name, mId, mMode); // 3 + else { // 3 + if (equalIdAndMode(hId, hMode, mId, mMode)) + keep(dce); + else + conflict(name, dce, h, m); + } } else { if (h == null) { /** |