fetchGit/fetchMercurial: Filter out directories with untracked files
This commit is contained in:
		
							parent
							
								
									4dee01da7c
								
							
						
					
					
						commit
						ee6ac38848
					
				
					 4 changed files with 28 additions and 14 deletions
				
			
		|  | @ -47,11 +47,15 @@ HgInfo exportMercurial(ref<Store> store, const std::string & uri, | |||
| 
 | ||||
|             PathFilter filter = [&](const Path & p) -> bool { | ||||
|                 assert(hasPrefix(p, uri)); | ||||
|                 auto st = lstat(p); | ||||
|                 std::string file(p, uri.size() + 1); | ||||
|                 if (file == ".hg") return false; | ||||
|                 // FIXME: filter out directories with no tracked files.
 | ||||
|                 if (S_ISDIR(st.st_mode)) return true; | ||||
| 
 | ||||
|                 auto st = lstat(p); | ||||
| 
 | ||||
|                 if (S_ISDIR(st.st_mode)) { | ||||
|                     auto i = files.lower_bound(file); | ||||
|                     return i != files.end() && hasPrefix(*i, file); | ||||
|                 } | ||||
| 
 | ||||
|                 return files.count(file); | ||||
|             }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -44,11 +44,15 @@ GitInfo exportGit(ref<Store> store, const std::string & uri, | |||
| 
 | ||||
|             PathFilter filter = [&](const Path & p) -> bool { | ||||
|                 assert(hasPrefix(p, uri)); | ||||
|                 auto st = lstat(p); | ||||
|                 std::string file(p, uri.size() + 1); | ||||
|                 if (file == ".git") return false; | ||||
|                 // FIXME: filter out directories with no tracked files.
 | ||||
|                 if (S_ISDIR(st.st_mode)) return true; | ||||
| 
 | ||||
|                 auto st = lstat(p); | ||||
| 
 | ||||
|                 if (S_ISDIR(st.st_mode)) { | ||||
|                     auto i = files.lower_bound(file); | ||||
|                     return i != files.end() && hasPrefix(*i, file); | ||||
|                 } | ||||
| 
 | ||||
|                 return files.count(file); | ||||
|             }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue