commit 19e70ad6fff7c3b54cf7f69f86c86c5299037c62 from: Stefan Sperling date: Tue May 14 20:33:38 2019 UTC make 'tog log' default to the current branch in a work tree commit - 1cc14b9ffe9db23a9b9546d1ce7ab12237b4e35b commit + 19e70ad6fff7c3b54cf7f69f86c86c5299037c62 blob - 08647d752a0fadf82338954dbf1b9061cbca3164 blob + 0ebf42b9397c3946b9f89b1b297bacf9756a07ea --- tog/tog.1 +++ tog/tog.1 @@ -115,6 +115,8 @@ Start traversing history at the specified .Ar commit . The expected argument is the name of a branch or a SHA1 hash which corresponds to a commit object. +If this option is not specified, default to the work tree's current branch +if invoked in a work tree, or to the repository's HEAD reference. .It Fl r Ar repository-path Use the repository at the specified path. If not specified, assume the repository is located at or above the current blob - a3ca55222c14ce740197763f349434d81c148e38 blob + f6e6728835caba36f32640aac656a5dcc1431600 --- tog/tog.c +++ tog/tog.c @@ -1106,14 +1106,15 @@ queue_commits(struct got_commit_graph *graph, struct c } static const struct got_error * -get_head_commit_id(struct got_object_id **head_id, struct got_repository *repo) +get_head_commit_id(struct got_object_id **head_id, const char *branch_name, + struct got_repository *repo) { const struct got_error *err = NULL; struct got_reference *head_ref; *head_id = NULL; - err = got_ref_open(&head_ref, repo, GOT_REF_HEAD, 0); + err = got_ref_open(&head_ref, repo, branch_name, 0); if (err) return err; @@ -1901,7 +1902,9 @@ cmd_log(int argc, char *argv[]) goto done; if (start_commit == NULL) - error = get_head_commit_id(&start_id, repo); + error = get_head_commit_id(&start_id, worktree ? + got_worktree_get_head_ref_name(worktree) : GOT_REF_HEAD, + repo); else error = got_object_resolve_id_str(&start_id, repo, start_commit); @@ -3909,7 +3912,7 @@ cmd_tree(int argc, char *argv[]) goto done; if (commit_id_arg == NULL) - error = get_head_commit_id(&commit_id, repo); + error = get_head_commit_id(&commit_id, GOT_REF_HEAD, repo); else error = got_object_resolve_id_str(&commit_id, repo, commit_id_arg);