Commit Diff


commit - 45d344f6a19dc0a91e021920cf6b3d0c5f4d0146
commit + 1cc14b9ffe9db23a9b9546d1ce7ab12237b4e35b
blob - e31268ef7cd73e1441f7b1bb264222dc8ab3216f
blob + 8412b6f8e8f5b3bc520eb72ff2c482f3a4cb600b
--- got/got.1
+++ got/got.1
@@ -171,6 +171,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 C Ar number
 Set the number of context lines shown in diffs with
 .Fl p .
blob - bdb817999466a7bc0d119183955f7661c2de3db9
blob + 5576a94038c6d3b01f3901abde351c21dc9e362c
--- got/got.c
+++ got/got.c
@@ -954,7 +954,7 @@ cmd_log(int argc, char *argv[])
 		err(1, "pledge");
 #endif
 
-	while ((ch = getopt(argc, argv, "pc:C:l:fr:")) != -1) {
+	while ((ch = getopt(argc, argv, "b:pc:C:l:fr:")) != -1) {
 		switch (ch) {
 		case 'p':
 			show_patch = 1;
@@ -1044,7 +1044,9 @@ cmd_log(int argc, char *argv[])
 
 	if (start_commit == NULL) {
 		struct got_reference *head_ref;
-		error = got_ref_open(&head_ref, repo, GOT_REF_HEAD, 0);
+		error = got_ref_open(&head_ref, repo,
+		    worktree ? got_worktree_get_head_ref_name(worktree)
+		    : GOT_REF_HEAD, 0);
 		if (error != NULL)
 			return error;
 		error = got_ref_resolve(&id, repo, head_ref);