Commit 9b4603c0290867d82a4f4f30cc49ae4e30789084

Stefan Sperling 2022-01-31T16:27:14

improve 'got add' error message if file does not exist; reported by Timo Myyrä ok tracey

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/lib/worktree.c b/lib/worktree.c
index 02ace08..610c0eb 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -3874,7 +3874,10 @@ schedule_addition(void *arg, unsigned char status, unsigned char staged_status,
 	}
 
 	if (status != GOT_STATUS_UNVERSIONED) {
-		err = got_error_path(ondisk_path, GOT_ERR_FILE_STATUS);
+		if (status == GOT_STATUS_NONEXISTENT)
+			err = got_error_set_errno(ENOENT, ondisk_path);
+		else
+			err = got_error_path(ondisk_path, GOT_ERR_FILE_STATUS);
 		goto done;
 	}