Skip to content

Commit

Permalink
diff --cached: give more sensible error message when HEAD is yet to b…
Browse files Browse the repository at this point in the history
…e 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>
  • Loading branch information
Junio C Hamano committed Feb 25, 2007
1 parent 56cf980 commit 6c09c45
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 6c09c45

Please sign in to comment.