@matheusbsbs / matheus-bagliano / commits / 45e2a4b2b0
Fork 0

Make "diff --check" output match "git apply"

For consistency, make the two tools report whitespace errors in the same way (the output of "diff --check" has been tweaked to match that of "git apply"). Note that although the textual content is basically the same only "git diff --check" provides a colorized version of the problematic lines; making "git apply" do colorization will require more extensive changes (figuring out the diff colorization preferences of the user) and so that will be a subject for another commit. Signed-off-by: Wincent Colaiuta <win@wincent.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Wincent Colaiuta committed Dec 13, 2007 at 14:32 UTC 45e2a4b2b0a07cda05dda08b47906100c4711e4e
2 files changed +3 -4
builtin-apply.c
+2 -2
@@ -912,8 +912,8 @@ static void check_whitespace(const char *line, int len, unsigned ws_rule)
912 ;
913 else {
914 err = whitespace_error_string(result);
915 - fprintf(stderr, "%s.\n%s:%d:%.*s\n",
916 - err, patch_input_file, linenr, len - 2, line + 1);
915 + fprintf(stderr, "%s:%d: %s.\n%.*s\n",
916 + patch_input_file, linenr, err, len - 2, line + 1);
917 free(err);
918 }
919 }
diff.c
+1 -2
@@ -973,8 +973,7 @@ static void checkdiff_consume(void *priv, char *line, unsigned long len)
973 if (!data->status)
974 return;
975 err = whitespace_error_string(data->status);
976 - printf("%s:%d: %s%s:%s ", data->filename, data->lineno,
977 - ws, err, reset);
976 + printf("%s:%d: %s.\n", data->filename, data->lineno, err);
977 free(err);
978 emit_line(set, reset, line, 1);
979 (void)check_and_emit_line(line + 1, len - 1, data->ws_rule,