Commit 0fd469ce93e6b6c5b88d97c22a7ed2a07b60451f

Stefan Sperling 2019-03-11T16:27:15

make got_ref_write() work for refs which do not exist yet

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/lib/reference.c b/lib/reference.c
index 3d68a01..fead5a1 100644
--- a/lib/reference.c
+++ b/lib/reference.c
@@ -18,6 +18,7 @@
 #include <sys/queue.h>
 #include <sys/stat.h>
 
+#include <errno.h>
 #include <ctype.h>
 #include <dirent.h>
 #include <sha1.h>
@@ -755,7 +756,7 @@ got_ref_write(struct got_reference *ref, struct got_repository *repo)
 
 	/* XXX: check if old content matches our expectations? */
 
-	if (stat(path, &sb) != 0) {
+	if (stat(path, &sb) != 0 && errno != ENOENT) {
 		err = got_error_from_errno();
 		goto done;
 	}