git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Christian Biesinger <cbiesinger@google.com>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v2 4/5] format-patch: teach --no-base
Date: Wed, 27 Nov 2019 11:56:15 -0800
Message-ID: <20191127195615.GA7413@generichostname> (raw)
In-Reply-To: <f7e5325cc0a7c29b62abe361e188c7cf9c59a9ca.1574878089.git.liu.denton@gmail.com>

On Wed, Nov 27, 2019 at 10:13:46AM -0800, Denton Liu wrote:
> If `format.useAutoBase = true`, there was no way to override this from
> the command-line. Teach format-patch the `--no-base` option which
> overrides `format.useAutoBase`.
> 
> Signed-off-by: Denton Liu <liu.denton@gmail.com>
> ---
>  Documentation/git-format-patch.txt |  5 +++--
>  builtin/log.c                      | 24 +++++++++++++++++++++---
>  t/t4014-format-patch.sh            |  6 ++++++
>  3 files changed, 30 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
> index 00bdf9b125..0d4f8951bb 100644
> --- a/Documentation/git-format-patch.txt
> +++ b/Documentation/git-format-patch.txt
> @@ -333,11 +333,12 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
>    Output an all-zero hash in each patch's From header instead
>    of the hash of the commit.
>  
> ---base=<commit>::
> +--[no-]base[=<commit>]::
>  	Record the base tree information to identify the state the
>  	patch series applies to.  See the BASE TREE INFORMATION section
>  	below for details. If <commit> is "auto", a base commit is
> -	automatically chosen.
> +	automatically chosen. The `--no-base` option overrides a
> +	`format.useAutoBase` configuration.
>  
>  --root::
>  	Treat the revision argument as a <revision range>, even if it
> diff --git a/builtin/log.c b/builtin/log.c
> index 9c44682f61..c017df4056 100644
> --- a/builtin/log.c
> +++ b/builtin/log.c
> @@ -1388,6 +1388,23 @@ static int from_callback(const struct option *opt, const char *arg, int unset)
>  	return 0;
>  }
>  
> +static int base_callback(const struct option *opt, const char *arg, int unset)
> +{
> +	char **base_commit = opt->value;
> +
> +	free(*base_commit);
> +
> +	if (unset) {
> +		base_auto = 0;
> +		*base_commit = NULL;
> +	} else if (arg) {
> +		*base_commit = xstrdup(arg);
> +	} else {
> +		BUG("arg is NULL");
> +	}
> +	return 0;
> +}
> +
>  struct base_tree_info {
>  	struct object_id base_commit;
>  	int nr_patch_id, alloc_patch_id;
> @@ -1676,10 +1693,11 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
>  			    PARSE_OPT_OPTARG, thread_callback },
>  		OPT_STRING(0, "signature", &signature, N_("signature"),
>  			    N_("add a signature")),
> -		OPT_STRING(0, "base", &base_commit, N_("base-commit"),
> -			   N_("add prerequisite tree info to the patch series")),
> +		{ OPTION_CALLBACK, 0, "base", &base_commit, N_("base-commit"),
> +			   N_("add prerequisite tree info to the patch series"),
> +			   0, base_callback },
>  		OPT_FILENAME(0, "signature-file", &signature_file,
> -				N_("add a signature from a file")),
> +			N_("add a signature from a file")),

Oops, this is reindentation is a spurious change and should be dropped.

