when "bad path" errors occur, always show the path in question
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
diff --git a/lib/object.c b/lib/object.c
index 174d3ab..f8ccc9e 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -152,7 +152,7 @@ get_packfile_path(char **path_packfile, struct got_packidx *packidx)
/* Packfile path contains ".pack" instead of ".idx", so add one byte. */
size = strlen(packidx->path_packidx) + 2;
if (size < GOT_PACKFILE_NAMELEN + 1)
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(packidx->path_packidx, GOT_ERR_BAD_PATH);
*path_packfile = malloc(size);
if (*path_packfile == NULL)
@@ -1643,7 +1643,7 @@ got_object_tree_path_changed(int *changed,
/* We not do support comparing the root path. */
if (path[1] == '\0')
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(path, GOT_ERR_BAD_PATH);
tree1 = tree01;
tree2 = tree02;
diff --git a/lib/path.c b/lib/path.c
index 612f8ea..01ae02e 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -112,11 +112,11 @@ got_path_skip_common_ancestor(char **child, const char *parent_abspath,
len_parent = strlen(parent_abspath);
len = strlen(abspath);
if (len_parent >= len)
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(abspath, GOT_ERR_BAD_PATH);
if (strncmp(parent_abspath, abspath, len_parent) != 0)
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(abspath, GOT_ERR_BAD_PATH);
if (!got_path_is_root_dir(parent_abspath) && abspath[len_parent] != '/')
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(abspath, GOT_ERR_BAD_PATH);
while (abspath[len_parent] == '/')
abspath++;
bufsize = len - len_parent + 1;
@@ -363,7 +363,7 @@ got_path_dirname(char **parent, const char *path)
return got_error_from_errno2("dirname", path);
if (p[0] == '.' && p[1] == '\0')
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(path, GOT_ERR_BAD_PATH);
*parent = strdup(p);
if (*parent == NULL)
diff --git a/lib/repository.c b/lib/repository.c
index 479f6f6..1b376cc 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -543,7 +543,7 @@ got_repo_open(struct got_repository **repop, const char *path,
else
abspath = got_path_get_absolute(path);
if (abspath == NULL)
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(path, GOT_ERR_BAD_PATH);
repo = calloc(1, sizeof(*repo));
if (repo == NULL) {
diff --git a/lib/worktree.c b/lib/worktree.c
index 86333ed..0e0bef7 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2833,7 +2833,7 @@ got_worktree_resolve_path(char **wt_path, struct got_worktree *worktree,
if (strncmp(got_worktree_get_root_path(worktree), resolved,
strlen(got_worktree_get_root_path(worktree)))) {
- err = got_error(GOT_ERR_BAD_PATH);
+ err = got_error_path(resolved, GOT_ERR_BAD_PATH);
goto done;
}
@@ -2996,7 +2996,7 @@ schedule_for_deletion(void *arg, unsigned char status,
ie = got_fileindex_entry_get(a->fileindex, relpath, strlen(relpath));
if (ie == NULL)
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(relpath, GOT_ERR_BAD_PATH);
staged_status = get_staged_status(ie);
if (staged_status != GOT_STATUS_NO_CHANGE) {
@@ -3465,7 +3465,7 @@ revert_file(void *arg, unsigned char status, unsigned char staged_status,
ie = got_fileindex_entry_get(a->fileindex, relpath, strlen(relpath));
if (ie == NULL)
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(relpath, GOT_ERR_BAD_PATH);
/* Construct in-repository path of tree which contains this blob. */
err = got_path_dirname(&parent_path, ie->path);
diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index 4913359..37bda9d 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -452,7 +452,7 @@ tree_path_changed(int *changed, uint8_t **buf1, uint8_t **buf2,
/* We not do support comparing the root path. */
if (path[1] == '\0')
- return got_error(GOT_ERR_BAD_PATH);
+ return got_error_path(path, GOT_ERR_BAD_PATH);
s = path;
s++; /* skip leading '/' */