fast-import: add input format tests
[gitweb.git] / builtin / revert.c
index 2bb13ebb1de48e793e01d18ced29a468aa273b34..1f27c63343904a969e60ab19408495007f59d133 100644 (file)
@@ -76,7 +76,8 @@ static void parse_args(int argc, const char **argv)
        struct option options[] = {
                OPT_BOOLEAN('n', "no-commit", &no_commit, "don't automatically commit"),
                OPT_BOOLEAN('e', "edit", &edit, "edit the commit message"),
-               OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"),
+               { OPTION_BOOLEAN, 'r', NULL, &noop, NULL, "no-op (backward compatibility)",
+                 PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 0 },
                OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
                OPT_INTEGER('m', "mainline", &mainline, "parent number"),
                OPT_RERERE_AUTOUPDATE(&allow_rerere_auto),
@@ -407,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) {
@@ -466,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));
                }