X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-revert.c;h=d210150671830c10f098463175e5a6e8d304c1a4;hb=aa98eb3d6581a123852e4e080011acc3a61bc556;hp=d48313c7453c24e7ab4cbb3e024d05ec311edf7b;hpb=ae5a97fdd0c553926aabdf324b6d9108b0699bee;p=git.git diff --git a/builtin-revert.c b/builtin-revert.c index d48313c74..d21015067 100644 --- a/builtin-revert.c +++ b/builtin-revert.c @@ -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();