diff --cached: give more sensible error message when HEAD is yet to be created.
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>
Junio C Hamano committed
Feb 24, 2007 at 22:26 UTC
6c09c451389ade6477d98b05d277aab0dd2f272e
1 file changed
+2
builtin-diff.c
+2
@@ -261,6 +261,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
261
break;
262
else if (!strcmp(arg, "--cached")) {
263
add_head(&rev);
264
+ if (!rev.pending.nr)
265
+ die("No HEAD commit to compare with (yet)");
266
break;
267
}
268
}