add custom error code for 'no such tree entry' errors
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
diff --git a/include/got_error.h b/include/got_error.h
index 5e8cb64..143e83f 100644
--- a/include/got_error.h
+++ b/include/got_error.h
@@ -63,6 +63,7 @@
#define GOT_ERR_RANGE 47
#define GOT_ERR_EXPECTED 48 /* for use in regress tests only */
#define GOT_ERR_CANCELLED 49
+#define GOT_ERR_NO_TREE_ENTRY 50
static const struct got_error {
int code;
@@ -114,6 +115,7 @@ static const struct got_error {
{ GOT_ERR_RANGE, "value out of range" },
{ GOT_ERR_EXPECTED, "expected an error but have no error" },
{ GOT_ERR_CANCELLED, "operation in progress has been cancelled" },
+ { GOT_ERR_NO_TREE_ENTRY,"no such entry found in tree" },
};
/*
diff --git a/lib/blame.c b/lib/blame.c
index e933e16..3bb1f98 100644
--- a/lib/blame.c
+++ b/lib/blame.c
@@ -206,7 +206,7 @@ blame_commit(struct got_blame *blame, struct got_object_id *id,
err = got_object_id_by_path(&pobj_id, repo, pid, path);
if (err) {
- if (err->code == GOT_ERR_NO_OBJ) {
+ if (err->code == GOT_ERR_NO_TREE_ENTRY) {
/* Blob's history began in previous commit. */
err = got_error(GOT_ERR_ITER_COMPLETED);
}
diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index e91da57..7ca2aa5 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -190,7 +190,7 @@ detect_changed_path(int *changed, struct got_commit_object *commit,
struct got_object_id *obj_id;
err = got_object_id_by_path(&obj_id, repo, commit_id, path);
if (err) {
- if (err->code == GOT_ERR_NO_OBJ)
+ if (err->code == GOT_ERR_NO_TREE_ENTRY)
err = NULL;
} else
*changed = 1; /* The path was created in this commit. */
@@ -309,7 +309,7 @@ advance_branch(struct got_commit_graph *graph,
err = got_object_id_by_path(&id, repo, qid->id,
graph->path);
if (err) {
- if (err->code == GOT_ERR_NO_OBJ) {
+ if (err->code == GOT_ERR_NO_TREE_ENTRY) {
branches_differ = 1;
continue;
}
diff --git a/lib/object.c b/lib/object.c
index 97f5a2e..6bb2eb4 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -771,7 +771,7 @@ got_object_id_by_path(struct got_object_id **id, struct got_repository *repo,
te = find_entry_by_name(tree, seg, seglen);
if (te == NULL) {
- err = got_error(GOT_ERR_NO_OBJ);
+ err = got_error(GOT_ERR_NO_TREE_ENTRY);
goto done;
}
@@ -798,7 +798,7 @@ got_object_id_by_path(struct got_object_id **id, struct got_repository *repo,
if (*id == NULL)
return got_error_from_errno();
} else
- err = got_error(GOT_ERR_NO_OBJ);
+ err = got_error(GOT_ERR_NO_TREE_ENTRY);
done:
if (commit)
got_object_commit_close(commit);