{"thread":{"id":"7613","subject":"[PATCH 2/2] diff [--cached] HEAD: catch updates to the current branch behind your back.","startedAt":"2007-04-11T20:58:17Z","lastAt":"2007-04-11T20:58:17Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"39134","messageId":"7vabxeocgm.fsf@assigned-by-dhcp.cox.net","threadId":"7613","inReplyTo":null,"subject":"[PATCH 2/2] diff [--cached] HEAD: catch updates to the current branch behind your back.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-04-11T20:58:17Z","receivedAt":"2007-04-11T20:58:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This makes \"git-diff [--cached] HEAD\" issue a warning message\nwhen it detects that your index is not based on the tip of the\ncurrent branch (e.g. updated by gremlins running git-send-pack\nfrom elsewhere to update it, or from another working tree that\nshares the same $GIT_DIR/refs with your working tree).\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n * This is on top of 'next', which contains 'jc/checkout' aka\n   \"index base\" topic.\n\n diff-lib.c |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 5c5b05b..940c18a 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -657,6 +657,14 @@ int run_diff_index(struct rev_info *revs, int cached)\n \tconst char *tree_name;\n \tint match_missing = 0;\n \n+\t/* Check for gremlins */\n+\tif (active_cache_base_valid &&\n+\t    revs->pending.objects->item->type == OBJ_COMMIT &&\n+\t    revs->pending.objects->name &&\n+\t    !strcmp(revs->pending.objects->name, \"HEAD\") &&\n+\t    hashcmp(active_cache_base, revs->pending.objects->item->sha1))\n+\t\trevs->diffopt.warning = \"WARNING: HEAD and index BASE do not match\";\n+\n \t/* \n \t * Backward compatibility wart - \"diff-index -m\" does\n \t * not mean \"do not ignore merges\", but totally different.\n-- \n1.5.1.777.gd14d3\n"}]}