Commit b4b3a7ddd799cc2acf25bf4a7b107f04b87d81cd

Stefan Sperling 2019-07-22T10:26:58

handle work tree path realpath(3) ENOENT during checkout

diff --git a/got/got.c b/got/got.c
index c124743..0b15a8b 100644
--- a/got/got.c
+++ b/got/got.c
@@ -856,8 +856,16 @@ cmd_checkout(int argc, char *argv[])
 		}
 		worktree_path = realpath(argv[1], NULL);
 		if (worktree_path == NULL) {
-			error = got_error_from_errno2("realpath", argv[1]);
-			goto done;
+			if (errno != ENOENT) {
+				error = got_error_from_errno2("realpath",
+				    argv[1]);
+				goto done;
+			}
+			worktree_path = strdup(argv[1]);
+			if (worktree_path == NULL) {
+				error = got_error_from_errno("strdup");
+				goto done;
+			}
 		}
 	} else
 		usage_checkout();