diff options
author | Pratik Karki <predatoramigo@gmail.com> | 2018-09-04 14:27:14 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-09-06 11:55:43 -0700 |
commit | e0333e5c63f347c5032fde05bddf711061e55e59 (patch) | |
tree | 4f50add2017576fcc2172dc64cec98bc58c78301 /builtin | |
parent | builtin rebase: support the `verbose` and `diffstat` options (diff) | |
download | tgif-e0333e5c63f347c5032fde05bddf711061e55e59.tar.xz |
builtin rebase: require a clean worktree
This commit reads the index of the repository for rebase and checks
whether the repository is ready for rebase.
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')
-rw-r--r-- | builtin/rebase.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c index 2d3f1d65fb..afef0b0046 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -19,6 +19,7 @@ #include "parse-options.h" #include "commit.h" #include "diff.h" +#include "wt-status.h" static char const * const builtin_rebase_usage[] = { N_("git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] " @@ -479,6 +480,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) die(_("Could not resolve HEAD to a revision")); } + if (read_index(the_repository->index) < 0) + die(_("could not read index")); + + if (require_clean_work_tree("rebase", + _("Please commit or stash them."), 1, 1)) { + ret = 1; + goto cleanup; + } + /* If a hook exists, give it a chance to interrupt*/ if (!ok_to_skip_pre_rebase && run_hook_le(NULL, "pre-rebase", options.upstream_arg, @@ -528,6 +538,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) ret = !!run_specific_rebase(&options); +cleanup: strbuf_release(&revisions); free(options.head_name); return ret; |