From: Fredrik Kuivinen Date: Fri, 17 Mar 2006 21:49:31 +0000 (+0100) Subject: blame: Fix git-blame X-Git-Tag: v1.3.0-rc1~21^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=53dc4636275c966bb0781709fd0dded1cced4458;p=git.git blame: Fix git-blame Before this patch git-blame gave non-sensible output. (It assigned blame to some random file in ) Abort with an error message instead. Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- diff --git a/blame.c b/blame.c index 8af4b5430..9c97aeca4 100644 --- a/blame.c +++ b/blame.c @@ -180,11 +180,13 @@ static int get_blob_sha1_internal(unsigned char *sha1, const char *base, unsigned mode, int stage); static unsigned char blob_sha1[20]; +static const char* blame_file; static int get_blob_sha1(struct tree *t, const char *pathname, unsigned char *sha1) { int i; const char *pathspec[2]; + blame_file = pathname; pathspec[0] = pathname; pathspec[1] = NULL; memset(blob_sha1, 0, sizeof(blob_sha1)); @@ -209,6 +211,10 @@ static int get_blob_sha1_internal(unsigned char *sha1, const char *base, if (S_ISDIR(mode)) return READ_TREE_RECURSIVE; + if (strncmp(blame_file, base, baselen) || + strcmp(blame_file + baselen, pathname)) + return -1; + memcpy(blob_sha1, sha1, 20); return -1; }