diff options
author | Jeff King <peff@peff.net> | 2011-05-12 07:09:55 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-05-16 13:01:45 -0700 |
commit | fad2652673247203014e2c57622a5ffe0eb5ad93 (patch) | |
tree | 93d8abf58386f96d67452fade9107224d024c8d5 /builtin/revert.c | |
parent | 161807349aa1ee853880a5c6e39c53f55b10077d (diff) | |
download | git-fad2652673247203014e2c57622a5ffe0eb5ad93.tar.gz git-fad2652673247203014e2c57622a5ffe0eb5ad93.tar.xz |
revert: allow reverting a root commit
Although it is probably an uncommon operation, there is no
reason to disallow it, as it works just fine. It is the
reverse of a cherry-pick of a root commit, which is already
allowed.
We do have to tweak one check on whether we have a merge
commit, which assumed we had at least one parent.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/revert.c')
-rw-r--r-- | builtin/revert.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/builtin/revert.c b/builtin/revert.c index f697e6695..1f27c6334 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -408,8 +408,6 @@ static int do_pick_commit(void) discard_cache(); if (!commit->parents) { - if (action == REVERT) - die (_("Cannot revert a root commit")); parent = NULL; } else if (commit->parents->next) { @@ -467,7 +465,7 @@ static int do_pick_commit(void) strbuf_addstr(&msgbuf, "\"\n\nThis reverts commit "); strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1)); - if (commit->parents->next) { + if (commit->parents && commit->parents->next) { strbuf_addstr(&msgbuf, ", reversing\nchanges made to "); strbuf_addstr(&msgbuf, sha1_to_hex(parent->object.sha1)); } |