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

Re: [PATCH 2/4] am: convert "resume" variable to a struct

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 19, 2020, 19:19 UTC
Message-ID
<xmqqv9o2e66q.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20200219161352.13562-3-pbonzini@redhat.com>
pbonzini@redhat.com writes:
Show 41 quoted lines
> From: Paolo Bonzini <pbonzini@redhat.com>
>
> This will allow stashing the submode of --show-current-patch.  Using
> a struct will allow accessing both fields from outside cmd_am (through
> container_of).
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  builtin/am.c | 32 ++++++++++++++++++--------------
>  1 file changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/builtin/am.c b/builtin/am.c
> index 8181c2aef3..a89e1a96ed 100644
> --- a/builtin/am.c
> +++ b/builtin/am.c
> @@ -2118,7 +2118,7 @@ static int parse_opt_patchformat(const struct option *opt, const char *arg, int
>  	return 0;
>  }
>  
> -enum resume_mode {
> +enum resume_type {
>  	RESUME_FALSE = 0,
>  	RESUME_APPLY,
>  	RESUME_RESOLVED,
> @@ -2128,6 +2128,10 @@ enum resume_mode {
>  	RESUME_SHOW_PATCH
>  };
>  
> +struct resume_mode {
> +	enum resume_type mode;
> +};
> +
>  static int git_am_config(const char *k, const char *v, void *cb)
>  {
>  	int status;
> @@ -2145,7 +2149,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
>  	int binary = -1;
>  	int keep_cr = -1;
>  	int patch_format = PATCH_FORMAT_UNKNOWN;
> -	enum resume_mode resume = RESUME_FALSE;
> +	struct resume_mode resume = { . mode = RESUME_FALSE };

I do not think it makes a difference to compilers, but it seems that existing code spells this without SP between dot and the field name.

> +	struct resume_mode resume = { .mode = RESUME_FALSE };

The rest of the patch is quite straight-forward update that looks correct.

Thanks.
Previous: pbonzini@redhat.comNext: Paolo Bonzini
Message 8 of 15 in “am: provide a replacement for "cat .git/rebase-apply/patch"”
  1. 0/4 am: provide a replacement for "cat .git/rebase-apply/patch"pbonzini@redhat.com, Feb 19, 2020
  2. 1/4 parse-options: convert "command mode" to a flagpbonzini@redhat.com, Feb 19, 2020
  3. Eric SunshineFeb 19, 2020
  4. Johannes SchindelinFeb 20, 2020
  5. Junio C HamanoFeb 19, 2020
  6. Paolo BonziniFeb 19, 2020
  7. 2/4 am: convert "resume" variable to a structpbonzini@redhat.com, Feb 19, 2020
  8. Junio C HamanoFeb 19, 2020
  9. Paolo BonziniFeb 19, 2020
  10. 3/4 am: support --show-current-patch=raw as a synonym for--show-current-patchpbonzini@redhat.com, Feb 19, 2020
  11. Eric SunshineFeb 19, 2020
  12. Junio C HamanoFeb 19, 2020
  13. Paolo BonziniFeb 19, 2020
  14. 4/4 am: support --show-current-patch=diff to retrieve .git/rebase-apply/patchpbonzini@redhat.com, Feb 19, 2020
  15. Eric SunshineFeb 19, 2020

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.