Skip to content

Commit 6412231

Browse files
newrengitster
authored andcommitted
ws.h: move declarations for ws.c functions from cache.h
Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d4ff207 commit 6412231

File tree

7 files changed

+40
-28
lines changed

7 files changed

+40
-28
lines changed

apply.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "entry.h"
3333
#include "setup.h"
3434
#include "symlinks.h"
35+
#include "ws.h"
3536
#include "wrapper.h"
3637

3738
struct gitdiff_data {

cache.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -603,32 +603,6 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int
603603
/* diff.c */
604604
extern int diff_auto_refresh_index;
605605

606-
/*
607-
* whitespace rules.
608-
* used by both diff and apply
609-
* last two digits are tab width
610-
*/
611-
#define WS_BLANK_AT_EOL 0100
612-
#define WS_SPACE_BEFORE_TAB 0200
613-
#define WS_INDENT_WITH_NON_TAB 0400
614-
#define WS_CR_AT_EOL 01000
615-
#define WS_BLANK_AT_EOF 02000
616-
#define WS_TAB_IN_INDENT 04000
617-
#define WS_TRAILING_SPACE (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
618-
#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
619-
#define WS_TAB_WIDTH_MASK 077
620-
/* All WS_* -- when extended, adapt diff.c emit_symbol */
621-
#define WS_RULE_MASK 07777
622-
extern unsigned whitespace_rule_cfg;
623-
unsigned whitespace_rule(struct index_state *, const char *);
624-
unsigned parse_whitespace_rule(const char *);
625-
unsigned ws_check(const char *line, int len, unsigned ws_rule);
626-
void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
627-
char *whitespace_error_string(unsigned ws);
628-
void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
629-
int ws_blank_line(const char *line, int len);
630-
#define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK)
631-
632606
/* ls-files */
633607
void overlay_tree_on_index(struct index_state *istate,
634608
const char *tree_name, const char *prefix);

config.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "setup.h"
3636
#include "trace2.h"
3737
#include "worktree.h"
38+
#include "ws.h"
3839
#include "wrapper.h"
3940
#include "write-or-die.h"
4041

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "object-name.h"
4242
#include "setup.h"
4343
#include "strmap.h"
44+
#include "ws.h"
4445
#include "wrapper.h"
4546

4647
#ifdef NO_FAST_WORKING_DIRECTORY

environment.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ int read_replace_refs = 1;
6767
enum eol core_eol = EOL_UNSET;
6868
int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
6969
char *check_roundtrip_encoding = "SHIFT-JIS";
70-
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
7170
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
7271
enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
7372
enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;

ws.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
*
44
* Copyright (c) 2007 Junio C Hamano
55
*/
6-
#include "cache.h"
6+
#include "git-compat-util.h"
77
#include "attr.h"
88
#include "strbuf.h"
9+
#include "ws.h"
10+
11+
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
912

1013
static struct whitespace_rule {
1114
const char *rule_name;

ws.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef WS_H
2+
#define WS_H
3+
4+
struct index_state;
5+
struct strbuf;
6+
7+
/*
8+
* whitespace rules.
9+
* used by both diff and apply
10+
* last two digits are tab width
11+
*/
12+
#define WS_BLANK_AT_EOL 0100
13+
#define WS_SPACE_BEFORE_TAB 0200
14+
#define WS_INDENT_WITH_NON_TAB 0400
15+
#define WS_CR_AT_EOL 01000
16+
#define WS_BLANK_AT_EOF 02000
17+
#define WS_TAB_IN_INDENT 04000
18+
#define WS_TRAILING_SPACE (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
19+
#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
20+
#define WS_TAB_WIDTH_MASK 077
21+
/* All WS_* -- when extended, adapt diff.c emit_symbol */
22+
#define WS_RULE_MASK 07777
23+
extern unsigned whitespace_rule_cfg;
24+
unsigned whitespace_rule(struct index_state *, const char *);
25+
unsigned parse_whitespace_rule(const char *);
26+
unsigned ws_check(const char *line, int len, unsigned ws_rule);
27+
void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
28+
char *whitespace_error_string(unsigned ws);
29+
void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
30+
int ws_blank_line(const char *line, int len);
31+
#define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK)
32+
33+
#endif /* WS_H */

0 commit comments

Comments
 (0)