Skip to content

Commit 9d49a43

Browse files
committed
repository_item_path: return ENOTFOUND when appropriate
Disambiguate error values: return `GIT_ENOTFOUND` when the item cannot exist in the repository (perhaps because the repository is inmemory or otherwise not backed by a filesystem), return `-1` when there is a hard failure.
1 parent fb3fc83 commit 9d49a43

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/git2/repository.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,12 +433,12 @@ typedef enum {
433433
* item. It will thereby honor things like the repository's
434434
* common directory, gitdir, etc. In case a file path cannot
435435
* exist for a given item (e.g. the working directory of a bare
436-
* repository), an error is returned.
436+
* repository), GIT_ENOTFOUND is returned.
437437
*
438438
* @param out Buffer to store the path at
439439
* @param repo Repository to get path for
440440
* @param item The repository item for which to retrieve the path
441-
* @return 0 on success, otherwise a negative value
441+
* @return 0, GIT_ENOTFOUND if the path cannot exist or an error code
442442
*/
443443
GIT_EXTERN(int) git_repository_item_path(git_buf *out, git_repository *repo, git_repository_item_t item);
444444

src/repository.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,7 +2272,7 @@ int git_repository_item_path(git_buf *out, git_repository *repo, git_repository_
22722272

22732273
if (parent == NULL) {
22742274
giterr_set(GITERR_INVALID, "path cannot exist in repository");
2275-
return -1;
2275+
return GIT_ENOTFOUND;
22762276
}
22772277

22782278
if (git_buf_sets(out, parent) < 0)

0 commit comments

Comments
 (0)