Commit Diff


commit - 3f8b7d6a05bca2370be722ebddb8b2418a30ffd2
commit + 5d7c1dab5252fee0ce211c15833dfd75027f6d1c
blob - d36fc503a75e6b75dd91939608912122f22629a9
blob + 12bc2ce386641994a1b47022c651f0311ca8e556
--- got/got.1
+++ 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 ]
blob - cb7b07e018311bd5ab62a53272627215b79aad96
blob + fffacf8141f5666f4ba7e40767b33d337935d700
--- got/got.c
+++ 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");