Re: [PATCH v4 6/8] status: print branch info with --porcelain=v2 --branch
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 5, 2016, 17:01 UTC
- Message-ID
- <xmqqd1lnxi99.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1470147137-17498-7-git-send-email-git@jeffhostetler.com>
Jeff Hostetler <git@jeffhostetler.com> writes:
Show 6 quoted lines
> /* > + * Print branch information for porcelain v2 output. These lines > + * are printed when the '--branch' parameter is given. > + * > + * # branch.oid <commit><eol> > + * # branch.head <head><eol>
Just bikeshedding, but ...
Show 17 quoted lines
> + if (!s->branch)
> + fprintf(s->fp, "# branch.head %s%c", "(unknown)", eol);
> + else {
> + if (!strcmp(s->branch, "HEAD")) {
> + fprintf(s->fp, "# branch.head %s%c", "(detached)", eol);
> +
> + if (state.rebase_in_progress || state.rebase_interactive_in_progress)
> + branch_name = state.onto;
> + else if (state.detached_from)
> + branch_name = state.detached_from;
> + else
> + branch_name = "";
> + } else {
> + branch_name = NULL;
> + skip_prefix(s->branch, "refs/heads/", &branch_name);
> +
> + fprintf(s->fp, "# branch.head %s%c", branch_name, eol);... given that we are showing branch name, perhaps "branch.name" instead of "branch.head" is more appropriate?
I wondered if "# " prefix before these lines is useful, by the way, and initially thought that the fact that these lines begin with "branch." and not with the "1/2/u $key" sufficient clue for whoever reads them, but the reader can tell which kind of record it is by reading the first two characters of each line (i.e. if "# " that is not the usual "change info for a single file"), so it is actually a good idea.
Thanks.