Fix ResetCommand to default to mixed reset
ResetCommand threw an NPE if neither mode nor path was defined. Instead it should default to a mixed reset like native git does. Change-Id: I455902394f9e7b0c7afae42381f34838f7f2a138 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
74c337eadb
commit
13ffda0666
|
@ -424,6 +424,21 @@ public void testPathsResetToNonexistingRef() throws Exception {
|
|||
git.reset().setRef("doesnotexist").addPath("a.txt").call();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResetDefaultMode() throws Exception {
|
||||
git = new Git(db);
|
||||
writeTrashFile("a.txt", "content");
|
||||
git.add().addFilepattern("a.txt").call();
|
||||
writeTrashFile("a.txt", "modified");
|
||||
// should use default mode MIXED
|
||||
git.reset().call();
|
||||
|
||||
DirCache cache = db.readDirCache();
|
||||
DirCacheEntry aEntry = cache.getEntry("a.txt");
|
||||
assertNull(aEntry);
|
||||
assertEquals("modified", read("a.txt"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHardResetOnTag() throws Exception {
|
||||
setupRepository();
|
||||
|
|
|
@ -195,6 +195,9 @@ public Ref call() throws GitAPIException, CheckoutConflictException {
|
|||
result = repo.getRef(Constants.HEAD);
|
||||
}
|
||||
|
||||
if (mode == null)
|
||||
mode = ResetType.MIXED;
|
||||
|
||||
switch (mode) {
|
||||
case HARD:
|
||||
checkoutIndex(commitTree);
|
||||
|
|
Loading…
Reference in New Issue