diff --cached: give more sensible error message when HEAD is yet to be created.
authorJunio C Hamano <junkio@cox.net>
Sun, 25 Feb 2007 06:26:33 +0000 (22:26 -0800)
committerJunio C Hamano <junkio@cox.net>
Sun, 25 Feb 2007 19:09:56 +0000 (11:09 -0800)
It is not like the user said 'diff --cached HEAD', so complaining about
HEAD not being a valid commit, while technically might be correct, is
not very helpful.

Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-diff.c
index c387ebb16c6bd353a84abd9454892eeab309ef1e..67f49329bf6bad1a5bf2592b1792b65421278708 100644 (file)
@@ -261,6 +261,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                                break;
                        else if (!strcmp(arg, "--cached")) {
                                add_head(&rev);
+                               if (!rev.pending.nr)
+                                       die("No HEAD commit to compare with (yet)");
                                break;
                        }
                }