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, ignoreInSubdirectories) {
  DiffTest test({
      {".gitignore", "**/foo/bar.txt\n"},
      {"foo/.gitignore", "stuff\ntest\nwhatever\n"},
      {"foo/foo/.gitignore", "!/bar.txt\ntest\n"},
      {"abc/def/.gitignore", "*.log\n"},
      {"abc/def/other.txt", "test\n"},
      {"a/.gitignore", "b/c/d.txt\n"},
      {"a/b/c/x.txt", "test\n"},
      {"b/c/x.txt", "test\n"},
  });
  test.getMount().addFile("foo/bar.txt", "new\n");
  test.getMount().addFile("foo/foo/bar.txt", "new\n");
  test.getMount().mkdir("foo/test");
  test.getMount().addFile("foo/test/1.txt", "new\n");
  test.getMount().addFile("foo/test/2.txt", "new\n");
  test.getMount().mkdir("foo/test/3");
  test.getMount().addFile("foo/test/3/4.txt", "new\n");
  test.getMount().addFile("foo/foo/test", "new\n");
  test.getMount().addFile("test", "test\n");
  test.getMount().addFile("abc/def/test", "test\n");
  test.getMount().addFile("abc/def/test.log", "test\n");
  test.getMount().addFile("abc/def/another.log", "test\n");
  test.getMount().addFile("abc/test.log", "test\n");
  test.getMount().mkdir("abc/foo");
  test.getMount().addFile("abc/foo/bar.txt", "test\n");
  test.getMount().mkdir("other");
  test.getMount().addFile("other/bar.txt", "test\n");
  test.getMount().addFile("a/b/c/d.txt", "test\n");
  test.getMount().addFile("b/c/d.txt", "test\n");
  auto result = test.diff();
  EXPECT_THAT(result.getErrors(), UnorderedElementsAre());
  EXPECT_THAT(
      result.getUntracked(),
      UnorderedElementsAre(
          RelativePath{"abc/test.log"},
          RelativePath{"abc/def/test"},
          RelativePath{"b/c/d.txt"},
          RelativePath{"foo/foo/bar.txt"},
          RelativePath{"other/bar.txt"},
          RelativePath{"test"}));
  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{"abc/test.log"},
          RelativePath{"abc/def/test"},
          RelativePath{"b/c/d.txt"},
          RelativePath{"foo/foo/bar.txt"},
          RelativePath{"other/bar.txt"},
          RelativePath{"test"}));
  EXPECT_THAT(
      result.getIgnored(),
      UnorderedElementsAre(
          RelativePath{"a/b/c/d.txt"},
          RelativePath{"abc/def/test.log"},
          RelativePath{"abc/def/another.log"},
          RelativePath{"abc/foo/bar.txt"},
          RelativePath{"foo/bar.txt"},
          RelativePath{"foo/test/1.txt"},
          RelativePath{"foo/test/2.txt"},
          RelativePath{"foo/test/3/4.txt"},
          RelativePath{"foo/foo/test"}));
  EXPECT_THAT(result.getRemoved(), UnorderedElementsAre());
  EXPECT_THAT(result.getModified(), UnorderedElementsAre());
}
TEST ( DiffTest , ignoreInSubdirectories ) { DiffTest test ( { { " " , " \n " } , { " " , " \n \n \n " } , { " " , " \n \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , { " " , " \n " } , } ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . mkdir ( " " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . mkdir ( " " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . mkdir ( " " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . mkdir ( " " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; test . getMount ( ) . addFile ( " " , " \n " ) ; auto result = test . diff ( ) ; EXPECT_THAT ( result . getErrors ( ) , UnorderedElementsAre ( ) ) ; EXPECT_THAT ( result . getUntracked ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , 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 { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , RelativePath { " " } ) ) ; EXPECT_THAT ( result . getIgnored ( ) , UnorderedElementsAre ( RelativePath { " " } , RelativePath { " " } , RelativePath { " " } , 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 // Matches exlude rule in top-level .gitignore, but explicitly // included by "!bar.txt" rule in foo/foo/.gitignore // Ignored by "*.log" rule in abc/def/.gitignore // Ignored by "**/foo/bar.txt" rule in top-level .gitignore file // Ignored by "**/foo/bar.txt" rule in top-level .gitignore file // Ignored by "test" rule in foo/.gitignore // Also ignored by "test" rule in foo/.gitignore