commit d142fc4582a55b3d8550935f8546bfa080f2bd98 from: Stefan Sperling date: Sun Apr 01 17:48:17 2018 UTC tweak the log command synopsis and update man page commit - b00d56cde51fc646b2b3055ff80e6f5b2b8cccb1 commit + d142fc4582a55b3d8550935f8546bfa080f2bd98 blob - 84b212f11bdf093996b9fad66acea32f441cf7b2 blob + e776aa41a89bdb1de0da979d24c3588f0c344152 --- got/got.1 +++ got/got.1 @@ -75,11 +75,19 @@ In this case, only files beneath the specified directo 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 blob - 41ca7c9696379c1899dc721f39eb4c60a8f672df blob + ba1a257980d1b9f0e7bebe84ebcfc64c904caf32 --- got/got.c +++ got/got.c @@ -404,7 +404,7 @@ print_commits(struct got_object *root_obj, struct got_ __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,10 +426,13 @@ 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(); @@ -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)