document checkout better and fix optional worktree arg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/got/got.1 b/got/got.1
index d36fc50..12bc2ce 100644
--- a/got/got.1
+++ b/got/got.1
@@ -65,14 +65,22 @@ Display usage information.
.Pp
The commands are as follows:
.Bl -tag -width checkout
-.It Cm checkout
+.It Cm checkout [ Fl p Ar path-prefix ] repository-path [ work-tree-path ]
Copy files from a repository into a new work tree.
The work tree may be restricted to a subset of the repository's tree
hierarchy by specifying the
-.Fl p Ar prefix
+.Fl p Ar path-prefix
option.
-In this case, only files beneath the specified directory prefix will
+In this case, only files beneath the specified prefix will
be checked out.
+If the
+.Ar work tree path
+is not specified, either use the base name of the
+.Ar repository path ,
+or if a
+.Ar path prefix
+was specified use the base name of the
+.Ar path prefix .
.\".It Cm status
.\"Show current status of files.
.It Cm log [ Fl p ] [ Fl c Ar commit ] [ Fl l Ar N ] [ Ar repository-path ]
diff --git a/got/got.c b/got/got.c
index cb7b07e..fffacf8 100644
--- a/got/got.c
+++ b/got/got.c
@@ -189,7 +189,10 @@ cmd_checkout(int argc, char *argv[])
cwd = getcwd(NULL, 0);
if (cwd == NULL)
err(1, "getcwd");
- base = basename(repo_path);
+ if (path_prefix[0])
+ base = basename(path_prefix);
+ else
+ base = basename(repo_path);
if (base == NULL)
err(1, "basename");
dotgit = strstr(base, ".git");