From: "René Scharfe" <l.s.r@web.de>
To: Denton Liu <liu.denton@gmail.com>,
Git Mailing List <git@vger.kernel.org>
Cc: Christian Biesinger <cbiesinger@google.com>,
Eric Sunshine <sunshine@sunshineco.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v3 4/5] format-patch: teach --no-base
Date: Wed, 4 Dec 2019 11:36:25 +0100 [thread overview]
Message-ID: <3d355c0c-805a-a55d-eb4e-e4918585e30c@web.de> (raw)
In-Reply-To: <6cba51ca247423c76bda498152c162900aba1b59.1575445583.git.liu.denton@gmail.com>
Am 04.12.19 um 08:47 schrieb Denton Liu:
> 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`.
> diff --git a/builtin/log.c b/builtin/log.c
> index 9c44682f61..645d6db7cc 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,8 +1693,9 @@ 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")),
> OPT__QUIET(&quiet, N_("don't print the patch filenames")),
Clearing the global variable base_auto feels unclean to me, as does the
introduction of a callback for that purpose. Why not set base_commit
after reading the config and before parsing command line options to
reflect base_auto? That would achieve the intended precedence in a
simpler way, something like this:
diff --git a/builtin/log.c b/builtin/log.c
index a26f223ab4..af1b0d0209 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1714,6 +1714,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
rev.mime_boundary = default_attach;
rev.no_inline = 1;
}
+ if (base_auto)
+ base_commit = "auto";
/*
* Parse the arguments before setup_revisions(), or something
@@ -1973,7 +1975,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
}
memset(&bases, 0, sizeof(bases));
- if (base_commit || base_auto) {
+ if (base_commit) {
struct commit *base = get_base_commit(base_commit, list, nr);
reset_revision_walk();
clear_object_flags(UNINTERESTING);
next prev parent reply other threads:[~2019-12-04 10:36 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
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 [this message]
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=3d355c0c-805a-a55d-eb4e-e4918585e30c@web.de \
--to=l.s.r@web.de \
--cc=cbiesinger@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=liu.denton@gmail.com \
--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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).