]> source.dussan.org Git - jgit.git/commitdiff
Fix CommitCommand.setOnly() 75/48075/2
authorChristian Halstrick <christian.halstrick@sap.com>
Mon, 18 May 2015 10:48:08 +0000 (12:48 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 1 Jun 2015 08:42:21 +0000 (10:42 +0200)
When CommitCommand.setOnly(path) is used a temporary index has to be
created containing only modifications for the specified pathes. The
process to fill this temporary index was broken because filling the
index was stopped when we reached the first untracked file. Instead the
process to fill the temporary index should continue until we processed
all pathes.

Bug: 451465
Change-Id: I22af50d70bd3b81e7c056358724956122b0d158d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/CommitCommand.java

index 54fbc6671a7851526f6444eca4729a0b80a2f5dc..060a5b65c650cdc5011d3e5736f86b7184e80cb2 100644 (file)
@@ -514,6 +514,17 @@ public class CommitCommandTest extends RepositoryTestCase {
                }
        }
 
+       @Test
+       public void commitOnlyShouldHandleIgnored() throws Exception {
+               try (Git git = new Git(db)) {
+                       writeTrashFile("subdir/foo", "Hello World");
+                       writeTrashFile("subdir/bar", "Hello World");
+                       writeTrashFile(".gitignore", "bar");
+                       git.add().addFilepattern("subdir").call();
+                       git.commit().setOnly("subdir").setMessage("first commit").call();
+               }
+       }
+
        private static void addUnmergedEntry(String file, DirCacheBuilder builder) {
                DirCacheEntry stage1 = new DirCacheEntry(file, DirCacheEntry.STAGE_1);
                DirCacheEntry stage2 = new DirCacheEntry(file, DirCacheEntry.STAGE_2);
index 87efd7983530c341173e1866257308ac4f24f734..6174d48d3a65e41b2fb7a3393f07625c99007606 100644 (file)
@@ -358,7 +358,7 @@ public class CommitCommand extends GitCommand<RevCommit> {
                                        // check if entry refers to a tracked file
                                        boolean tracked = dcTree != null || hTree != null;
                                        if (!tracked)
-                                               break;
+                                               continue;
 
                                        // for an unmerged path, DirCacheBuildIterator will yield 3
                                        // entries, we only want to add one