git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v3 05/16] ref-filter: move get_head_description() from branch.c

From
Karthik Nayak <karthik.188@gmail.com>
Date
Apr 1, 2016, 18:41 UTC
Message-ID
<CAOLa=ZSs3ZUysusArNK8oXSe7jqqquJyx4=ZtNyqmDsm_iAguQ@mail.gmail.com>
In-Reply-To
<xmqqy48zr4r6.fsf@gitster.mtv.corp.google.com>
On Thu, Mar 31, 2016 at 3:46 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 40 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>> -static char *get_head_description(void)
>> -{
>> -     struct strbuf desc = STRBUF_INIT;
>> -     struct wt_status_state state;
>> -     memset(&state, 0, sizeof(state));
>> -     wt_status_get_state(&state, 1);
>> -     if (state.rebase_in_progress ||
>> -         state.rebase_interactive_in_progress)
>> -             strbuf_addf(&desc, _("(no branch, rebasing %s)"),
>> -                         state.branch);
>> -     else if (state.bisect_in_progress)
>> -             strbuf_addf(&desc, _("(no branch, bisect started on %s)"),
>> -                         state.branch);
>> -     else if (state.detached_from) {
>> -             /* TRANSLATORS: make sure these match _("HEAD detached at ")
>> -                and _("HEAD detached from ") in wt-status.c */
>> -             if (state.detached_at)
>> -                     strbuf_addf(&desc, _("(HEAD detached at %s)"),
>> -                             state.detached_from);
>> -             else
>> -                     strbuf_addf(&desc, _("(HEAD detached from %s)"),
>> -                             state.detached_from);
>> -     }
>> -     else
>> -             strbuf_addstr(&desc, _("(no branch)"));
>> -     free(state.branch);
>> -     free(state.onto);
>> -     free(state.detached_from);
>> -     return strbuf_detach(&desc, NULL);
>> -}
>> -
>
> Hmph, the name used to be a good one within the context of
> implementation of "git branch" command, but I have to wonder if it
> is a specific enough name in the global context of the entire
> project.  I also wondered if this sits better in wt-status.c;
> doesn't "git status" do something similar?
>

Yes, `wt_status_print(struct wt_status *s)` pretty much does the same, maybe we can eventually lose this in favor of using that.

> For now, this should do, as I do not think of anything better.
>
> Thanks.
Sure.
-- 
Regards,
Karthik Nayak
Previous: Junio C HamanoNext: Karthik Nayak
Message 9 of 31 in “port branch.c to use ref-filter's printing options”
  1. 00/16 port branch.c to use ref-filter's printing optionsKarthik Nayak, Mar 30, 2016
  2. 01/16 ref-filter: implement %(if), %(then), and %(else) atomsKarthik Nayak, Mar 30, 2016
  3. 02/16 ref-filter: include reference to 'used_atom' within 'atom_value'Karthik Nayak, Mar 30, 2016
  4. Junio C HamanoMar 30, 2016
  5. 03/16 ref-filter: implement %(if:equals=<string>) and %(if:notequals=<string>)Karthik Nayak, Mar 30, 2016
  6. 04/16 ref-filter: modify "%(objectname:short)" to take lengthKarthik Nayak, Mar 30, 2016
  7. 05/16 ref-filter: move get_head_description() from branch.cKarthik Nayak, Mar 30, 2016
  8. Junio C HamanoMar 30, 2016
  9. Karthik NayakApr 1, 2016
  10. 06/16 ref-filter: introduce format_ref_array_item()Karthik Nayak, Mar 30, 2016
  11. 07/16 ref-filter: make %(upstream:track) prints "[gone]" for invalid upstreamsKarthik Nayak, Mar 30, 2016
  12. 08/16 ref-filter: add support for %(upstream:track,nobracket)Karthik Nayak, Mar 30, 2016
  13. 09/16 ref-filter: make "%(symref)" atom work with the ':short' modifierKarthik Nayak, Mar 30, 2016
  14. Junio C HamanoMar 30, 2016
  15. Karthik NayakApr 1, 2016
  16. 10/16 ref-filter: introduce symref_atom_parser()Karthik Nayak, Mar 30, 2016
  17. 11/16 ref-filter: introduce refname_atom_parser()Karthik Nayak, Mar 30, 2016
  18. 12/16 ref-filter: add support for %(refname:dir) and %(refname:base)Karthik Nayak, Mar 30, 2016
  19. 13/16 ref-filter: allow porcelain to translate messages in the outputKarthik Nayak, Mar 30, 2016
  20. Junio C HamanoMar 30, 2016
  21. Karthik NayakApr 1, 2016
  22. Matthieu MoyApr 4, 2016
  23. Junio C HamanoApr 4, 2016
  24. 14/16 branch, tag: use porcelain outputKarthik Nayak, Mar 30, 2016
  25. 15/16 branch: use ref-filter printing APIsKarthik Nayak, Mar 30, 2016
  26. 16/16 branch: implement '--format' optionKarthik Nayak, Mar 30, 2016
  27. Junio C HamanoMar 30, 2016
  28. Dennis KaarsemakerApr 1, 2016
  29. Dennis KaarsemakerApr 1, 2016
  30. Ramsay JonesApr 1, 2016
  31. Karthik NayakApr 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.