{"thread":{"id":"5823","subject":"[PATCH 2/6] git-blame: --show-name (and -f)","startedAt":"2006-10-05T21:06:22Z","lastAt":"2006-10-05T21:06:22Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"28249","messageId":"7vmz8acw1d.fsf@assigned-by-dhcp.cox.net","threadId":"5823","inReplyTo":null,"subject":"[PATCH 2/6] git-blame: --show-name (and -f)","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-05T21:06:22Z","receivedAt":"2006-10-05T21:06:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The new option makes the command's native output format show the\nfilename even when there were no renames in its history, to make\nit simpler for Porcelains to parse its output.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n blame.c |   14 +++++++++-----\n 1 files changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/blame.c b/blame.c\nindex 394b5c3..d830b29 100644\n--- a/blame.c\n+++ b/blame.c\n@@ -752,7 +752,7 @@ int main(int argc, const char **argv)\n \tconst char *buf;\n \tint max_digits;\n \tint longest_file, longest_author;\n-\tint found_rename;\n+\tint show_name = 0;\n \n \tconst char *prefix = setup_git_directory();\n \tgit_config(git_default_config);\n@@ -786,6 +786,11 @@ int main(int argc, const char **argv)\n \t\t\t\t}\n \t\t\t\tusage(blame_usage);\n \t\t\t}\n+\t\t\tif (!strcmp(argv[i], \"-f\") ||\n+\t\t\t    !strcmp(argv[i], \"--show-name\")) {\n+\t\t\t\tshow_name = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(argv[i], \"--\")) {\n \t\t\t\toptions = 0;\n \t\t\t\tcontinue;\n@@ -853,7 +858,6 @@ int main(int argc, const char **argv)\n \n \tlongest_file = 0;\n \tlongest_author = 0;\n-\tfound_rename = 0;\n \tfor (i = 0; i < num_blame_lines; i++) {\n \t\tstruct commit *c = blame_lines[i];\n \t\tstruct util_info *u;\n@@ -861,8 +865,8 @@ int main(int argc, const char **argv)\n \t\t\tc = initial;\n \t\tu = c->util;\n \n-\t\tif (!found_rename && strcmp(filename, u->pathname))\n-\t\t\tfound_rename = 1;\n+\t\tif (!show_name && strcmp(filename, u->pathname))\n+\t\t\tshow_name = 1;\n \t\tif (longest_file < strlen(u->pathname))\n \t\t\tlongest_file = strlen(u->pathname);\n \t\tget_commit_info(c, &ci);\n@@ -886,7 +890,7 @@ int main(int argc, const char **argv)\n \t\t\t       i+1);\n \t\t}\n \t\telse {\n-\t\t\tif (found_rename)\n+\t\t\tif (show_name)\n \t\t\t\tprintf(\" %-*.*s\", longest_file, longest_file,\n \t\t\t\t       u->pathname);\n \t\t\tprintf(\" (%-*.*s %10s %*d) \",\n-- \n1.4.2.3.g866f3\n"}]}