From 75b62b489af7b62a5518c3f199d2a2776205e088 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 23 Feb 2007 05:20:32 +0100 Subject: git-diff: fix combined diff The code forgets that typecast binds tighter than addition, in other words: (cast *)array + i === ((cast *)array) + i Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-diff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'builtin-diff.c') diff --git a/builtin-diff.c b/builtin-diff.c index a6590205e8..c387ebb16c 100644 --- a/builtin-diff.c +++ b/builtin-diff.c @@ -192,7 +192,8 @@ static int builtin_diff_combined(struct rev_info *revs, parent = xmalloc(ents * sizeof(*parent)); /* Again, the revs are all reverse */ for (i = 0; i < ents; i++) - hashcpy((unsigned char*)parent + i, ent[ents - 1 - i].item->sha1); + hashcpy((unsigned char *)(parent + i), + ent[ents - 1 - i].item->sha1); diff_tree_combined(parent[0], parent + 1, ents - 1, revs->dense_combined_merges, revs); return 0; -- cgit v1.2.3 From 6c09c451389ade6477d98b05d277aab0dd2f272e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 24 Feb 2007 22:26:33 -0800 Subject: 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 --- builtin-diff.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'builtin-diff.c') diff --git a/builtin-diff.c b/builtin-diff.c index c387ebb16c..67f49329bf 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; } } -- cgit v1.2.3