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

Re: [PATCH v4 6/8] status: print branch info with --porcelain=v2 --branch

From
JHJeff Hostetler <git@jeffhostetler.com>
Date
Aug 5, 2016, 18:11 UTC
Message-ID
<57A4D6C4.3010501@jeffhostetler.com>
In-Reply-To
<xmqqd1lnxi99.fsf@gitster.mtv.corp.google.com>
On 08/05/2016 01:01 PM, Junio C Hamano wrote:
Show 31 quoted lines
> Jeff Hostetler <git@jeffhostetler.com> writes:
>
>>   /*
>> + * 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 ...
>
>> +	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?

Either way is fine with me. I just saw your comments on commit v4-7/8. And leaving it as is is fine.

Show 8 quoted lines
>
> 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.

Yes, I used the "#" prefix to indicate a header line so that parsers can always look at the first character and decide.

I set it up so the "--branch" argument creates "# branch.*" headers.

In my first patch series, I included worktree state information (such as in-a-rebase and the rebase step counts), but it was thought that that should be an independent effort. So, using this model, if we later do add a "--state" argument, it would create "# state.*" headers. And we would not have to change the --porcelain=v2 version number.

Jeff
Previous: Junio C HamanoNext: Jeff Hostetler
Message 12 of 31 in “status: V2 porcelain status”
  1. 0/8 status: V2 porcelain statusJeff Hostetler, Aug 2, 2016
  2. 2/8 status: cleanup API to wt_status_printJeff Hostetler, Aug 2, 2016
  3. Junio C HamanoAug 3, 2016
  4. Jeff HostetlerAug 4, 2016
  5. 3/8 status: support --porcelain[=<version>]Jeff Hostetler, Aug 2, 2016
  6. Junio C HamanoAug 3, 2016
  7. 8/8 status: tests for --porcelain=v2Jeff Hostetler, Aug 2, 2016
  8. Junio C HamanoAug 5, 2016
  9. Jeff HostetlerAug 5, 2016
  10. 6/8 status: print branch info with --porcelain=v2 --branchJeff Hostetler, Aug 2, 2016
  11. Junio C HamanoAug 5, 2016
  12. Jeff HostetlerAug 5, 2016
  13. 5/8 status: print per-file porcelain v2 status dataJeff Hostetler, Aug 2, 2016
  14. Jeff KingAug 5, 2016
  15. Junio C HamanoAug 5, 2016
  16. Jeff KingAug 5, 2016
  17. Junio C HamanoAug 5, 2016
  18. Stefan BellerAug 5, 2016
  19. Stefan BellerAug 5, 2016
  20. Jeff HostetlerAug 5, 2016
  21. 7/8 git-status.txt: describe --porcelain=v2 formatJeff Hostetler, Aug 2, 2016
  22. Junio C HamanoAug 5, 2016
  23. Jeff HostetlerAug 5, 2016
  24. 1/8 status: rename long-format print routinesJeff Hostetler, Aug 2, 2016
  25. Junio C HamanoAug 3, 2016
  26. Jeff HostetlerAug 4, 2016
  27. 4/8 status: per-file data collection for --porcelain=v2Jeff Hostetler, Aug 2, 2016
  28. Johannes SchindelinAug 3, 2016
  29. Junio C HamanoAug 3, 2016
  30. Johannes SchindelinAug 3, 2016
  31. Junio C HamanoAug 3, 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.