Commit b66cd6f325e3fa7ddd17ff6dd41cf6e59d04ebf5

Stefan Sperling 2020-07-31T10:33:34

display more context info in "no such entry found in tree" error messages

diff --git a/lib/object.c b/lib/object.c
index 822b842..a43dbc1 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1664,7 +1664,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_TREE_ENTRY);
+			err = got_error_path(path, GOT_ERR_NO_TREE_ENTRY);
 			goto done;
 		}
 
@@ -1690,7 +1690,7 @@ got_object_id_by_path(struct got_object_id **id, struct got_repository *repo,
 		if (*id == NULL)
 			return got_error_from_errno("got_object_id_dup");
 	} else
-		err = got_error(GOT_ERR_NO_TREE_ENTRY);
+		err = got_error_path(path, GOT_ERR_NO_TREE_ENTRY);
 done:
 	if (commit)
 		got_object_commit_close(commit);
diff --git a/lib/repository.c b/lib/repository.c
index 6234533..b8408a7 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -1626,7 +1626,8 @@ write_tree(struct got_object_id **new_tree_id, const char *path_dir,
 	}
 
 	if (TAILQ_EMPTY(&paths)) {
-		err = got_error(GOT_ERR_NO_TREE_ENTRY);
+		err = got_error_msg(GOT_ERR_NO_TREE_ENTRY,
+		    "cannot create tree without any entries");
 		goto done;
 	}
 
diff --git a/lib/worktree.c b/lib/worktree.c
index 0538db4..61cc47c 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2537,7 +2537,7 @@ checkout_files(struct got_worktree *worktree, struct got_fileindex *fileindex,
 
 	if (entry_name &&
 	    got_object_tree_find_entry(tree, entry_name) == NULL) {
-		err = got_error(GOT_ERR_NO_TREE_ENTRY);
+		err = got_error_path(entry_name, GOT_ERR_NO_TREE_ENTRY);
 		goto done;
 	}
 
@@ -4341,7 +4341,7 @@ revert_file(void *arg, unsigned char status, unsigned char staged_status,
 		te = got_object_tree_find_entry(tree, te_name);
 		if (te == NULL && status != GOT_STATUS_ADD &&
 		    staged_status != GOT_STATUS_ADD) {
-			err = got_error(GOT_ERR_NO_TREE_ENTRY);
+			err = got_error_path(ie->path, GOT_ERR_NO_TREE_ENTRY);
 			goto done;
 		}
 	}
diff --git a/regress/cmdline/update.sh b/regress/cmdline/update.sh
index 80b89ad..29f55aa 100755
--- a/regress/cmdline/update.sh
+++ b/regress/cmdline/update.sh
@@ -1216,7 +1216,7 @@ function test_update_partial_rm {
 	(cd $testroot/repo && git rm -q alpha epsilon/zeta)
 	git_commit $testroot/repo -m "removed two files"
 
-	echo "got: no such entry found in tree" \
+	echo "got: /alpha: no such entry found in tree" \
 		> $testroot/stderr.expected
 
 	(cd $testroot/wt && got update alpha epsilon/zeta 2> $testroot/stderr)