mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
builtin rebase: support keep-empty
option
The `--keep-empty` option can be used to keep the commits that do not change anything from its parents in the result. While the scripted version uses `interactive_rebase=implied` to indicate that the rebase needs to use the `git-rebase--interactive` backend in non-interactive mode as fallback when figuring out which backend to use, the C version needs to use a different route because the backend will already be chosen during the `parse_options()` call. Signed-off-by: Pratik Karki <predatoramigo@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
53f9e5be94
commit
002ee2fe68
|
@ -95,6 +95,7 @@ struct rebase_options {
|
|||
const char *action;
|
||||
int signoff;
|
||||
int allow_rerere_autoupdate;
|
||||
int keep_empty;
|
||||
};
|
||||
|
||||
static int is_interactive(struct rebase_options *opts)
|
||||
|
@ -103,6 +104,23 @@ static int is_interactive(struct rebase_options *opts)
|
|||
opts->type == REBASE_PRESERVE_MERGES;
|
||||
}
|
||||
|
||||
static void imply_interactive(struct rebase_options *opts, const char *option)
|
||||
{
|
||||
switch (opts->type) {
|
||||
case REBASE_AM:
|
||||
die(_("%s requires an interactive rebase"), option);
|
||||
break;
|
||||
case REBASE_INTERACTIVE:
|
||||
case REBASE_PRESERVE_MERGES:
|
||||
break;
|
||||
case REBASE_MERGE:
|
||||
/* we silently *upgrade* --merge to --interactive if needed */
|
||||
default:
|
||||
opts->type = REBASE_INTERACTIVE; /* implied */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns the filename prefixed by the state_dir */
|
||||
static const char *state_dir_path(const char *filename, struct rebase_options *opts)
|
||||
{
|
||||
|
@ -276,6 +294,7 @@ static int run_specific_rebase(struct rebase_options *opts)
|
|||
opts->allow_rerere_autoupdate < 0 ? "" :
|
||||
opts->allow_rerere_autoupdate ?
|
||||
"--rerere-autoupdate" : "--no-rerere-autoupdate");
|
||||
add_var(&script_snippet, "keep_empty", opts->keep_empty ? "yes" : "");
|
||||
|
||||
switch (opts->type) {
|
||||
case REBASE_AM:
|
||||
|
@ -588,6 +607,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||
&options.allow_rerere_autoupdate,
|
||||
N_("allow rerere to update index with resolved "
|
||||
"conflict")),
|
||||
OPT_BOOL('k', "keep-empty", &options.keep_empty,
|
||||
N_("preserve empty commits during rebase")),
|
||||
OPT_END(),
|
||||
};
|
||||
|
||||
|
@ -787,6 +808,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
|
|||
options.flags |= REBASE_FORCE;
|
||||
}
|
||||
|
||||
if (options.keep_empty)
|
||||
imply_interactive(&options, "--keep-empty");
|
||||
|
||||
switch (options.type) {
|
||||
case REBASE_MERGE:
|
||||
case REBASE_INTERACTIVE:
|
||||
|
|
Loading…
Reference in a new issue