Commit a097512813331d3a6c5eac85579b195a9707f114

Stefan Sperling 2020-02-07T11:02:00

fix 'got blame' and 'tog blame' on files added on worktree's current branch

diff --git a/got/got.c b/got/got.c
index 676510c..4329f78 100644
--- a/got/got.c
+++ b/got/got.c
@@ -2623,7 +2623,8 @@ cmd_blame(int argc, char *argv[])
 
 	if (commit_id_str == 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)
 			goto done;
 		error = got_ref_resolve(&commit_id, repo, head_ref);
diff --git a/tog/tog.c b/tog/tog.c
index 99c464b..9618b61 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -4438,7 +4438,8 @@ cmd_blame(int argc, char *argv[])
 
 	if (commit_id_str == 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)
 			goto done;
 		error = got_ref_resolve(&commit_id, repo, head_ref);