mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
sequencer: load commit related config
Load default values for message cleanup and gpg signing of commits in preparation for committing without forking 'git commit'. Note that we interpret commit.cleanup=scissors to mean COMMIT_MSG_CLEANUP_SPACE to be consistent with 'git commit' Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b34eeea352
commit
b36c590813
|
@ -9,6 +9,17 @@ static const char * const builtin_rebase_helper_usage[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static int git_rebase_helper_config(const char *k, const char *v, void *cb)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = git_sequencer_config(k, v, NULL);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return git_default_config(k, v, NULL);
|
||||
}
|
||||
|
||||
int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct replay_opts opts = REPLAY_OPTS_INIT;
|
||||
|
@ -39,7 +50,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
|
|||
OPT_END()
|
||||
};
|
||||
|
||||
git_config(git_default_config, NULL);
|
||||
git_config(git_rebase_helper_config, NULL);
|
||||
|
||||
opts.action = REPLAY_INTERACTIVE_REBASE;
|
||||
opts.allow_ff = 1;
|
||||
|
|
|
@ -31,6 +31,17 @@ static const char * const cherry_pick_usage[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
static int common_config(const char *k, const char *v, void *cb)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = git_sequencer_config(k, v, NULL);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
return git_default_config(k, v, NULL);
|
||||
}
|
||||
|
||||
static const char *action_name(const struct replay_opts *opts)
|
||||
{
|
||||
return opts->action == REPLAY_REVERT ? "revert" : "cherry-pick";
|
||||
|
@ -208,7 +219,7 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
|
|||
if (isatty(0))
|
||||
opts.edit = 1;
|
||||
opts.action = REPLAY_REVERT;
|
||||
git_config(git_default_config, NULL);
|
||||
git_config(common_config, NULL);
|
||||
res = run_sequencer(argc, argv, &opts);
|
||||
if (res < 0)
|
||||
die(_("revert failed"));
|
||||
|
@ -221,7 +232,7 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
|
|||
int res;
|
||||
|
||||
opts.action = REPLAY_PICK;
|
||||
git_config(git_default_config, NULL);
|
||||
git_config(common_config, NULL);
|
||||
res = run_sequencer(argc, argv, &opts);
|
||||
if (res < 0)
|
||||
die(_("cherry-pick failed"));
|
||||
|
|
34
sequencer.c
34
sequencer.c
|
@ -688,6 +688,40 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
|
|||
return run_command(&cmd);
|
||||
}
|
||||
|
||||
static enum commit_msg_cleanup_mode default_msg_cleanup =
|
||||
COMMIT_MSG_CLEANUP_NONE;
|
||||
static char *default_gpg_sign;
|
||||
|
||||
int git_sequencer_config(const char *k, const char *v, void *cb)
|
||||
{
|
||||
if (!strcmp(k, "commit.cleanup")) {
|
||||
int status;
|
||||
const char *s;
|
||||
|
||||
status = git_config_string(&s, k, v);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
if (!strcmp(s, "verbatim"))
|
||||
default_msg_cleanup = COMMIT_MSG_CLEANUP_NONE;
|
||||
else if (!strcmp(s, "whitespace"))
|
||||
default_msg_cleanup = COMMIT_MSG_CLEANUP_SPACE;
|
||||
else if (!strcmp(s, "strip"))
|
||||
default_msg_cleanup = COMMIT_MSG_CLEANUP_ALL;
|
||||
else if (!strcmp(s, "scissors"))
|
||||
default_msg_cleanup = COMMIT_MSG_CLEANUP_SPACE;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
if (!strcmp(k, "commit.gpgsign")) {
|
||||
default_gpg_sign = git_config_bool(k, v) ? "" : NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return git_gpg_config(k, v, NULL);
|
||||
}
|
||||
|
||||
static int rest_is_empty(const struct strbuf *sb, int start)
|
||||
{
|
||||
int i, eol;
|
||||
|
|
|
@ -57,6 +57,7 @@ extern const char sign_off_header[];
|
|||
|
||||
void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag);
|
||||
void append_conflicts_hint(struct strbuf *msgbuf);
|
||||
int git_sequencer_config(const char *k, const char *v, void *cb);
|
||||
|
||||
enum commit_msg_cleanup_mode {
|
||||
COMMIT_MSG_CLEANUP_SPACE,
|
||||
|
|
Loading…
Reference in a new issue