summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUngureanu Marius <marius.ungureanu@xamarin.com>2014-11-07 20:32:50 +0200
committerUngureanu Marius <marius.ungureanu@xamarin.com>2014-11-07 21:34:54 +0200
commit68182085694d76b97eb747960195917df69500c8 (patch)
tree0f535ab30c389eaa54f84168bcf6e85309466e61
parent4e1b3b3b7186b017223b8302a51289ff92ccba25 (diff)
downloadlibgit2-68182085694d76b97eb747960195917df69500c8.tar.gz
git_status_file now takes an exact path
This function has one output but can match multiple files, which can be unexpected for the user, which would usually path the exact path of the file he wants the status of.
-rw-r--r--CHANGELOG.md3
-rw-r--r--include/git2/status.h3
-rw-r--r--src/status.c3
-rw-r--r--tests/status/worktree_init.c4
4 files changed, 8 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 786668c4a..3ae298293 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -112,3 +112,6 @@ v0.21 + 1
now uint32_t instead of uint16_t. This allows to set them to UINT_MAX,
in effect asking for "infinite" context e.g. to iterate over all the
unmodified lines of a diff.
+
+* git_status_file now takes an exact path. Use git_status_list_new if
+ pathspec searching is needed.
diff --git a/include/git2/status.h b/include/git2/status.h
index 3c86e5d7b..5f211810d 100644
--- a/include/git2/status.h
+++ b/include/git2/status.h
@@ -281,7 +281,8 @@ GIT_EXTERN(int) git_status_foreach_ext(
*
* @param status_flags Output combination of git_status_t values for file
* @param repo A repository object
- * @param path The file to retrieve status for relative to the repo workdir
+ * @param path The exact path to retrieve status for relative to the
+ * repository working directory
* @return 0 on success, GIT_ENOTFOUND if the file is not found in the HEAD,
* index, and work tree, GIT_EAMBIGUOUS if `path` matches multiple files
* or if it refers to a folder, and -1 on other errors.
diff --git a/src/status.c b/src/status.c
index cb2490042..720ccb7eb 100644
--- a/src/status.c
+++ b/src/status.c
@@ -494,7 +494,8 @@ int git_status_file(
GIT_STATUS_OPT_RECURSE_IGNORED_DIRS |
GIT_STATUS_OPT_INCLUDE_UNTRACKED |
GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS |
- GIT_STATUS_OPT_INCLUDE_UNMODIFIED;
+ GIT_STATUS_OPT_INCLUDE_UNMODIFIED |
+ GIT_STATUS_OPT_DISABLE_PATHSPEC_MATCH;
opts.pathspec.count = 1;
opts.pathspec.strings = &sfi.expected;
diff --git a/tests/status/worktree_init.c b/tests/status/worktree_init.c
index 296c27c86..3e43c8c20 100644
--- a/tests/status/worktree_init.c
+++ b/tests/status/worktree_init.c
@@ -195,9 +195,7 @@ void test_status_worktree_init__bracket_in_filename(void)
cl_git_pass(git_status_file(&status_flags, repo, "LICENSE\\[1\\].md"));
cl_assert(status_flags == GIT_STATUS_INDEX_NEW);
- error = git_status_file(&status_flags, repo, FILE_WITH_BRACKET);
- cl_git_fail(error);
- cl_assert_equal_i(GIT_EAMBIGUOUS, error);
+ cl_git_pass(git_status_file(&status_flags, repo, FILE_WITH_BRACKET));
git_index_free(index);
git_repository_free(repo);