Commit c97665ae45fef5919c0cfb789fafc56449be3409

Stefan Sperling 2019-01-13T01:43:17

tolerate missing files in remove_ondisk_file()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/lib/worktree.c b/lib/worktree.c
index 71f2090..43321ad 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -687,9 +687,10 @@ remove_ondisk_file(const char *root_path, const char *path)
 	if (asprintf(&ondisk_path, "%s/%s", root_path, path) == -1)
 		return got_error_from_errno();
 
-	if (unlink(ondisk_path) == -1)
-		err = got_error_from_errno();
-	else {
+	if (unlink(ondisk_path) == -1) {
+		if (errno != ENOENT)
+			err = got_error_from_errno();
+	} else {
 		char *parent = dirname(ondisk_path);
 		while (parent && strcmp(parent, root_path) != 0) {
 			if (rmdir(parent) == -1) {