From: Junio C Hamano Date: Sun, 9 Dec 2007 09:23:48 +0000 (-0800) Subject: Merge branch 'jc/spht' X-Git-Tag: v1.5.4-rc0~35 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4eb39e9bcccc54eb23af8a7e2676c63e5bf32866;p=git.git Merge branch 'jc/spht' * jc/spht: Use gitattributes to define per-path whitespace rule core.whitespace: documentation updates. builtin-apply: teach whitespace_rules builtin-apply: rename "whitespace" variables and fix styles core.whitespace: add test for diff whitespace error highlighting git-diff: complain about >=8 consecutive spaces in initial indent War on whitespace: first, a bit of retreat. Conflicts: cache.h config.c diff.c --- 4eb39e9bcccc54eb23af8a7e2676c63e5bf32866 diff --cc Documentation/config.txt index 79d51f26c,0e711374d..fabe7f859 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@@ -387,22 -392,10 +401,22 @@@ color.diff.: which part of the patch to use the specified color, and is one of `plain` (context text), `meta` (metainformation), `frag` (hunk header), `old` (removed lines), `new` (added lines), - `commit` (commit headers), or `whitespace` (highlighting dubious - whitespace). The values of these variables may be specified as + `commit` (commit headers), or `whitespace` (highlighting + whitespace errors). The values of these variables may be specified as in color.branch.. +color.interactive:: + When set to `always`, always use colors in `git add --interactive`. + When false (or `never`), never. When set to `true` or `auto`, use + colors only when the output is to the terminal. Defaults to false. + +color.interactive.:: + Use customized color for `git add --interactive` + output. `` may be `prompt`, `header`, or `help`, for + three distinct types of normal output from interactive + programs. The values of these variables may be specified as + in color.branch.. + color.pager:: A boolean to enable/disable colored output when the pager is in use (default is true). diff --cc cache.h index c6142e9b7,9cc6268d4..1bcb3df7a --- a/cache.h +++ b/cache.h @@@ -644,9 -602,16 +644,21 @@@ extern int diff_auto_refresh_index /* match-trees.c */ void shift_tree(const unsigned char *, const unsigned char *, unsigned char *, int); + /* + * whitespace rules. + * used by both diff and apply + */ + #define WS_TRAILING_SPACE 01 + #define WS_SPACE_BEFORE_TAB 02 + #define WS_INDENT_WITH_NON_TAB 04 + #define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB) + extern unsigned whitespace_rule_cfg; + extern unsigned whitespace_rule(const char *); + extern unsigned parse_whitespace_rule(const char *); + +/* ls-files */ +int pathspec_match(const char **spec, char *matched, const char *filename, int skiplen); +int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset); +void overlay_tree_on_cache(const char *tree_name, const char *prefix); + #endif /* CACHE_H */ diff --cc config.c index 15b3d0734,2500e0d59..49d2b427e --- a/config.c +++ b/config.c @@@ -432,13 -431,11 +432,18 @@@ int git_default_config(const char *var return 0; } + if (!strcmp(var, "core.excludesfile")) { + if (!value) + die("core.excludesfile without value"); + excludes_file = xstrdup(value); + return 0; + } + + if (!strcmp(var, "core.whitespace")) { + whitespace_rule_cfg = parse_whitespace_rule(value); + return 0; + } + /* Add other config variables here and to Documentation/config.txt. */ return 0; } diff --cc diff.c index be6cf687a,c3a1942bb..f780e3e8e --- a/diff.c +++ b/diff.c @@@ -1315,8 -1331,9 +1331,9 @@@ static void builtin_diff(const char *na memset(&xecfg, 0, sizeof(xecfg)); memset(&ecbdata, 0, sizeof(ecbdata)); ecbdata.label_path = lbl; - ecbdata.color_diff = o->color_diff; + ecbdata.color_diff = DIFF_OPT_TST(o, COLOR_DIFF); ecbdata.found_changesp = &o->found_changes; + ecbdata.ws_rule = whitespace_rule(name_b ? name_b : name_a); xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts; xecfg.ctxlen = o->context; xecfg.flags = XDL_EMIT_FUNCNAMES; @@@ -1409,7 -1426,8 +1426,8 @@@ static void builtin_checkdiff(const cha data.xm.consume = checkdiff_consume; data.filename = name_b ? name_b : name_a; data.lineno = 0; - data.color_diff = o->color_diff; + data.color_diff = DIFF_OPT_TST(o, COLOR_DIFF); + data.ws_rule = whitespace_rule(data.filename); if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0) die("unable to read files to diff"); diff --cc environment.c index 1dab72ec1,2fbbc8e43..f3e3d4138 --- a/environment.c +++ b/environment.c @@@ -34,8 -34,8 +34,9 @@@ char *pager_program int pager_in_use; int pager_use_color = 1; char *editor_program; +char *excludes_file; int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */ + unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; /* This is set by setup_git_dir_gently() and/or git_default_config() */ char *git_work_tree_cfg;