[PATCH 2/4] Tweak diff output further to make it a bit less distracting.
- From
Junio C Hamano <junkio@cox.net>
- Date
- May 15, 2005, 21:19 UTC
- Message-ID
- <7vvf5kqj9l.fsf@assigned-by-dhcp.cox.net>
Adds an newline between each diff. Also change "#mode : " string, which was misleading in that we are not showing just mode when we talk about a file changing into a symlink.
Signed-off-by: Junio C Hamano <junkio@cox.net> ---
diff.c | 18 ++++++++++-------- t/t4000-diff-format.sh | 6 ++++-- 2 files changed, 14 insertions(+), 10 deletions(-)
--- a/diff.c +++ b/diff.c @@ -83,7 +83,7 @@ struct diff_tempfile *temp) { int i, next_at; - const char *git_prefix = "# mode: "; + const char *git_prefix = "\n@. "; const char *diff_cmd = "diff -L'%s%s' -L'%s%s'"; const char *diff_arg = "'%s' '%s'||:"; /* "||:" is to return 0 */ const char *input_name_sq[2]; @@ -128,15 +128,17 @@ else if (!path1[1][0]) printf("%s%s . %s\n", git_prefix, temp[0].mode, name); else { - if (strcmp(temp[0].mode, temp[1].mode)) + if (strcmp(temp[0].mode, temp[1].mode)) { printf("%s%s %s %s\n", git_prefix, temp[0].mode, temp[1].mode, name); - - if (strncmp(temp[0].mode, temp[1].mode, 3)) - /* we do not run diff between different kind - * of objects. - */ - exit(0); + if (strncmp(temp[0].mode, temp[1].mode, 3)) + /* we do not run diff between different kind + * of objects. + */ + exit(0); + } + else + putchar('\n'); } fflush(NULL); execlp("/bin/sh","sh", "-c", cmd, NULL); --- a/t/t4000-diff-format.sh +++ b/t/t4000-diff-format.sh @@ -26,7 +26,8 @@ 'git-diff-files -p after editing work tree.' \ 'git-diff-files -p >current' cat >expected <<\EOF -# mode: 100644 100755 path0 + +@. 100644 100755 path0 --- a/path0 +++ b/path0 @@ -1,3 +1,3 @@ @@ -34,7 +35,8 @@ Line 2 -line 3 +Line 3 -# mode: 100755 . path1 + +@. 100755 . path1 --- a/path1 +++ /dev/null @@ -1,3 +0,0 @@