commit d14519756a20c300e9189d2db6b7477b7adfe312 from: Stefan Sperling date: Sun Nov 11 12:52:20 2018 UTC add custom error code for 'no such tree entry' errors commit - 91a3d81fcf77040d5c432c86b5d4aebbec565468 commit + d14519756a20c300e9189d2db6b7477b7adfe312 blob - 5e8cb64e0e52fb1095b802f3386f56fdd3227a08 blob + 143e83f7018ddbcef9628d690bdf051427ab3057 --- include/got_error.h +++ 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" }, }; /* blob - e933e1676c8daad16a0b9fd52b089237e97c9e44 blob + 3bb1f98678b106ad77122434a981186a20b887b0 --- lib/blame.c +++ lib/blame.c @@ -206,7 +206,7 @@ blame_commit(struct got_blame *blame, struct got_objec 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); } blob - e91da57c2b2b62b9a115c7686001cfa45a0344da blob + 7ca2aa5795d839cb3b05074a245a575fa5bc069d --- lib/commit_graph.c +++ lib/commit_graph.c @@ -190,7 +190,7 @@ detect_changed_path(int *changed, struct got_commit_ob 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; } blob - 97f5a2e4929107697eee79b4a1b2ab8d14c253a5 blob + 6bb2eb4489271559e6ddb7579f548ba80e7d7ff0 --- lib/object.c +++ lib/object.c @@ -771,7 +771,7 @@ got_object_id_by_path(struct got_object_id **id, struc 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, struc 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);