|
|
|
@ -180,11 +180,13 @@ static int get_blob_sha1_internal(unsigned char *sha1, const char *base,
@@ -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,
@@ -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; |
|
|
|
|
} |
|
|
|
@ -742,6 +748,8 @@ int main(int argc, const char **argv)
@@ -742,6 +748,8 @@ int main(int argc, const char **argv)
|
|
|
|
|
struct commit_info ci; |
|
|
|
|
const char *buf; |
|
|
|
|
int max_digits; |
|
|
|
|
size_t longest_file, longest_author; |
|
|
|
|
int found_rename; |
|
|
|
|
|
|
|
|
|
const char* prefix = setup_git_directory(); |
|
|
|
|
|
|
|
|
@ -818,6 +826,25 @@ int main(int argc, const char **argv)
@@ -818,6 +826,25 @@ int main(int argc, const char **argv)
|
|
|
|
|
for (max_digits = 1, i = 10; i <= num_blame_lines + 1; max_digits++) |
|
|
|
|
i *= 10; |
|
|
|
|
|
|
|
|
|
longest_file = 0; |
|
|
|
|
longest_author = 0; |
|
|
|
|
found_rename = 0; |
|
|
|
|
for (i = 0; i < num_blame_lines; i++) { |
|
|
|
|
struct commit *c = blame_lines[i]; |
|
|
|
|
struct util_info* u; |
|
|
|
|
if (!c) |
|
|
|
|
c = initial; |
|
|
|
|
u = c->object.util; |
|
|
|
|
|
|
|
|
|
if (!found_rename && strcmp(filename, u->pathname)) |
|
|
|
|
found_rename = 1; |
|
|
|
|
if (longest_file < strlen(u->pathname)) |
|
|
|
|
longest_file = strlen(u->pathname); |
|
|
|
|
get_commit_info(c, &ci); |
|
|
|
|
if (longest_author < strlen(ci.author)) |
|
|
|
|
longest_author = strlen(ci.author); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (i = 0; i < num_blame_lines; i++) { |
|
|
|
|
struct commit *c = blame_lines[i]; |
|
|
|
|
struct util_info* u; |
|
|
|
@ -828,14 +855,18 @@ int main(int argc, const char **argv)
@@ -828,14 +855,18 @@ int main(int argc, const char **argv)
|
|
|
|
|
u = c->object.util; |
|
|
|
|
get_commit_info(c, &ci); |
|
|
|
|
fwrite(sha1_to_hex(c->object.sha1), sha1_len, 1, stdout); |
|
|
|
|
if(compability) |
|
|
|
|
if(compability) { |
|
|
|
|
printf("\t(%10s\t%10s\t%d)", ci.author, |
|
|
|
|
format_time(ci.author_time, ci.author_tz), i+1); |
|
|
|
|
else |
|
|
|
|
printf(" %s (%-15.15s %10s %*d) ", u->pathname, |
|
|
|
|
ci.author, format_time(ci.author_time, |
|
|
|
|
ci.author_tz), |
|
|
|
|
} else { |
|
|
|
|
if (found_rename) |
|
|
|
|
printf(" %-*.*s", longest_file, longest_file, |
|
|
|
|
u->pathname); |
|
|
|
|
printf(" (%-*.*s %10s %*d) ", |
|
|
|
|
longest_author, longest_author, ci.author, |
|
|
|
|
format_time(ci.author_time, ci.author_tz), |
|
|
|
|
max_digits, i+1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(i == num_blame_lines - 1) { |
|
|
|
|
fwrite(buf, blame_len - (buf - blame_contents), |
|
|
|
|