@@ -54,11 +54,13 @@ func gitCommits(repos []string, author string, r model.Range) []model.Item {
5454 name := filepath .Base (repo )
5555 base := originURL (repo )
5656
57+ // --source tags each commit with the ref it was reached from, exposed via
58+ // %S; with --all that's the branch (or remote/tag) carrying the commit.
5759 args := []string {
58- "-C" , repo , "log" , "--all" , "--no-merges" ,
60+ "-C" , repo , "log" , "--all" , "--source" , "-- no-merges" ,
5961 "--author=" + author , "--regexp-ignore-case" ,
6062 "--date=short" ,
61- "--pretty=format:%h" + fieldSep + "%H" + fieldSep + "%ad" + fieldSep + "%s" ,
63+ "--pretty=format:%h" + fieldSep + "%H" + fieldSep + "%ad" + fieldSep + "%S" + fieldSep + "% s" ,
6264 }
6365 if r .Since != "" {
6466 args = append (args , "--since=" + anchorMidnight (r .Since ))
@@ -75,11 +77,11 @@ func gitCommits(repos []string, author string, r model.Range) []model.Item {
7577 if strings .TrimSpace (line ) == "" {
7678 continue
7779 }
78- p := strings .SplitN (line , fieldSep , 4 )
79- if len (p ) != 4 {
80+ p := strings .SplitN (line , fieldSep , 5 )
81+ if len (p ) != 5 {
8082 continue
8183 }
82- if isNoiseSubject (p [3 ]) {
84+ if isNoiseSubject (p [4 ]) {
8385 continue
8486 }
8587 url := ""
@@ -94,13 +96,34 @@ func gitCommits(repos []string, author string, r model.Range) []model.Item {
9496 URL : url ,
9597 Hash : p [1 ],
9698 ShortHash : p [0 ],
97- Title : model .CleanText (p [3 ]),
99+ Branch : shortRef (p [3 ]),
100+ Title : model .CleanText (p [4 ]),
98101 })
99102 }
100103 }
101104 return items
102105}
103106
107+ // shortRef turns a fully-qualified git ref (as emitted by %S under --source)
108+ // into a bare branch name: refs/heads/x → x, refs/remotes/origin/x → x,
109+ // refs/tags/x → x. Anything else is returned trimmed and unchanged.
110+ func shortRef (ref string ) string {
111+ ref = strings .TrimSpace (ref )
112+ switch {
113+ case strings .HasPrefix (ref , "refs/heads/" ):
114+ return strings .TrimPrefix (ref , "refs/heads/" )
115+ case strings .HasPrefix (ref , "refs/remotes/" ):
116+ rest := strings .TrimPrefix (ref , "refs/remotes/" )
117+ if i := strings .IndexByte (rest , '/' ); i >= 0 {
118+ return rest [i + 1 :] // drop the remote name, keep the branch
119+ }
120+ return rest
121+ case strings .HasPrefix (ref , "refs/tags/" ):
122+ return strings .TrimPrefix (ref , "refs/tags/" )
123+ }
124+ return ref
125+ }
126+
104127// Preview returns `git show --stat` for a commit item (for the picker pane).
105128func Preview (it model.Item ) string {
106129 if it .Kind != model .KindCommit || it .Hash == "" {
0 commit comments