remove GOT_ERR_NOT_ABSPATH and fix existing users to deal with absolute paths
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
diff --git a/include/got_error.h b/include/got_error.h
index ae6efb2..cd15a3a 100644
--- a/include/got_error.h
+++ b/include/got_error.h
@@ -18,7 +18,7 @@
#define GOT_ERR_OK 0
#define GOT_ERR_ERRNO 1
#define GOT_ERR_NOT_GIT_REPO 2
-#define GOT_ERR_NOT_ABSPATH 3
+/* 3 is currently unused */
#define GOT_ERR_BAD_PATH 4
#define GOT_ERR_NOT_REF 5
#define GOT_ERR_IO 6
@@ -139,7 +139,7 @@ static const struct got_error {
{ GOT_ERR_OK, "no error occured?!?" },
{ GOT_ERR_ERRNO, "see errno" },
{ GOT_ERR_NOT_GIT_REPO, "no git repository found" },
- { GOT_ERR_NOT_ABSPATH, "absolute path expected" },
+ { 3, "unused error code" },
{ GOT_ERR_BAD_PATH, "bad path" },
{ GOT_ERR_NOT_REF, "no such reference found" },
{ GOT_ERR_IO, "input/output error" },
diff --git a/lib/object.c b/lib/object.c
index f8ccc9e..ea5232a 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1637,18 +1637,15 @@ got_object_tree_path_changed(int *changed,
*changed = 0;
- /* We are expecting an absolute in-repository path. */
- if (path[0] != '/')
- return got_error(GOT_ERR_NOT_ABSPATH);
-
/* We not do support comparing the root path. */
- if (path[1] == '\0')
+ if (got_path_is_root_dir(path))
return got_error_path(path, GOT_ERR_BAD_PATH);
tree1 = tree01;
tree2 = tree02;
s = path;
- s++; /* skip leading '/' */
+ while (*s == '/')
+ s++;
seg = s;
seglen = 0;
while (*s) {
diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index 37bda9d..d690ffc 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -446,16 +446,13 @@ tree_path_changed(int *changed, uint8_t **buf1, uint8_t **buf2,
*changed = 0;
- /* We are expecting an absolute in-repository path. */
- if (path[0] != '/')
- return got_error(GOT_ERR_NOT_ABSPATH);
-
/* We not do support comparing the root path. */
- if (path[1] == '\0')
+ if (got_path_is_root_dir(path))
return got_error_path(path, GOT_ERR_BAD_PATH);
s = path;
- s++; /* skip leading '/' */
+ while (*s == '/')
+ s++;
seg = s;
seglen = 0;
while (*s) {