Code

cvsimport: add test illustrating a bug in cvsps
[git.git] / builtin-revert.c
index 4038b4118da087069db82bfcf6e0dd298aec9036..d210150671830c10f098463175e5a6e8d304c1a4 100644 (file)
@@ -223,17 +223,6 @@ static char *help_msg(const unsigned char *sha1)
        return helpbuf;
 }
 
-static int index_is_dirty(void)
-{
-       struct rev_info rev;
-       init_revisions(&rev, NULL);
-       setup_revisions(0, NULL, &rev, "HEAD");
-       DIFF_OPT_SET(&rev.diffopt, QUIET);
-       DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
-       run_diff_index(&rev, 1);
-       return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
-}
-
 static struct tree *empty_tree(void)
 {
        struct tree *tree = xcalloc(1, sizeof(struct tree));
@@ -279,7 +268,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        } else {
                if (get_sha1("HEAD", head))
                        die ("You do not have a valid HEAD");
-               if (index_is_dirty())
+               if (index_differs_from("HEAD", 0))
                        die ("Dirty index: cannot %s", me);
        }
        discard_cache();
@@ -352,6 +341,11 @@ static int revert_or_cherry_pick(int argc, const char **argv)
                add_to_msg(oneline_body + 1);
                add_to_msg("\"\n\nThis reverts commit ");
                add_to_msg(sha1_to_hex(commit->object.sha1));
+
+               if (commit->parents->next) {
+                       add_to_msg(", reversing\nchanges made to ");
+                       add_to_msg(sha1_to_hex(parent->object.sha1));
+               }
                add_to_msg(".\n");
        } else {
                base = parent;