Skip to content

Commit

Permalink
blame: Fix git-blame <directory>
Browse files Browse the repository at this point in the history
Before this patch git-blame <directory> gave non-sensible output. (It
assigned blame to some random file in <directory>) Abort with an error
message instead.

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Fredrik Kuivinen authored and Junio C Hamano committed Mar 17, 2006
1 parent 88a8b79 commit 53dc463
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
}
Expand Down

0 comments on commit 53dc463

Please sign in to comment.