Commit Diff


commit - 8b90f09e6b60001662761a66e78cec95d3a4b5b3
commit + 6f3d1eb01f797b6f091902400d6228bf6b76b96b
blob - 64b71bcd69c9439137d81692ec2d90e353a65e11
blob + c6d31fe1fabe152f155f7b3a2bf1e0ca13b290d3
--- got/got.c
+++ got/got.c
@@ -40,6 +40,7 @@ struct cmd {
 };
 
 __dead void	usage(void);
+__dead void	usage_log(void);
 
 int		cmd_log(int, char *[]);
 int		cmd_status(int, char *[]);
@@ -151,6 +152,13 @@ print_commit_object(struct got_object *obj, struct got
 	return err;
 }
 
+__dead void
+usage_log(void)
+{
+	fprintf(stderr, "usage: %s log [REPO_PATH]\n", getprogname());
+	exit(1);
+}
+
 int
 cmd_log(int argc, char *argv[])
 {
@@ -159,15 +167,19 @@ cmd_log(int argc, char *argv[])
 	struct got_reference *head_ref;
 	struct got_object_id *id;
 	struct got_object *obj;
-	char *repo_path;
+	char *repo_path = NULL;
 
 	if (pledge("stdio rpath wpath cpath", NULL) == -1)
 		err(1, "pledge");
 
-	/* TODO parse argv */
-	repo_path = getcwd(NULL, 0);
-	if (repo_path == NULL)
-		err(1, "getcwd");
+	if (argc == 1) {
+		repo_path = getcwd(NULL, 0);
+		if (repo_path == NULL)
+			err(1, "getcwd");
+	} else if (argc == 2)
+		repo_path = argv[1];
+	else
+		usage_log();
 
 	error = got_repo_open(&repo, repo_path);
 	if (error != NULL || repo == NULL)