]> source.dussan.org Git - jgit.git/commitdiff
Hard reset should not report conflict on untracked file 53/2353/1
authorMatthias Sohn <matthias.sohn@sap.com>
Thu, 27 Jan 2011 16:20:04 +0000 (17:20 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Thu, 27 Jan 2011 16:20:04 +0000 (17:20 +0100)
This problem surfaced since EGit Core ResetOperationTest is failing
since change I26806d21. JGit detected checkout conflict for untracked
files which never were tracked by the repository.

"git reset --hard" in c git also doesn't remove such untracked files.

Change-Id: Icc8e1c548ecf6ed48bd2979c81eeb6f578d347bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java

index 1b4a9ff2311816881f036f344c9b7f2bf0479f3d..90a3f94167486e821d565f16ee27e20a6ca46f5e 100644 (file)
@@ -128,11 +128,14 @@ public class DirCacheCheckoutTest extends ReadTreeTest {
                RevCommit topic = git.commit().setMessage("topic-1").call();
                assertIndex(mkmap("f", "f()\nside", "G/i", "i()"));
 
+               writeTrashFile("untracked", "untracked");
+
                resetHard(master);
                assertIndex(mkmap("f", "f()\nmaster", "D/g", "g()\ng2()", "E/h", "h()"));
                resetHard(topic);
                assertIndex(mkmap("f", "f()\nside", "G/i", "i()"));
-               assertWorkDir(mkmap("f", "f()\nside", "G/i", "i()"));
+               assertWorkDir(mkmap("f", "f()\nside", "G/i", "i()", "untracked",
+                               "untracked"));
 
                assertEquals(MergeStatus.CONFLICTING, git.merge().include(master)
                                .call().getMergeStatus());
@@ -143,7 +146,7 @@ public class DirCacheCheckoutTest extends ReadTreeTest {
                resetHard(master);
                assertIndex(mkmap("f", "f()\nmaster", "D/g", "g()\ng2()", "E/h", "h()"));
                assertWorkDir(mkmap("f", "f()\nmaster", "D/g", "g()\ng2()", "E/h",
-                               "h()"));
+                               "h()", "untracked", "untracked"));
        }
 
        private DirCacheCheckout resetHard(RevCommit commit)
index 9b0bc7b01cb5a6c4115cdb26e6f9f9b5b5ea268b..25acf16a35cc17bbfac06e5f36acabacca191b68 100644 (file)
@@ -351,12 +351,8 @@ public class DirCacheCheckout {
                                                remove(i.getEntryPathString());
                                                conflicts.remove(i.getEntryPathString());
                                        } else {
-                                               // We are about to remove an untracked file. Check that
-                                               // it is ignored - otherwise that's an conflict
-                                               if (!f.isEntryIgnored())
-                                                       conflicts.add(walk.getPathString());
-                                               else
-                                                       remove(f.getEntryPathString());
+                                               // untracked file, neither contained in tree to merge
+                                               // nor in index
                                        }
                                }
                        } else {