>  		OPT__QUIET(&quiet, N_("don't print the patch filenames")),
>  		OPT_BOOL(0, "progress", &show_progress,
>  			 N_("show progress while generating patches")),
> diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
> index c7cc643adf..a5b6302a1c 100755
> --- a/t/t4014-format-patch.sh
> +++ b/t/t4014-format-patch.sh
> @@ -1958,6 +1958,12 @@ test_expect_success 'format-patch --base overrides format.useAutoBase' '
>  	test_cmp expect actual
>  '
>  
> +test_expect_success 'format-patch --no-base overrides format.useAutoBase' '
> +	test_config format.useAutoBase true &&
> +	git format-patch --stdout --no-base -1 >patch &&
> +	! grep "^base-commit:" patch
> +'
> +
>  test_expect_success 'format-patch --base with --attach' '
>  	git format-patch --attach=mimemime --stdout --base=HEAD~ -1 >patch &&
>  	sed -n -e "/^base-commit:/s/.*/1/p" -e "/^---*mimemime--$/s/.*/2/p" \
> -- 
> 2.24.0.504.g3cd56eb17d
> 

  reply	other threads:[~2019-11-27 19:56 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26 20:50 Bug with "git rebase" when format.useAutoBase is set Christian Biesinger
2019-11-27  2:09 ` [PATCH 0/5] rebase: fix breakage with `format.useAutoBase` Denton Liu
2019-11-27  2:09   ` [PATCH 1/5] t3400: demonstrate failure with format.useAutoBase Denton Liu
2019-11-27  2:26     ` Eric Sunshine
2019-11-30 17:25       ` Junio C Hamano
2019-11-27  2:09   ` [PATCH 2/5] format-patch: fix indentation Denton Liu
2019-11-27  2:09   ` [PATCH 3/5] t4014: use `test_config` Denton Liu
2019-11-27  2:09   ` [PATCH 4/5] format-patch: teach --no-base Denton Liu
2019-11-27  2:09   ` [PATCH 5/5] rebase: fix `format.useAutoBase` breakage Denton Liu
2019-11-27  2:42     ` Eric Sunshine
2019-11-27 17:14   ` [PATCH 0/5] rebase: fix breakage with `format.useAutoBase` Christian Biesinger
2019-11-27 18:13   ` [PATCH v2 " Denton Liu
2019-11-27 18:13     ` [PATCH v2 1/5] t3400: demonstrate failure with format.useAutoBase Denton Liu
2019-11-27 18:13     ` [PATCH v2 2/5] format-patch: fix indentation Denton Liu
2019-11-27 18:13     ` [PATCH v2 3/5] t4014: use test_config() Denton Liu
2019-11-27 18:13     ` [PATCH v2 4/5] format-patch: teach --no-base Denton Liu
2019-11-27 19:56       ` Denton Liu [this message]
2019-11-27 18:13     ` [PATCH v2 5/5] rebase: fix format.useAutoBase breakage Denton Liu
2019-12-04 16:21       ` Christian Biesinger
2019-12-04  7:47     ` [PATCH v3 0/5] rebase: fix breakage with `format.useAutoBase` Denton Liu
2019-12-04  7:47       ` [PATCH v3 1/5] t3400: demonstrate failure with format.useAutoBase Denton Liu
2019-12-04  7:47       ` [PATCH v3 2/5] format-patch: fix indentation Denton Liu
2019-12-04  7:47       ` [PATCH v3 3/5] t4014: use test_config() Denton Liu
2019-12-04  7:47       ` [PATCH v3 4/5] format-patch: teach --no-base Denton Liu
2019-12-04 10:36         ` René Scharfe
2019-12-04 17:26           ` Junio C Hamano
2019-12-04  7:48       ` [PATCH v3 5/5] rebase: fix format.useAutoBase breakage Denton Liu
2019-12-04 21:24       ` [PATCH v4 0/5] rebase: fix breakage with `format.useAutoBase` Denton Liu
2019-12-04 21:24         ` [PATCH v4 1/5] t3400: demonstrate failure with format.useAutoBase Denton Liu
2019-12-04 21:24         ` [PATCH v4 2/5] format-patch: fix indentation Denton Liu
2019-12-04 21:25         ` [PATCH v4 3/5] t4014: use test_config() Denton Liu
2019-12-04 21:25         ` [PATCH v4 4/5] format-patch: teach --no-base Denton Liu
2019-12-04 21:25         ` [PATCH v4 5/5] rebase: fix format.useAutoBase breakage Denton Liu

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20191127195615.GA7413@generichostname \
    --to=liu.denton@gmail.com \
    --cc=cbiesinger@google.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git