| ASSUME_UNCHANGED));
}
@Test
public void testExecutableRetention() throws Exception {
StoredConfig config = db.getConfig();
config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
ConfigConstants.CONFIG_KEY_FILEMODE, true);
config.save();
FS executableFs = new FS() {
public boolean supportsExecute() {
return true;
}
public boolean setExecute(File f, boolean canExec) {
return true;
}
public ProcessBuilder runInShell(String cmd, String[] args) {
return null;
}
public boolean retryFailedLockFileCommit() {
return false;
}
public FS newInstance() {
return this;
}
protected File discoverGitPrefix() {
return null;
}
public boolean canExecute(File f) {
return true;
}
@Override
public boolean isCaseSensitive() {
return false;
}
};
Git git = Git.open(db.getDirectory(), executableFs);
String path = "a.txt";
writeTrashFile(path, "content");
git.add().addFilepattern(path).call();
RevCommit commit1 = git.commit().setMessage("commit").call();
TreeWalk walk = TreeWalk.forPath(db, path, commit1.getTree());
assertNotNull(walk);
assertEquals(FileMode.EXECUTABLE_FILE, walk.getFileMode(0));
FS nonExecutableFs = new FS() {
public boolean supportsExecute() {
return false;
}
public boolean setExecute(File f, boolean canExec) {
return false;
}
public ProcessBuilder runInShell(String cmd, String[] args) {
return null;
}
public boolean retryFailedLockFileCommit() {
return false;
}
public FS newInstance() {
return this;
}
protected File discoverGitPrefix() {
return null;
}
public boolean canExecute(File f) {
return false;
}
@Override
public boolean isCaseSensitive() {
return false;
}
};
config = db.getConfig();
config.setBoolean(ConfigConstants.CONFIG_CORE_SECTION, null,
ConfigConstants.CONFIG_KEY_FILEMODE, false);
config.save();
Git git2 = Git.open(db.getDirectory(), nonExecutableFs);
writeTrashFile(path, "content2");
git2.add().addFilepattern(path).call();
RevCommit commit2 = git2.commit().setMessage("commit2").call();