@matheusbsbs / matheus-bagliano / commits / eb93b72406
Fork 0

git-blame: --show-name (and -f)

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>

Junio C Hamano committed Oct 5, 2006 at 14:06 UTC eb93b7240665e35ecc0ed72098e1a5b3352bdc17
1 file changed +9 -5
blame.c
+9 -5
@@ -752,7 +752,7 @@ int main(int argc, const char **argv)
752 const char *buf;
753 int max_digits;
754 int longest_file, longest_author;
755 - int found_rename;
755 + int show_name = 0;
756
757 const char *prefix = setup_git_directory();
758 git_config(git_default_config);
@@ -786,6 +786,11 @@ int main(int argc, const char **argv)
786 }
787 usage(blame_usage);
788 }
789 + if (!strcmp(argv[i], "-f") ||
790 + !strcmp(argv[i], "--show-name")) {
791 + show_name = 1;
792 + continue;
793 + }
794 if (!strcmp(argv[i], "--")) {
795 options = 0;
796 continue;
@@ -853,7 +858,6 @@ int main(int argc, const char **argv)
858
859 longest_file = 0;
860 longest_author = 0;
856 - found_rename = 0;
861 for (i = 0; i < num_blame_lines; i++) {
862 struct commit *c = blame_lines[i];
863 struct util_info *u;
@@ -861,8 +865,8 @@ int main(int argc, const char **argv)
865 c = initial;
866 u = c->util;
867
864 - if (!found_rename && strcmp(filename, u->pathname))
865 - found_rename = 1;
868 + if (!show_name && strcmp(filename, u->pathname))
869 + show_name = 1;
870 if (longest_file < strlen(u->pathname))
871 longest_file = strlen(u->pathname);
872 get_commit_info(c, &ci);
@@ -886,7 +890,7 @@ int main(int argc, const char **argv)
890 i+1);
891 }
892 else {
889 - if (found_rename)
893 + if (show_name)
894 printf(" %-*.*s", longest_file, longest_file,
895 u->pathname);
896 printf(" (%-*.*s %10s %*d) ",