Commit 2e22a7cd96554f2890a58a6abc884f057e79c2ca

Stefan Sperling 2018-12-27T19:19:03

remove redundant existence check

diff --git a/lib/worktree.c b/lib/worktree.c
index f6afe82..7329316 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -53,8 +53,6 @@ create_meta_file(const char *path_got, const char *name, const char *content)
 	const struct got_error *err = NULL;
 	char *path;
 	int fd = -1;
-	char buf[4];
-	ssize_t n;
 
 	if (asprintf(&path, "%s/%s", path_got, name) == -1) {
 		err = got_error_from_errno();
@@ -69,14 +67,6 @@ create_meta_file(const char *path_got, const char *name, const char *content)
 		goto done;
 	}
 
-	/* The file should be empty. */
-	n = read(fd, buf, sizeof(buf));
-	if (n != 0) {
-		err = (n == -1 ? got_error_from_errno() :
-		    got_error(GOT_ERR_WORKTREE_EXISTS));
-		goto done;
-	}
-
 	if (content) {
 		int len = dprintf(fd, "%s\n", content);
 		if (len != strlen(content) + 1) {