add -v option 'got log'; currently shows parent commits
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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
diff --git a/got/got.1 b/got/got.1
index f7418de..3bcc62f 100644
--- a/got/got.1
+++ b/got/got.1
@@ -84,7 +84,7 @@ 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 ]
+.It Cm log [ Fl p ] [ Fl c Ar commit ] [ Fl l Ar N ] [ Fl v ] [ Ar repository-path ]
Display history of the repository.
If the
.Fl p
@@ -102,6 +102,9 @@ The
option limits the output to a number of
.Ar N
commits.
+The
+.Fl v
+option enables verbose output.
If the
.Ar repository path
is omitted, use the current working directory.
diff --git a/got/got.c b/got/got.c
index df469a9..0402e69 100644
--- a/got/got.c
+++ b/got/got.c
@@ -306,7 +306,7 @@ print_patch(struct got_commit_object *commit, struct got_object_id *id,
static const struct got_error *
print_commit(struct got_commit_object *commit, struct got_object_id *id,
- struct got_repository *repo, int show_patch)
+ struct got_repository *repo, int show_patch, int verbose)
{
const struct got_error *err = NULL;
char *id_str, *logmsg, *line;
@@ -321,6 +321,16 @@ print_commit(struct got_commit_object *commit, struct got_object_id *id,
printf("author: %s\n", commit->author);
if (strcmp(commit->author, commit->committer) != 0)
printf("committer: %s\n", commit->committer);
+ if (verbose) {
+ struct got_parent_id *pid;
+ SIMPLEQ_FOREACH(pid, &commit->parent_ids, entry) {
+ err = got_object_id_str(&id_str, pid->id);
+ if (err)
+ return err;
+ printf("parent commit: %s\n", id_str);
+ free(id_str);
+ }
+ }
logmsg = strdup(commit->logmsg);
if (logmsg == NULL)
@@ -344,7 +354,7 @@ print_commit(struct got_commit_object *commit, struct got_object_id *id,
static const struct got_error *
print_commits(struct got_object *root_obj, struct got_object_id *root_id,
- struct got_repository *repo, int show_patch, int limit)
+ struct got_repository *repo, int show_patch, int limit, int verbose)
{
const struct got_error *err;
struct got_commit_graph *graph;
@@ -373,7 +383,7 @@ print_commits(struct got_object *root_obj, struct got_object_id *root_id,
}
if (commit == NULL)
break;
- err = print_commit(commit, id, repo, show_patch);
+ err = print_commit(commit, id, repo, show_patch, verbose);
if (err || (limit && --limit == 0))
break;
} while (ncommits > 0);
@@ -400,7 +410,7 @@ cmd_log(int argc, char *argv[])
char *repo_path = NULL;
char *start_commit = NULL;
int ch;
- int show_patch = 0, limit = 0;
+ int show_patch = 0, limit = 0, verbose = 0;
const char *errstr;
#ifndef PROFILE
@@ -408,7 +418,7 @@ cmd_log(int argc, char *argv[])
err(1, "pledge");
#endif
- while ((ch = getopt(argc, argv, "pc:l:")) != -1) {
+ while ((ch = getopt(argc, argv, "pc:l:v")) != -1) {
switch (ch) {
case 'p':
show_patch = 1;
@@ -421,6 +431,9 @@ cmd_log(int argc, char *argv[])
if (errstr != NULL)
err(1, "-l option %s", errstr);
break;
+ case 'v':
+ verbose = 1;
+ break;
default:
usage();
/* NOTREACHED */
@@ -467,7 +480,8 @@ cmd_log(int argc, char *argv[])
if (error != NULL)
return error;
if (got_object_get_type(obj) == GOT_OBJ_TYPE_COMMIT)
- error = print_commits(obj, id, repo, show_patch, limit);
+ error = print_commits(obj, id, repo, show_patch, limit,
+ verbose);
else
error = got_error(GOT_ERR_OBJ_TYPE);
got_object_close(obj);