Skip to content

Commit

Permalink
git-blame: --show-name (and -f)
Browse files Browse the repository at this point in the history
The new option makes the command's native output format show the
filename even when there were no renames in its history, to make
it simpler for Porcelains to parse its output.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Oct 5, 2006
1 parent 506e49f commit eb93b72
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions blame.c
Expand Up @@ -752,7 +752,7 @@ int main(int argc, const char **argv)
const char *buf;
int max_digits;
int longest_file, longest_author;
int found_rename;
int show_name = 0;

const char *prefix = setup_git_directory();
git_config(git_default_config);
Expand Down Expand Up @@ -786,6 +786,11 @@ int main(int argc, const char **argv)
}
usage(blame_usage);
}
if (!strcmp(argv[i], "-f") ||
!strcmp(argv[i], "--show-name")) {
show_name = 1;
continue;
}
if (!strcmp(argv[i], "--")) {
options = 0;
continue;
Expand Down Expand Up @@ -853,16 +858,15 @@ int main(int argc, const char **argv)

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->util;

if (!found_rename && strcmp(filename, u->pathname))
found_rename = 1;
if (!show_name && strcmp(filename, u->pathname))
show_name = 1;
if (longest_file < strlen(u->pathname))
longest_file = strlen(u->pathname);
get_commit_info(c, &ci);
Expand All @@ -886,7 +890,7 @@ int main(int argc, const char **argv)
i+1);
}
else {
if (found_rename)
if (show_name)
printf(" %-*.*s", longest_file, longest_file,
u->pathname);
printf(" (%-*.*s %10s %*d) ",
Expand Down

0 comments on commit eb93b72

Please sign in to comment.