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

Re: [PATCH 1/2] status: really ignore config with --porcelain

From
Jeff King <peff@peff.net>
Date
Jun 28, 2013, 01:40 UTC
Message-ID
<20130628014011.GA620@sigill.intra.peff.net>
In-Reply-To
<7vk3lj9xwn.fsf@alter.siamese.dyndns.org>
On Mon, Jun 24, 2013 at 11:16:56AM -0700, Junio C Hamano wrote:
Show 19 quoted lines
> diff --git a/builtin/commit.c b/builtin/commit.c
> index 0da944f..a535eb2 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -111,12 +111,14 @@ static int show_ignored_in_status;
>  static const char *only_include_assumed;
>  static struct strbuf message = STRBUF_INIT;
>  
> -static enum {
> +static enum status_format {
>  	STATUS_FORMAT_NONE = 0,
>  	STATUS_FORMAT_LONG,
>  	STATUS_FORMAT_SHORT,
> -	STATUS_FORMAT_PORCELAIN
> -} status_format;
> +	STATUS_FORMAT_PORCELAIN,
> +
> +	STATUS_FORMAT_UNSPECIFIED
> +} status_format = STATUS_FORMAT_UNSPECIFIED;

I'm not sure why you need to add UNSPECIFIED here; the point of NONE is that no format had yet been specified.

It looks like the only difference is that finalize_deferred_config converts unspecified into NONE. But I think you can just use NONE for both cases, and drop this hunk:

Show 12 quoted lines
>  static int opt_parse_m(const struct option *opt, const char *arg, int unset)
>  {
> @@ -457,6 +459,9 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
>  	case STATUS_FORMAT_PORCELAIN:
>  		wt_porcelain_print(s);
>  		break;
> +	case STATUS_FORMAT_UNSPECIFIED:
> +		die("BUG: finalize_deferred_config() should have been called");
> +		break;
>  	case STATUS_FORMAT_NONE:
>  	case STATUS_FORMAT_LONG:
>  		wt_status_print(s);

You lose the assertion that finalize_deferred_config has been called, but I think the resulting code would be simpler, as it drops this die("BUG") state entirely. Am I missing something?

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 of 25 in “Fix serious regressions in latest master”
  1. 0/2 Fix serious regressions in latest masterRamkumar Ramachandra, Jun 24, 2013
  2. 1/2 status: really ignore config with --porcelainRamkumar Ramachandra, Jun 24, 2013
  3. Matthieu MoyJun 24, 2013
  4. Ramkumar RamachandraJun 24, 2013
  5. Matthieu MoyJun 24, 2013
  6. Junio C HamanoJun 24, 2013
  7. Matthieu MoyJun 24, 2013
  8. Junio C HamanoJun 24, 2013
  9. Matthieu MoyJun 24, 2013
  10. Junio C HamanoJun 24, 2013
  11. Ramkumar RamachandraJun 24, 2013
  12. Junio C HamanoJun 24, 2013
  13. Junio C HamanoJun 24, 2013
  14. Jeff KingJun 28, 2013
  15. Junio C HamanoJun 28, 2013
  16. Junio C HamanoJun 28, 2013
  17. Jeff KingJun 28, 2013
  18. Junio C HamanoJun 28, 2013
  19. Ramkumar RamachandraJun 24, 2013
  20. Junio C HamanoJun 24, 2013
  21. Matthieu MoyJun 24, 2013
  22. Ramkumar RamachandraJun 24, 2013
  23. 2/2 commit: make it work with status.shortRamkumar Ramachandra, Jun 24, 2013
  24. Junio C HamanoJun 24, 2013
  25. Ramkumar RamachandraJun 24, 2013

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.