X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-revert.c;h=3f2614e1bbef009afadefff7d284225533db2a09;hb=b60df87a6b39b3e9fc2fe81585a8bc55a502dcd3;hp=d48313c7453c24e7ab4cbb3e024d05ec311edf7b;hpb=5cb0f2745f83c01ee94d1739b7476504b4e20216;p=git.git diff --git a/builtin-revert.c b/builtin-revert.c index d48313c74..3f2614e1b 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(); @@ -387,6 +376,7 @@ static int revert_or_cherry_pick(int argc, const char **argv) (write_cache(index_fd, active_cache, active_nr) || commit_locked_index(&index_lock))) die("%s: Unable to write new index file", me); + rollback_lock_file(&index_lock); if (!clean) { add_to_msg("\nConflicts:\n\n");