Commit 13bfb272d51b1b7cf8f81e858928fb9af4698883

joshua stein 2019-05-10T18:46:23

got: remove trailing slash from worktree_path avoids a double slash when building a path in got_worktree_init

diff --git a/got/got.c b/got/got.c
index c82e0bf..d699079 100644
--- a/got/got.c
+++ b/got/got.c
@@ -314,7 +314,7 @@ cmd_checkout(int argc, char *argv[])
 	char *worktree_path = NULL;
 	const char *path_prefix = "";
 	char *commit_id_str = NULL;
-	int ch, same_path_prefix;
+	int ch, same_path_prefix, x;
 
 	while ((ch = getopt(argc, argv, "c:p:")) != -1) {
 		switch (ch) {
@@ -381,6 +381,9 @@ cmd_checkout(int argc, char *argv[])
 	} else
 		usage_checkout();
 
+	if (worktree_path[x = strlen(worktree_path) - 1] == '/')
+		worktree_path[x] = '\0';
+
 	error = got_repo_open(&repo, repo_path);
 	if (error != NULL)
 		goto done;