summaryrefslogtreecommitdiff
path: root/builtin-revert.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-01-20 14:42:59 -0800
committerJunio C Hamano <gitster@pobox.com>2010-01-20 14:42:59 -0800
commit71b3ef11fa0aade4a514c51b83438858a4a3c03b (patch)
tree6cea8215ecc0e70c8f19e04c51327deda93672d3 /builtin-revert.c
parentf922df8655675aafaea96f3715c9473c63d2ca47 (diff)
parentd38a30df7dd54c5c6883af1de1a03ec7d523cee5 (diff)
downloadgit-71b3ef11fa0aade4a514c51b83438858a4a3c03b.tar.gz
Merge branch 'mm/conflict-advice'
* mm/conflict-advice: Be more user-friendly when refusing to do something because of conflict. Conflicts: Documentation/config.txt advice.c advice.h
Diffstat (limited to 'builtin-revert.c')
-rw-r--r--builtin-revert.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/builtin-revert.c b/builtin-revert.c
index 857ca2eefa..8ac86f0943 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -235,6 +235,19 @@ static struct tree *empty_tree(void)
return tree;
}
+static NORETURN void die_dirty_index(const char *me)
+{
+ if (read_cache_unmerged()) {
+ die_resolve_conflict(me);
+ } else {
+ if (advice_commit_before_merge)
+ die("Your local changes would be overwritten by %s.\n"
+ "Please, commit your changes or stash them to proceed.", me);
+ else
+ die("Your local changes would be overwritten by %s.\n", me);
+ }
+}
+
static int revert_or_cherry_pick(int argc, const char **argv)
{
unsigned char head[20];
@@ -271,7 +284,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
if (get_sha1("HEAD", head))
die ("You do not have a valid HEAD");
if (index_differs_from("HEAD", 0))
- die ("Dirty index: cannot %s", me);
+ die_dirty_index(me);
}
discard_cache();