threads / discuss / 35401

branch annotations?

Subject: branch annotations?

## tl;dr

5 messages between Nov 25, 2013 and Nov 25, 2013.

replies: 4people: 4as markdown or json

Tim Chase· Nov 25, 2013, 14:46 UTC · lore

Is there any way to associate some sort of note with a branch that would be shown when listing them? While I currently have things like "issue/QA-42", it would be nice to have a note associated with it so I could do something like

  $ git branch --show-notes
    issue/CR-88: make sure NoSQL engines support .CSV file backends
    issue/QA-31: add missile launch codes
  * issue/QA-42: support flying cars
    master

as I currently need to flip back and forth between my git/terminal and my issue-tracker to know that, if I need to be adding missile launch codes, I need to be working on QA-31. I know there are "note" features elsewhere for commits, and I know that git-branch supports showing the most recent commit (that's not always enough info to discern the branch's purpose).

Thanks for any ideas on how to ease this pain-point, :-)
-tkc
Johan Herland· Nov 25, 2013, 14:55 UTC · re: Tim Chase · lore

Re: branch annotations?

On Mon, Nov 25, 2013 at 3:46 PM, Tim Chase <git@tim.thechases.com> wrote:
Show 19 quoted lines
> Is there any way to associate some sort of note with a branch that
> would be shown when listing them?  While I currently have things like
> "issue/QA-42", it would be nice to have a note associated with it so
> I could do something like
>
>   $ git branch --show-notes
>     issue/CR-88: make sure NoSQL engines support .CSV file backends
>     issue/QA-31: add missile launch codes
>   * issue/QA-42: support flying cars
>     master
>
> as I currently need to flip back and forth between my git/terminal
> and my issue-tracker to know that, if I need to be adding missile
> launch codes, I need to be working on QA-31.  I know there are "note"
> features elsewhere for commits, and I know that git-branch supports
> showing the most recent commit (that's not always enough info to
> discern the branch's purpose).
>
> Thanks for any ideas on how to ease this pain-point, :-)

"git branch --edit-description" allows you to write a descriptive string for your branch. AFAICS, however, it currently only shows up when using request-pull. It does not show up in any git branch command. IMHO that should be fixed.

As a workaround, you can use this one-liner:
  git for-each-ref --format "%(refname:short)" refs/heads/ | while
read branch; do echo "$branch - $(git config
branch.$branch.description)"; done
I guess that could even be turned into an alias...
Hope this helps,
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Tim Chase· Nov 25, 2013, 15:08 UTC · re: Johan Herland · lore

Re: branch annotations?

On 2013-11-25 15:55, Johan Herland wrote:
Show 10 quoted lines
> "git branch --edit-description" allows you to write a descriptive
> string for your branch. AFAICS, however, it currently only shows up
> when using request-pull. It does not show up in any git branch
> command. IMHO that should be fixed.
> 
> As a workaround, you can use this one-liner:
> 
>   git for-each-ref --format "%(refname:short)" refs/heads/ | while
> read branch; do echo "$branch - $(git config
> branch.$branch.description)"; done
That works like a charm.  Thanks!
-tkc
Jeff King· Nov 25, 2013, 14:56 UTC · re: Tim Chase · lore

Re: branch annotations?

On Mon, Nov 25, 2013 at 08:46:44AM -0600, Tim Chase wrote:
Show 10 quoted lines
> Is there any way to associate some sort of note with a branch that
> would be shown when listing them?  While I currently have things like
> "issue/QA-42", it would be nice to have a note associated with it so
> I could do something like
> 
>   $ git branch --show-notes
>     issue/CR-88: make sure NoSQL engines support .CSV file backends
>     issue/QA-31: add missile launch codes
>   * issue/QA-42: support flying cars
>     master

There is a "branch description" config entry that you can edit with "git branch --edit-description" (or by simply tweaking the config file yourself). However, it is currently only used by git-request-pull when generating the request.

I think it makes sense to be able to show it as part of "git branch", but the verbose branch listing there is a bit of a mess. Doing it cleanly would probably involve refactoring the branch-display code to allow users to specify more flexible formats.

Ramkumar (cc'd) was looking into that refactoring a while back, but I did not follow it closely (it looks like some of the underlying for-each-ref refactoring is on the 'next' branch?).

-Peff
Ramkumar Ramachandra· Nov 25, 2013, 18:29 UTC · re: Jeff King · lore

Re: branch annotations?

Jeff King wrote:
> I think it makes sense to be able to show it as part of "git branch",
> but the verbose branch listing there is a bit of a mess. Doing it
> cleanly would probably involve refactoring the branch-display code to
> allow users to specify more flexible formats.

Certainly. I'm quite unhappy with the current 'git branch', and am looking to improve it. Branch descriptions will definitely be useful to display as well.

> Ramkumar (cc'd) was looking into that refactoring a while back, but I
> did not follow it closely (it looks like some of the underlying
> for-each-ref refactoring is on the 'next' branch?).

The previous effort in collaboration with Duy fell apart, unfortunately. Currently, there are a few small patches enhancing f-e-r from the original series in 'next'. Once they graduate, the plan is to refactor f-e-r a bit so that 'git branch' can slowly be moved into using its machinery.

← back to recent threads