summaryrefslogtreecommitdiff
path: root/src/status.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-10-15 12:48:43 -0700
committerRussell Belfer <rb@github.com>2012-10-15 12:54:46 -0700
commit52032ae53689ac37350f6af3bf1834122e4b3cf0 (patch)
treed9d98e14fa8e2a5d5d024dbd623bf9beb42e1330 /src/status.c
parentd5a51910678f8aea2b7efe077efc678141762dfc (diff)
downloadlibgit2-52032ae53689ac37350f6af3bf1834122e4b3cf0.tar.gz
Fix single-file ignore checks
To answer if a single given file should be ignored, the path to that file has to be processed progressively checking that there are no intermediate ignored directories in getting to the file in question. This enables that, fixing the broken old behavior, and adds tests to exercise various ignore situations.
Diffstat (limited to 'src/status.c')
-rw-r--r--src/status.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/status.c b/src/status.c
index 3a0ed075f..a37653db4 100644
--- a/src/status.c
+++ b/src/status.c
@@ -86,6 +86,10 @@ int git_status_foreach_ext(
assert(show <= GIT_STATUS_SHOW_INDEX_THEN_WORKDIR);
+ if (show != GIT_STATUS_SHOW_INDEX_ONLY &&
+ (err = git_repository__ensure_not_bare(repo, "status")) < 0)
+ return err;
+
if ((err = git_repository_head_tree(&head, repo)) < 0)
return err;
@@ -245,9 +249,22 @@ int git_status_file(
error = GIT_EAMBIGUOUS;
if (!error && !sfi.count) {
- giterr_set(GITERR_INVALID,
- "Attempt to get status of nonexistent file '%s'", path);
- error = GIT_ENOTFOUND;
+ git_buf full = GIT_BUF_INIT;
+
+ /* if the file actually exists and we still did not get a callback
+ * for it, then it must be contained inside an ignored directory, so
+ * mark it as such instead of generating an error.
+ */
+ if (!git_buf_joinpath(&full, git_repository_workdir(repo), path) &&
+ git_path_exists(full.ptr))
+ sfi.status = GIT_STATUS_IGNORED;
+ else {
+ giterr_set(GITERR_INVALID,
+ "Attempt to get status of nonexistent file '%s'", path);
+ error = GIT_ENOTFOUND;
+ }
+
+ git_buf_free(&full);
}
*status_flags = sfi.status;