diff options
author | Fredrik Kuivinen <freku045@student.liu.se> | 2006-03-17 22:49:31 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-03-17 14:09:18 -0800 |
commit | 53dc4636275c966bb0781709fd0dded1cced4458 (patch) | |
tree | b280137789f91bf6e49a4f4b5ad408817dd1c476 /blame.c | |
parent | 88a8b7955666ed8fa5924fadbb3bb58984eaa6af (diff) | |
download | git-53dc4636275c966bb0781709fd0dded1cced4458.tar.gz git-53dc4636275c966bb0781709fd0dded1cced4458.tar.xz |
blame: Fix git-blame <directory>
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>
Diffstat (limited to 'blame.c')
-rw-r--r-- | blame.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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; } |