Commit Diff


commit - 8ea5c9979e9868aea3b985582195d97ace1f9665
commit + 34d4e04c36ba27442a4c0c7187e648ce03e23275
blob - 1991d4245ec041b192b623d07a0b5659e4757156
blob + 22cc9a1eba46d729c6f6890233b894a7d846f716
--- got/got.1
+++ got/got.1
@@ -978,12 +978,12 @@ Cannot be used together with any other options except
 .It Cm branch Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl d Ar name Oc Oo Fl n Oc Op Ar name
 Create, list, or delete branches.
 .Pp
-Branches are managed via references which live in the
+Local branches are managed via references which live in the
 .Dq refs/heads/
 reference namespace.
 The
 .Cm got branch
-command operates on references in this namespace only.
+command creates or deletes references in this namespace only.
 .Pp
 If invoked in a work tree without any arguments, print the name of the
 work tree's current branch.
@@ -1030,7 +1030,11 @@ If this directory is a
 .Nm
 work tree, use the repository path associated with this work tree.
 .It Fl l
-List all existing branches in the repository.
+List all existing branches in the repository, including copies of remote
+repositories' branches in the
+.Dq refs/remotes/
+reference namespace.
+.Pp
 If invoked in a work tree, the work tree's current branch is shown
 with one the following annotations:
 .Bl -column YXZ description
blob - ec8ca383265dfaa28ba38d636dbbfa0e9e73d98c
blob + 9bcd279e5446ef8a890025dd5e3e16b3206fc66a
--- got/got.c
+++ got/got.c
@@ -5543,6 +5543,8 @@ list_branch(struct got_repository *repo, struct got_wo
 		refname += 11;
 	if (strncmp(refname, "refs/got/worktree/", 18) == 0)
 		refname += 18;
+	if (strncmp(refname, "refs/remotes/", 13) == 0)
+		refname += 13;
 
 	refstr = got_ref_to_str(ref);
 	if (refstr == NULL)
@@ -5614,6 +5616,17 @@ list_branches(struct got_repository *repo, struct got_
 		list_branch(repo, worktree, re->ref);
 
 	got_ref_list_free(&refs);
+
+	err = got_ref_list(&refs, repo, "refs/remotes",
+	    got_ref_cmp_by_name, NULL);
+	if (err)
+		return err;
+
+	TAILQ_FOREACH(re, &refs, entry)
+		list_branch(repo, worktree, re->ref);
+
+	got_ref_list_free(&refs);
+
 	return NULL;
 }