summaryrefslogtreecommitdiff
path: root/builtin/rebase.c
diff options
context:
space:
mode:
authorLibravatar Pratik Karki <predatoramigo@gmail.com>2018-09-04 15:00:01 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-10-11 14:12:42 +0900
commit7998dbe1ec40faffb429386d1c0971d4350a97eb (patch)
tree4f4161a66712e78bf1b10797c509c980917dfd9c /builtin/rebase.c
parentbuiltin rebase: support `--gpg-sign` option (diff)
downloadtgif-7998dbe1ec40faffb429386d1c0971d4350a97eb.tar.xz
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 <predatoramigo@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase.c')
-rw-r--r--builtin/rebase.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 23a5bb3003..c2f28cdd9e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -574,6 +574,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
int ignore_date = 0;
int ignore_whitespace = 0;
const char *gpg_sign = NULL;
+ int opt_c = -1;
+ struct string_list whitespace = STRING_LIST_INIT_NODUP;
struct option builtin_rebase_options[] = {
OPT_STRING(0, "onto", &options.onto_name,
N_("revision"),
@@ -641,6 +643,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
{ OPTION_STRING, 'S', "gpg-sign", &gpg_sign, N_("key-id"),
N_("GPG-sign commits"),
PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
+ OPT_STRING_LIST(0, "whitespace", &whitespace,
+ N_("whitespace"), N_("passed to 'git apply'")),
+ OPT_SET_INT('C', NULL, &opt_c, N_("passed to 'git apply'"),
+ REBASE_AM),
OPT_END(),
};
@@ -848,6 +854,23 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
options.gpg_sign_opt = xstrfmt("-S%s", gpg_sign);
}
+ if (opt_c >= 0)
+ strbuf_addf(&options.git_am_opt, " -C%d", opt_c);
+
+ if (whitespace.nr) {
+ int i;
+
+ for (i = 0; i < whitespace.nr; i++) {
+ const char *item = whitespace.items[i].string;
+
+ strbuf_addf(&options.git_am_opt, " --whitespace=%s",
+ item);
+
+ if ((!strcmp(item, "fix")) || (!strcmp(item, "strip")))
+ options.flags |= REBASE_FORCE;
+ }
+ }
+
switch (options.type) {
case REBASE_MERGE:
case REBASE_INTERACTIVE: