Skip to content

Commit 7998dbe

Browse files
prertikgitster
authored andcommitted
builtin rebase: support -C and --whitespace=<type>
This commit converts more code from the shell script version to the builtin rebase. In this instance, we just have to be careful to keep support for passing multiple `--whitespace` options, as the shell script version does so, too. Signed-off-by: Pratik Karki <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 12026a4 commit 7998dbe

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

builtin/rebase.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
574574
int ignore_date = 0;
575575
int ignore_whitespace = 0;
576576
const char *gpg_sign = NULL;
577+
int opt_c = -1;
578+
struct string_list whitespace = STRING_LIST_INIT_NODUP;
577579
struct option builtin_rebase_options[] = {
578580
OPT_STRING(0, "onto", &options.onto_name,
579581
N_("revision"),
@@ -641,6 +643,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
641643
{ OPTION_STRING, 'S', "gpg-sign", &gpg_sign, N_("key-id"),
642644
N_("GPG-sign commits"),
643645
PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
646+
OPT_STRING_LIST(0, "whitespace", &whitespace,
647+
N_("whitespace"), N_("passed to 'git apply'")),
648+
OPT_SET_INT('C', NULL, &opt_c, N_("passed to 'git apply'"),
649+
REBASE_AM),
644650
OPT_END(),
645651
};
646652

@@ -848,6 +854,23 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
848854
options.gpg_sign_opt = xstrfmt("-S%s", gpg_sign);
849855
}
850856

857+
if (opt_c >= 0)
858+
strbuf_addf(&options.git_am_opt, " -C%d", opt_c);
859+
860+
if (whitespace.nr) {
861+
int i;
862+
863+
for (i = 0; i < whitespace.nr; i++) {
864+
const char *item = whitespace.items[i].string;
865+
866+
strbuf_addf(&options.git_am_opt, " --whitespace=%s",
867+
item);
868+
869+
if ((!strcmp(item, "fix")) || (!strcmp(item, "strip")))
870+
options.flags |= REBASE_FORCE;
871+
}
872+
}
873+
851874
switch (options.type) {
852875
case REBASE_MERGE:
853876
case REBASE_INTERACTIVE:

0 commit comments

Comments
 (0)