mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 07:49:11 +03:00
fix handling of empty .gitignore files
Summary: Empty .gitignore files should be processed normally, and treated as no new ignore rules. The logic in D6659654 had accidentally introduced a bug where we would completely skip processing any directories that contained empty .gitignore files. Reviewed By: wez Differential Revision: D7261276 fbshipit-source-id: 033e199f15d7763bff5f9a080a226c50e481aa9d
This commit is contained in:
parent
d220296a33
commit
b37dfd0707
@ -1868,16 +1868,13 @@ Future<Unit> TreeInode::loadGitIgnoreThenDiff(
|
||||
tree,
|
||||
parentIgnore,
|
||||
isIgnored](std::string&& ignoreFileContents) mutable {
|
||||
if (!ignoreFileContents.empty()) {
|
||||
return self->computeDiff(
|
||||
self->contents_.wlock(),
|
||||
context,
|
||||
currentPath,
|
||||
std::move(tree),
|
||||
make_unique<GitIgnoreStack>(parentIgnore, ignoreFileContents),
|
||||
isIgnored);
|
||||
}
|
||||
return makeFuture();
|
||||
return self->computeDiff(
|
||||
self->contents_.wlock(),
|
||||
context,
|
||||
currentPath,
|
||||
std::move(tree),
|
||||
make_unique<GitIgnoreStack>(parentIgnore, ignoreFileContents),
|
||||
isIgnored);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1010,6 +1010,25 @@ TEST(DiffTest, ignoreFileIsDirectory) {
|
||||
EXPECT_THAT(result.getModified(), UnorderedElementsAre());
|
||||
}
|
||||
|
||||
TEST(DiffTest, emptyIgnoreFile) {
|
||||
DiffTest test({
|
||||
{"src/foo.txt", "test\n"},
|
||||
{"src/subdir/bar.txt", "test\n"},
|
||||
{"src/.gitignore", ""},
|
||||
});
|
||||
|
||||
test.getMount().addFile("src/subdir/new.txt", "new\n");
|
||||
|
||||
auto result = test.diff();
|
||||
EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
|
||||
EXPECT_THAT(
|
||||
result.getUntracked(),
|
||||
UnorderedElementsAre(RelativePath{"src/subdir/new.txt"}));
|
||||
EXPECT_THAT(result.getIgnored(), UnorderedElementsAre());
|
||||
EXPECT_THAT(result.getRemoved(), UnorderedElementsAre());
|
||||
EXPECT_THAT(result.getModified(), UnorderedElementsAre());
|
||||
}
|
||||
|
||||
// Files under the .hg directory should never be reported in diff results
|
||||
TEST(DiffTest, ignoreHidden) {
|
||||
DiffTest test({
|
||||
|
Loading…
Reference in New Issue
Block a user