wt-status.c: remove implicit dependency on the_index
[gitweb.git] / builtin / rebase.c
index cd6beb96b40f97027734fe2c5dd8bb89f86c7187..b9eb9584542bc9e1851c338e03991f055b58c947 100644 (file)
@@ -21,6 +21,7 @@
 #include "diff.h"
 #include "wt-status.h"
 #include "revision.h"
+#include "commit-reach.h"
 #include "rerere.h"
 
 static char const * const builtin_rebase_usage[] = {
@@ -252,6 +253,8 @@ static int apply_autostash(struct rebase_options *opts)
 
        if (read_one(path, &autostash))
                return error(_("Could not read '%s'"), path);
+       /* Ensure that the hash is not mistaken for a number */
+       strbuf_addstr(&autostash, "^0");
        argv_array_pushl(&stash_apply.args,
                         "stash", "apply", autostash.buf, NULL);
        stash_apply.git_cmd = 1;
@@ -686,7 +689,7 @@ static int can_fast_forward(struct commit *onto, struct object_id *head_oid,
        merge_bases = get_merge_bases(onto, head);
        if (merge_bases && !merge_bases->next) {
                oidcpy(merge_base, &merge_bases->item->object.oid);
-               res = !oidcmp(merge_base, &onto->object.oid);
+               res = oideq(merge_base, &onto->object.oid);
        } else {
                oidcpy(merge_base, &null_oid);
                res = 0;
@@ -980,7 +983,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                                             &lock_file);
                rollback_lock_file(&lock_file);
 
-               if (has_unstaged_changes(1)) {
+               if (has_unstaged_changes(the_repository, 1)) {
                        puts(_("You must edit all merge conflicts and then\n"
                               "mark them as resolved using git add"));
                        exit(1);
@@ -1215,15 +1218,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                 *       git-rebase.txt caveats with "unless you know what you are doing"
                 */
                if (options.rebase_merges)
-                       die(_("error: cannot combine '--preserve_merges' with "
+                       die(_("error: cannot combine '--preserve-merges' with "
                              "'--rebase-merges'"));
 
        if (options.rebase_merges) {
                if (strategy_options.nr)
-                       die(_("error: cannot combine '--rebase_merges' with "
+                       die(_("error: cannot combine '--rebase-merges' with "
                              "'--strategy-option'"));
                if (options.strategy)
-                       die(_("error: cannot combine '--rebase_merges' with "
+                       die(_("error: cannot combine '--rebase-merges' with "
                              "'--strategy'"));
        }
 
@@ -1348,7 +1351,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                        update_index_if_able(&the_index, &lock_file);
                rollback_lock_file(&lock_file);
 
-               if (has_unstaged_changes(0) || has_uncommitted_changes(0)) {
+               if (has_unstaged_changes(the_repository, 1) ||
+                   has_uncommitted_changes(the_repository, 1)) {
                        const char *autostash =
                                state_dir_path("autostash", &options);
                        struct child_process stash = CHILD_PROCESS_INIT;
@@ -1394,7 +1398,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
                }
        }
 
-       if (require_clean_work_tree("rebase",
+       if (require_clean_work_tree(the_repository, "rebase",
                                    _("Please commit or stash them."), 1, 1)) {
                ret = 1;
                goto cleanup;