diff --git a/apply.c b/apply.c index 43a0aebf4eec85..509f080809af75 100644 --- a/apply.c +++ b/apply.c @@ -22,6 +22,7 @@ #include "rerere.h" #include "apply.h" #include "entry.h" +#include "ws.h" struct gitdiff_data { struct strbuf *root; diff --git a/cache.h b/cache.h index eba12487b99caa..59b9c576d98fc2 100644 --- a/cache.h +++ b/cache.h @@ -1800,32 +1800,6 @@ extern int diff_auto_refresh_index; void shift_tree(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, int); void shift_tree_by(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, const char *); -/* - * whitespace rules. - * used by both diff and apply - * last two digits are tab width - */ -#define WS_BLANK_AT_EOL 0100 -#define WS_SPACE_BEFORE_TAB 0200 -#define WS_INDENT_WITH_NON_TAB 0400 -#define WS_CR_AT_EOL 01000 -#define WS_BLANK_AT_EOF 02000 -#define WS_TAB_IN_INDENT 04000 -#define WS_TRAILING_SPACE (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF) -#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8) -#define WS_TAB_WIDTH_MASK 077 -/* All WS_* -- when extended, adapt diff.c emit_symbol */ -#define WS_RULE_MASK 07777 -extern unsigned whitespace_rule_cfg; -unsigned whitespace_rule(struct index_state *, const char *); -unsigned parse_whitespace_rule(const char *); -unsigned ws_check(const char *line, int len, unsigned ws_rule); -void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws); -char *whitespace_error_string(unsigned ws); -void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *); -int ws_blank_line(const char *line, int len, unsigned ws_rule); -#define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK) - /* ls-files */ void overlay_tree_on_index(struct index_state *istate, const char *tree_name, const char *prefix); diff --git a/config.c b/config.c index c5873f3a70643a..67cd66e33ca78c 100644 --- a/config.c +++ b/config.c @@ -21,6 +21,7 @@ #include "dir.h" #include "color.h" #include "refs.h" +#include "ws.h" struct config_source { struct config_source *prev; diff --git a/diff.c b/diff.c index 861282db1c3283..5b123758fca64d 100644 --- a/diff.c +++ b/diff.c @@ -27,6 +27,7 @@ #include "help.h" #include "promisor-remote.h" #include "dir.h" +#include "ws.h" #ifdef NO_FAST_WORKING_DIRECTORY #define FAST_WORKING_DIRECTORY 0 diff --git a/environment.c b/environment.c index 9da7f3c1a19ee5..d7cbea26f82cc2 100644 --- a/environment.c +++ b/environment.c @@ -19,6 +19,7 @@ #include "object-store.h" #include "chdir-notify.h" #include "shallow.h" +#include "ws.h" int trust_executable_bit = 1; int trust_ctime = 1; diff --git a/ws.c b/ws.c index 6e69877f257916..bbb5f71e21e3d3 100644 --- a/ws.c +++ b/ws.c @@ -4,6 +4,7 @@ * Copyright (c) 2007 Junio C Hamano */ #include "cache.h" +#include "ws.h" #include "attr.h" static struct whitespace_rule { diff --git a/ws.h b/ws.h new file mode 100644 index 00000000000000..fcaac979288f49 --- /dev/null +++ b/ws.h @@ -0,0 +1,30 @@ +#ifndef WS_H +#define WS_H + +/* + * whitespace rules. + * used by both diff and apply + * last two digits are tab width + */ +#define WS_BLANK_AT_EOL 0100 +#define WS_SPACE_BEFORE_TAB 0200 +#define WS_INDENT_WITH_NON_TAB 0400 +#define WS_CR_AT_EOL 01000 +#define WS_BLANK_AT_EOF 02000 +#define WS_TAB_IN_INDENT 04000 +#define WS_TRAILING_SPACE (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF) +#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8) +#define WS_TAB_WIDTH_MASK 077 +/* All WS_* -- when extended, adapt diff.c emit_symbol */ +#define WS_RULE_MASK 07777 +extern unsigned whitespace_rule_cfg; +unsigned whitespace_rule(struct index_state *, const char *); +unsigned parse_whitespace_rule(const char *); +unsigned ws_check(const char *line, int len, unsigned ws_rule); +void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws); +char *whitespace_error_string(unsigned ws); +void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *); +int ws_blank_line(const char *line, int len, unsigned ws_rule); +#define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK) + +#endif