|
|
@ -817,40 +817,35 @@ public class RecursiveMergerTest extends RepositoryTestCase { |
|
|
|
|
|
|
|
|
|
|
|
void modifyWorktree(WorktreeState worktreeState, String path, String other) |
|
|
|
void modifyWorktree(WorktreeState worktreeState, String path, String other) |
|
|
|
throws Exception { |
|
|
|
throws Exception { |
|
|
|
FileOutputStream fos = null; |
|
|
|
switch (worktreeState) { |
|
|
|
ObjectId bloblId; |
|
|
|
case Missing: |
|
|
|
|
|
|
|
new File(db.getWorkTree(), path).delete(); |
|
|
|
try { |
|
|
|
break; |
|
|
|
switch (worktreeState) { |
|
|
|
case DifferentFromHeadAndOther: |
|
|
|
case Missing: |
|
|
|
write(new File(db.getWorkTree(), path), |
|
|
|
new File(db.getWorkTree(), path).delete(); |
|
|
|
Integer.toString(counter++)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case DifferentFromHeadAndOther: |
|
|
|
case SameAsHead: |
|
|
|
write(new File(db.getWorkTree(), path), |
|
|
|
try (FileOutputStream fos = new FileOutputStream( |
|
|
|
Integer.toString(counter++)); |
|
|
|
new File(db.getWorkTree(), path))) { |
|
|
|
break; |
|
|
|
db.newObjectReader().open(contentId(Constants.HEAD, path)) |
|
|
|
case SameAsHead: |
|
|
|
.copyTo(fos); |
|
|
|
bloblId = contentId(Constants.HEAD, path); |
|
|
|
|
|
|
|
fos = new FileOutputStream(new File(db.getWorkTree(), path)); |
|
|
|
|
|
|
|
db.newObjectReader().open(bloblId).copyTo(fos); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case SameAsOther: |
|
|
|
|
|
|
|
bloblId = contentId(other, path); |
|
|
|
|
|
|
|
fos = new FileOutputStream(new File(db.getWorkTree(), path)); |
|
|
|
|
|
|
|
db.newObjectReader().open(bloblId).copyTo(fos); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case Bare: |
|
|
|
|
|
|
|
if (db.isBare()) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
File workTreeFile = db.getWorkTree(); |
|
|
|
|
|
|
|
db.getConfig().setBoolean("core", null, "bare", true); |
|
|
|
|
|
|
|
db.getDirectory().renameTo(new File(workTreeFile, "test.git")); |
|
|
|
|
|
|
|
db = new FileRepository(new File(workTreeFile, "test.git")); |
|
|
|
|
|
|
|
db_t = new TestRepository<>(db); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
break; |
|
|
|
if (fos != null) |
|
|
|
case SameAsOther: |
|
|
|
fos.close(); |
|
|
|
try (FileOutputStream fos = new FileOutputStream( |
|
|
|
|
|
|
|
new File(db.getWorkTree(), path))) { |
|
|
|
|
|
|
|
db.newObjectReader().open(contentId(other, path)).copyTo(fos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case Bare: |
|
|
|
|
|
|
|
if (db.isBare()) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
File workTreeFile = db.getWorkTree(); |
|
|
|
|
|
|
|
db.getConfig().setBoolean("core", null, "bare", true); |
|
|
|
|
|
|
|
db.getDirectory().renameTo(new File(workTreeFile, "test.git")); |
|
|
|
|
|
|
|
db = new FileRepository(new File(workTreeFile, "test.git")); |
|
|
|
|
|
|
|
db_t = new TestRepository<>(db); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|