tweak the log command synopsis and update man page
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
diff --git a/got/got.1 b/got/got.1
index 84b212f..e776aa4 100644
--- a/got/got.1
+++ b/got/got.1
@@ -75,11 +75,19 @@ In this case, only files beneath the specified directory prefix will
be checked out.
.\".It Cm status
.\"Show current status of files.
-.It Cm log
+.It Cm log [ Fl p ] [ Fl c Ar commit ] [ Ar repository-path ]
Display history of the repository.
If the
.Fl p
flag is given, display the patch of modifications made in each commit.
+If a
+.Ar commit
+is specified with the
+.Fl c
+option, start traversing history at this commit.
+If the
+.Ar repository path
+is omitted, use the current working directory.
.El
.Sh EXIT STATUS
.Ex -std got
diff --git a/got/got.c b/got/got.c
index 41ca7c9..ba1a257 100644
--- a/got/got.c
+++ b/got/got.c
@@ -404,7 +404,7 @@ print_commits(struct got_object *root_obj, struct got_object_id *root_id,
__dead void
usage_log(void)
{
- fprintf(stderr, "usage: %s log [-p] [repository-path] [commit]\n",
+ fprintf(stderr, "usage: %s log [-p] [-c commit] [repository-path]\n",
getprogname());
exit(1);
}
@@ -417,7 +417,7 @@ cmd_log(int argc, char *argv[])
struct got_object_id *id = NULL;
struct got_object *obj;
char *repo_path = NULL;
- char *commit_id_str = NULL;
+ char *start_commit = NULL;
int ch;
int show_patch = 0;
@@ -426,11 +426,14 @@ cmd_log(int argc, char *argv[])
err(1, "pledge");
#endif
- while ((ch = getopt(argc, argv, "p")) != -1) {
+ while ((ch = getopt(argc, argv, "pc:")) != -1) {
switch (ch) {
case 'p':
show_patch = 1;
break;
+ case 'c':
+ start_commit = optarg;
+ break;
default:
usage();
/* NOTREACHED */
@@ -446,9 +449,6 @@ cmd_log(int argc, char *argv[])
err(1, "getcwd");
} else if (argc == 1) {
repo_path = argv[0];
- } else if (argc == 2) {
- repo_path = argv[0];
- commit_id_str = argv[1];
} else
usage_log();
@@ -456,7 +456,7 @@ cmd_log(int argc, char *argv[])
if (error != NULL)
return error;
- if (commit_id_str == NULL) {
+ if (start_commit == NULL) {
struct got_reference *head_ref;
error = got_ref_open(&head_ref, repo, GOT_REF_HEAD);
if (error != NULL)
@@ -467,7 +467,7 @@ cmd_log(int argc, char *argv[])
return error;
error = got_object_open(&obj, repo, id);
} else {
- error = got_object_open_by_id_str(&obj, repo, commit_id_str);
+ error = got_object_open_by_id_str(&obj, repo, start_commit);
if (error == NULL) {
id = got_object_get_id(obj);
if (id == NULL)