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