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

Re: [PATCH v2 4/5] format-patch: teach --no-base

From
Denton Liu <liu.denton@gmail.com>
Date
Nov 27, 2019, 19:56 UTC
Message-ID
<20191127195615.GA7413@generichostname>
In-Reply-To
<f7e5325cc0a7c29b62abe361e188c7cf9c59a9ca.1574878089.git.liu.denton@gmail.com>
On Wed, Nov 27, 2019 at 10:13:46AM -0800, Denton Liu wrote:
Show 70 quoted lines
> 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.
Show 23 quoted lines
>  		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
> 
Previous: Denton LiuNext: Denton Liu
Message 17 of 33 in “Bug with "git rebase" when format.useAutoBase is set”
  1. Christian BiesingerNov 26, 2019
  2. 0/5 rebase: fix breakage with `format.useAutoBase`Denton Liu, Nov 27, 2019
  3. 1/5 t3400: demonstrate failure with format.useAutoBaseDenton Liu, Nov 27, 2019
  4. Eric SunshineNov 27, 2019
  5. Junio C HamanoNov 30, 2019
  6. 2/5 format-patch: fix indentationDenton Liu, Nov 27, 2019
  7. 3/5 t4014: use `test_config`Denton Liu, Nov 27, 2019
  8. 4/5 format-patch: teach --no-baseDenton Liu, Nov 27, 2019
  9. 5/5 rebase: fix `format.useAutoBase` breakageDenton Liu, Nov 27, 2019
  10. Eric SunshineNov 27, 2019
  11. Christian BiesingerNov 27, 2019
  12. 0/5 rebase: fix breakage with `format.useAutoBase`Denton Liu, Nov 27, 2019
  13. 1/5 t3400: demonstrate failure with format.useAutoBaseDenton Liu, Nov 27, 2019
  14. 2/5 format-patch: fix indentationDenton Liu, Nov 27, 2019
  15. 3/5 t4014: use test_config()Denton Liu, Nov 27, 2019
  16. 4/5 format-patch: teach --no-baseDenton Liu, Nov 27, 2019
  17. Denton LiuNov 27, 2019
  18. 5/5 rebase: fix format.useAutoBase breakageDenton Liu, Nov 27, 2019
  19. Christian BiesingerDec 4, 2019
  20. 0/5 rebase: fix breakage with `format.useAutoBase`Denton Liu, Dec 4, 2019
  21. 1/5 t3400: demonstrate failure with format.useAutoBaseDenton Liu, Dec 4, 2019
  22. 2/5 format-patch: fix indentationDenton Liu, Dec 4, 2019
  23. 4/5 format-patch: teach --no-baseDenton Liu, Dec 4, 2019
  24. René ScharfeDec 4, 2019
  25. Junio C HamanoDec 4, 2019
  26. 3/5 t4014: use test_config()Denton Liu, Dec 4, 2019
  27. 5/5 rebase: fix format.useAutoBase breakageDenton Liu, Dec 4, 2019
  28. 0/5 rebase: fix breakage with `format.useAutoBase`Denton Liu, Dec 4, 2019
  29. 1/5 t3400: demonstrate failure with format.useAutoBaseDenton Liu, Dec 4, 2019
  30. 2/5 format-patch: fix indentationDenton Liu, Dec 4, 2019
  31. 3/5 t4014: use test_config()Denton Liu, Dec 4, 2019
  32. 4/5 format-patch: teach --no-baseDenton Liu, Dec 4, 2019
  33. 5/5 rebase: fix format.useAutoBase breakageDenton Liu, Dec 4, 2019

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.