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);