diff options
author | Alban Gruin <alban.gruin@gmail.com> | 2018-08-28 14:10:41 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-29 13:38:18 -0700 |
commit | d59cd14de8e05111f45ad55a507493225cd849bc (patch) | |
tree | ba850f6e8b3c45b917293e3522352a10400727ef /builtin/rebase--helper.c | |
parent | rebase -i: rewrite write_basic_state() in C (diff) | |
download | tgif-d59cd14de8e05111f45ad55a507493225cd849bc.tar.xz |
rebase -i: rewrite init_basic_state() in C
This rewrites init_basic_state() from shell to C. The call to
write_basic_state() in cmd_rebase__helper() is replaced by a call to the
new function.
The shell version is then stripped from git-rebase--interactive.sh.
Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/rebase--helper.c')
-rw-r--r-- | builtin/rebase--helper.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/builtin/rebase--helper.c b/builtin/rebase--helper.c index 63c5086e42..f8128037d3 100644 --- a/builtin/rebase--helper.c +++ b/builtin/rebase--helper.c @@ -5,10 +5,13 @@ #include "sequencer.h" #include "rebase-interactive.h" #include "argv-array.h" +#include "refs.h" #include "rerere.h" #include "alias.h" +static GIT_PATH_FUNC(path_state_dir, "rebase-merge/") static GIT_PATH_FUNC(path_squash_onto, "rebase-merge/squash-onto") +static GIT_PATH_FUNC(path_interactive, "rebase-merge/interactive") static int get_revision_ranges(const char *upstream, const char *onto, const char **head_hash, @@ -44,6 +47,24 @@ static int get_revision_ranges(const char *upstream, const char *onto, return 0; } +static int init_basic_state(struct replay_opts *opts, const char *head_name, + const char *onto, const char *orig_head) +{ + FILE *interactive; + + if (!is_directory(path_state_dir()) && mkdir_in_gitdir(path_state_dir())) + return error_errno(_("could not create temporary %s"), path_state_dir()); + + delete_reflog("REBASE_HEAD"); + + interactive = fopen(path_interactive(), "w"); + if (!interactive) + return error_errno(_("could not mark as interactive")); + fclose(interactive); + + return write_basic_state(opts, head_name, onto, orig_head); +} + static const char * const builtin_rebase_helper_usage[] = { N_("git rebase--helper [<options>]"), NULL @@ -198,7 +219,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix) if (ret) return ret; - return !!write_basic_state(&opts, head_name, onto, head_hash); + return !!init_basic_state(&opts, head_name, onto, head_hash); } usage_with_options(builtin_rebase_helper_usage, options); |