eden/fs/inodes/test/DiffTest.cpp
// Test with a .gitignore file in the top-level directory
Test with a .gitignore file in the top-level directory
Test with a . gitignore file in the top - level directory
TEST(DiffTest, ignoreToplevelOnly) {
  DiffTest test({
      {".gitignore", "/1.txt\nignore.txt\njunk/\n!important.txt\n"},
      {"a/b.txt", "test\n"},
      {"src/x.txt", "test\n"},
      {"src/y.txt", "test\n"},
      {"src/z.txt", "test\n"},
      {"src/foo/bar.txt", "test\n"},
  });
  test.getMount().addFile("1.txt", "new\n");
  test.getMount().addFile("ignore.txt", "new\n");
  test.getMount().addFile("src/1.txt", "new\n");
  test.getMount().addFile("src/foo/ignore.txt", "new\n");
  test.getMount().mkdir("src/foo/abc");
  test.getMount().mkdir("src/foo/abc/xyz");
  test.getMount().addFile("src/foo/abc/xyz/ignore.txt", "new\n");
  test.getMount().mkdir("junk");
  test.getMount().addFile("junk/stuff.txt", "new\n");
  test.getMount().addFile("junk/important.txt", "new\n");
  auto result = test.diff();
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(), UnorderedElementsAre(RelativePath{"src/1.txt"}));
  EXPECT_THAT(result.getIgnored(), UnorderedElementsAre());
  EXPECT_THAT(result.getRemoved(), UnorderedElementsAre());
  EXPECT_THAT(result.getModified(), UnorderedElementsAre());
  result = test.diff(true);
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(), UnorderedElementsAre(RelativePath{"src/1.txt"}));
  EXPECT_THAT(
      result.getIgnored(),
      UnorderedElementsAre(
          RelativePath{"1.txt"},
          RelativePath{"ignore.txt"},
          RelativePath{"junk/stuff.txt"},
          RelativePath{"junk/important.txt"},
          RelativePath{"src/foo/ignore.txt"},
          RelativePath{"src/foo/abc/xyz/ignore.txt"}));
  EXPECT_THAT(result.getRemoved(), UnorderedElementsAre());
  EXPECT_THAT(result.getModified(), UnorderedElementsAre());
}
TEST ( DiffTest , ignoreToplevelOnly ) { DiffTest test ( { { " " , " \n \n \n \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , } ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . mkdir ( " " ) ; test . getMount ( ) . mkdir ( " " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . mkdir ( " " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; auto result = test . diff ( ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getRemoved ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getModified ( ) , UnorderedElementsAre ( ) ) ; result = test . diff ( true ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getRemoved ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getModified ( ) , UnorderedElementsAre ( ) ) ; }
Test with a .gitignore file in the top-level directory
Test with a . gitignore file in the top - level directory
// Add some untracked files, some of which match the ignore patterns // Even though important.txt matches an include rule, the fact that it // is inside an excluded directory takes precedence.