|
5 | 5 | #include "sequencer.h"
|
6 | 6 | #include "rebase-interactive.h"
|
7 | 7 | #include "argv-array.h"
|
| 8 | +#include "refs.h" |
8 | 9 | #include "rerere.h"
|
9 | 10 | #include "alias.h"
|
10 | 11 |
|
| 12 | +static GIT_PATH_FUNC(path_state_dir, "rebase-merge/") |
11 | 13 | static GIT_PATH_FUNC(path_squash_onto, "rebase-merge/squash-onto")
|
| 14 | +static GIT_PATH_FUNC(path_interactive, "rebase-merge/interactive") |
12 | 15 |
|
13 | 16 | static int get_revision_ranges(const char *upstream, const char *onto,
|
14 | 17 | const char **head_hash,
|
@@ -44,6 +47,24 @@ static int get_revision_ranges(const char *upstream, const char *onto,
|
44 | 47 | return 0;
|
45 | 48 | }
|
46 | 49 |
|
| 50 | +static int init_basic_state(struct replay_opts *opts, const char *head_name, |
| 51 | + const char *onto, const char *orig_head) |
| 52 | +{ |
| 53 | + FILE *interactive; |
| 54 | + |
| 55 | + if (!is_directory(path_state_dir()) && mkdir_in_gitdir(path_state_dir())) |
| 56 | + return error_errno(_("could not create temporary %s"), path_state_dir()); |
| 57 | + |
| 58 | + delete_reflog("REBASE_HEAD"); |
| 59 | + |
| 60 | + interactive = fopen(path_interactive(), "w"); |
| 61 | + if (!interactive) |
| 62 | + return error_errno(_("could not mark as interactive")); |
| 63 | + fclose(interactive); |
| 64 | + |
| 65 | + return write_basic_state(opts, head_name, onto, orig_head); |
| 66 | +} |
| 67 | + |
47 | 68 | static const char * const builtin_rebase_helper_usage[] = {
|
48 | 69 | N_("git rebase--helper [<options>]"),
|
49 | 70 | NULL
|
@@ -198,7 +219,7 @@ int cmd_rebase__helper(int argc, const char **argv, const char *prefix)
|
198 | 219 | if (ret)
|
199 | 220 | return ret;
|
200 | 221 |
|
201 |
| - return !!write_basic_state(&opts, head_name, onto, head_hash); |
| 222 | + return !!init_basic_state(&opts, head_name, onto, head_hash); |
202 | 223 | }
|
203 | 224 |
|
204 | 225 | usage_with_options(builtin_rebase_helper_usage, options);
|
|
0 commit comments