瀏覽代碼

Merge 6b4de1a460 into 1e391d47ba

pull/37/merge
qxo 2 年之前
父節點
當前提交
7d7650fd52
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 27 行新增4 行删除
  1. 27
    4
      org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java

+ 27
- 4
org.eclipse.jgit/src/org/eclipse/jgit/api/CleanCommand.java 查看文件

@@ -92,12 +92,12 @@ public class CleanCommand extends GitCommand<Set<String>> {
status.getIgnoredNotInIndex(), false);

for (String file : notIgnoredFiles)
if (paths.isEmpty() || paths.contains(file)) {
if (paths.isEmpty() || paths.contains(file) || isFileInPaths(file) ) {
files = cleanPath(file, files);
}
for (String dir : notIgnoredDirs)
if (paths.isEmpty() || paths.contains(dir)) {
if (paths.isEmpty() || paths.contains(dir) || isFileInPaths(dir) ) {
files = cleanPath(dir, files);
}
} catch (IOException e) {
@@ -109,7 +109,30 @@ public class CleanCommand extends GitCommand<Set<String>> {
}
return files;
}

protected boolean isFileInPaths(final String file) {
if(paths.isEmpty()){
return false;
}
String path=file;
final Set<String> dirs = new HashSet<String>();
while(true){
int idx = path.lastIndexOf("/");
if( idx> 0 ){
path=file.substring(0,idx);
if(paths.contains(path)){
paths.addAll(dirs);
return true;
}
dirs.add(path);
}else{
break;
}
return idx == -1 ? false : ;
}
return false;
}
/**
* When dryRun is false, deletes the specified path from disk. If dryRun
* is true, no paths are actually deleted. In both cases, the paths that

Loading…
取消
儲存