summaryrefslogtreecommitdiff
path: root/ws.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-06-26 15:36:59 -0700
committerJunio C Hamano <gitster@pobox.com>2008-06-26 22:07:26 -0700
commit877f23ccb88227203f2576abdfb5d1c15925fcb3 (patch)
tree6d54619f825b9e489f90928f9f7af670cc0a4cb8 /ws.c
parent1ba111d1d6bd90b2c120ceb05418e01ee304cc46 (diff)
downloadgit-877f23ccb88227203f2576abdfb5d1c15925fcb3.tar.gz
Teach "diff --check" about new blank lines at end
When a patch adds new blank lines at the end, "git apply --whitespace" warns. This teaches "diff --check" to do the same. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ws.c')
-rw-r--r--ws.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/ws.c b/ws.c
index 24d3e3de07..7a7ff130a3 100644
--- a/ws.c
+++ b/ws.c
@@ -225,6 +225,21 @@ unsigned ws_check(const char *line, int len, unsigned ws_rule)
return ws_check_emit_1(line, len, ws_rule, NULL, NULL, NULL, NULL);
}
+int ws_blank_line(const char *line, int len, unsigned ws_rule)
+{
+ /*
+ * We _might_ want to treat CR differently from other
+ * whitespace characters when ws_rule has WS_CR_AT_EOL, but
+ * for now we just use this stupid definition.
+ */
+ while (len-- > 0) {
+ if (!isspace(*line))
+ return 0;
+ line++;
+ }
+ return 1;
+}
+
/* Copy the line to the buffer while fixing whitespaces */
int ws_fix_copy(char *dst, const char *src, int len, unsigned ws_rule, int *error_count)
{