public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Johannes Schindelin <johannes.schindelin@gmx•de>
Cc: git@vger•kernel.org, Sebastian Schuberth <sschuberth@gmail•com>
Subject: Re: [PATCH 2/3] sequencer: make commit options more extensible
Date: Wed, 22 Mar 2017 11:21:28 -0700	[thread overview]
Message-ID: <xmqqa88dkw9j.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <c0c836e1f1739af25ad875419ee6125b53ac6a1a.1490194846.git.johannes.schindelin@gmx.de> (Johannes Schindelin's message of "Wed, 22 Mar 2017 16:01:53 +0100 (CET)")

Johannes Schindelin <johannes.schindelin@gmx•de> writes:

> +#define ALLOW_EMPTY (1<<0)
> +#define EDIT_MSG    (1<<1)
> +#define AMEND_MSG   (1<<2)
> +#define CLEANUP_MSG (1<<3)

These being bits makes it clear that they can be independently set
and unset.

> @@ -615,8 +620,7 @@ N_("you have staged changes in your working tree\n"
>   * author metadata.
>   */
>  static int run_git_commit(const char *defmsg, struct replay_opts *opts,
> -			  int allow_empty, int edit, int amend,
> -			  int cleanup_commit_message)
> +			  int flags)

Use "unsigned" not signed integer for a collection of bits (see
e.g. GSoC microproject ideas page).

> @@ -1123,11 +1127,11 @@ static int do_pick_commit(enum todo_command command, struct commit *commit,
>  	if (allow < 0) {
>  		res = allow;
>  		goto leave;
> -	}
> +	} else if (allow)
> +		flags |= ALLOW_EMPTY;

;-)  Much more descriptive than just "allow".

>  static int commit_staged_changes(struct replay_opts *opts)
>  {
> -	int amend = 0;
> +	int flags = ALLOW_EMPTY | EDIT_MSG;
>  
>  	if (has_unstaged_changes(1))
>  		return error(_("cannot rebase: You have unstaged changes."));
> @@ -2184,10 +2188,10 @@ static int commit_staged_changes(struct replay_opts *opts)
>  				       "--continue' again."));
>  
>  		strbuf_release(&rev);
> -		amend = 1;
> +		flags |= AMEND_MSG;
>  	}
>  
> -	if (run_git_commit(rebase_path_message(), opts, 1, 1, amend, 0))
> +	if (run_git_commit(rebase_path_message(), opts, flags))

OK, the initialization of "flags" corresponds to these "1, 1" in the
original.

Overall, much easier to understand (and to extend).  Good
maintaintability clean-up.

Thanks.

  reply	other threads:[~2017-03-22 18:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 15:01 [PATCH 0/3] rebase -i (reword): call the commit-msg hook again Johannes Schindelin
2017-03-22 15:01 ` [PATCH 1/3] t7504: document regression: reword no longer calls commit-msg Johannes Schindelin
2017-03-22 15:18   ` Sebastian Schuberth
2017-03-22 16:09     ` Johannes Schindelin
2017-03-22 18:15       ` Junio C Hamano
2017-03-23 14:43         ` Johannes Schindelin
2017-03-23 14:55           ` Sebastian Schuberth
2017-03-23 15:52             ` Johannes Schindelin
2017-03-22 18:12     ` Junio C Hamano
2017-03-23 14:41       ` Johannes Schindelin
2017-03-22 15:01 ` [PATCH 2/3] sequencer: make commit options more extensible Johannes Schindelin
2017-03-22 18:21   ` Junio C Hamano [this message]
2017-03-23 14:39     ` Johannes Schindelin
2017-03-23 16:04   ` Junio C Hamano
2017-03-22 15:02 ` [PATCH 3/3] sequencer: allow the commit-msg hooks to run during a `reword` Johannes Schindelin
2017-03-22 18:43   ` Junio C Hamano
2017-03-23 15:49     ` Johannes Schindelin
2017-03-23 16:07 ` [PATCH v2 0/3] rebase -i (reword): call the commit-msg hook again Johannes Schindelin
2017-03-23 16:07   ` [PATCH v2 1/3] t7504: document regression: reword no longer calls commit-msg Johannes Schindelin
2017-03-23 16:07   ` [PATCH v2 2/3] sequencer: make commit options more extensible Johannes Schindelin
2017-03-24  1:01     ` Junio C Hamano
2017-03-25  0:01       ` Johannes Schindelin
2017-03-27  0:55         ` Junio C Hamano
2017-03-27 21:03           ` Junio C Hamano
2017-03-29 12:49             ` Johannes Schindelin
2017-03-23 16:07   ` [PATCH v2 3/3] sequencer: allow the commit-msg hooks to run during a `reword` Johannes Schindelin
2017-03-23 16:51     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa88dkw9j.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=johannes.schindelin@gmx$(echo .)de \
    --cc=sschuberth@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox