Skip to content

Commit

Permalink
cache.h: split off ws.c declerations into a new ws.h
Browse files Browse the repository at this point in the history
  • Loading branch information
avar committed Dec 2, 2021
1 parent abe6bb3 commit 1d023e5
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 26 deletions.
1 change: 1 addition & 0 deletions apply.c
Expand Up @@ -22,6 +22,7 @@
#include "rerere.h"
#include "apply.h"
#include "entry.h"
#include "ws.h"

struct gitdiff_data {
struct strbuf *root;
Expand Down
26 changes: 0 additions & 26 deletions cache.h
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions config.c
Expand Up @@ -21,6 +21,7 @@
#include "dir.h"
#include "color.h"
#include "refs.h"
#include "ws.h"

struct config_source {
struct config_source *prev;
Expand Down
1 change: 1 addition & 0 deletions diff.c
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions environment.c
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ws.c
Expand Up @@ -4,6 +4,7 @@
* Copyright (c) 2007 Junio C Hamano
*/
#include "cache.h"
#include "ws.h"
#include "attr.h"

static struct whitespace_rule {
Expand Down
30 changes: 30 additions & 0 deletions 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

0 comments on commit 1d023e5

Please sign in to comment.