From: Junio C Hamano Date: Sun, 25 Feb 2007 06:26:33 +0000 (-0800) Subject: diff --cached: give more sensible error message when HEAD is yet to be created. X-Git-Tag: v1.5.1-rc1~131 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6c09c451389ade6477d98b05d277aab0dd2f272e;p=git.git 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 --- diff --git a/builtin-diff.c b/builtin-diff.c index c387ebb16..67f49329b 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -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; } }