diff --git a/native/v8_extensions/git.mm b/native/v8_extensions/git.mm index 3063e43ad..8027f84e4 100644 --- a/native/v8_extensions/git.mm +++ b/native/v8_extensions/git.mm @@ -51,7 +51,7 @@ public: return CefV8Value::CreateBool(false); int *ignored; - if (git_ignore_path_is_ignored(ignored, repo, path) == GIT_OK) + if (git_ignore_path_is_ignored(ignored, repo, path) >= GIT_OK) return CefV8Value::CreateBool(*ignored == 1); else return CefV8Value::CreateBool(false); diff --git a/spec/app/git-spec.coffee b/spec/app/git-spec.coffee index a9da26be0..efe07de60 100644 --- a/spec/app/git-spec.coffee +++ b/spec/app/git-spec.coffee @@ -28,3 +28,12 @@ describe "Git", -> it "returns a branch name for a non-empty repository", -> repo = new Git(require.resolve('fixtures/git/master.git')) expect(repo.getShortHead()).toBe 'master' + + describe "isIgnored()", -> + it "returns true for an ignored path", -> + repo = new Git(require.resolve('fixtures/git/ignore.git')) + expect(repo.isIgnored('a.txt')).toBeTruthy() + + it "returns false for a non-ignored path", -> + repo = new Git(require.resolve('fixtures/git/ignore.git')) + expect(repo.isIgnored('b.txt')).toBeFalsy() \ No newline at end of file diff --git a/spec/fixtures/git/ignore.git/COMMIT_EDITMSG b/spec/fixtures/git/ignore.git/COMMIT_EDITMSG new file mode 100644 index 000000000..802607664 --- /dev/null +++ b/spec/fixtures/git/ignore.git/COMMIT_EDITMSG @@ -0,0 +1 @@ +initial commit diff --git a/spec/fixtures/git/ignore.git/HEAD b/spec/fixtures/git/ignore.git/HEAD new file mode 100644 index 000000000..cb089cd89 --- /dev/null +++ b/spec/fixtures/git/ignore.git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/spec/fixtures/git/ignore.git/config b/spec/fixtures/git/ignore.git/config new file mode 100644 index 000000000..af107929f --- /dev/null +++ b/spec/fixtures/git/ignore.git/config @@ -0,0 +1,6 @@ +[core] + repositoryformatversion = 0 + filemode = true + bare = false + logallrefupdates = true + ignorecase = true diff --git a/spec/fixtures/git/ignore.git/description b/spec/fixtures/git/ignore.git/description new file mode 100644 index 000000000..498b267a8 --- /dev/null +++ b/spec/fixtures/git/ignore.git/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/spec/fixtures/git/ignore.git/index b/spec/fixtures/git/ignore.git/index new file mode 100644 index 000000000..bf35b18cd Binary files /dev/null and b/spec/fixtures/git/ignore.git/index differ diff --git a/spec/fixtures/git/ignore.git/info/exclude b/spec/fixtures/git/ignore.git/info/exclude new file mode 100644 index 000000000..eaa5fa875 --- /dev/null +++ b/spec/fixtures/git/ignore.git/info/exclude @@ -0,0 +1 @@ +a.txt diff --git a/spec/fixtures/git/ignore.git/logs/HEAD b/spec/fixtures/git/ignore.git/logs/HEAD new file mode 100644 index 000000000..a5e7d8dcc --- /dev/null +++ b/spec/fixtures/git/ignore.git/logs/HEAD @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ef046e9eecaa5255ea5e9817132d4001724d6ae1 Kevin Sawicki 1351201397 -0700 commit (initial): initial commit diff --git a/spec/fixtures/git/ignore.git/logs/refs/heads/master b/spec/fixtures/git/ignore.git/logs/refs/heads/master new file mode 100644 index 000000000..a5e7d8dcc --- /dev/null +++ b/spec/fixtures/git/ignore.git/logs/refs/heads/master @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 ef046e9eecaa5255ea5e9817132d4001724d6ae1 Kevin Sawicki 1351201397 -0700 commit (initial): initial commit diff --git a/spec/fixtures/git/ignore.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 b/spec/fixtures/git/ignore.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 new file mode 100644 index 000000000..ba1f06fc0 Binary files /dev/null and b/spec/fixtures/git/ignore.git/objects/65/a457425a679cbe9adf0d2741785d3ceabb44a7 differ diff --git a/spec/fixtures/git/ignore.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 b/spec/fixtures/git/ignore.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 new file mode 100644 index 000000000..711223894 Binary files /dev/null and b/spec/fixtures/git/ignore.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 differ diff --git a/spec/fixtures/git/ignore.git/objects/ef/046e9eecaa5255ea5e9817132d4001724d6ae1 b/spec/fixtures/git/ignore.git/objects/ef/046e9eecaa5255ea5e9817132d4001724d6ae1 new file mode 100644 index 000000000..eaf6eeff3 Binary files /dev/null and b/spec/fixtures/git/ignore.git/objects/ef/046e9eecaa5255ea5e9817132d4001724d6ae1 differ diff --git a/spec/fixtures/git/ignore.git/refs/heads/master b/spec/fixtures/git/ignore.git/refs/heads/master new file mode 100644 index 000000000..6134b5707 --- /dev/null +++ b/spec/fixtures/git/ignore.git/refs/heads/master @@ -0,0 +1 @@ +ef046e9eecaa5255ea5e9817132d4001724d6ae1