mirror of
https://github.com/git/git.git
synced 2024-11-27 12:03:55 +08:00
ws.c: remove implicit dependency on the_index
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
dcf42869ee
commit
26d024ecf0
8
apply.c
8
apply.c
@ -2131,10 +2131,12 @@ static int parse_chunk(struct apply_state *state, char *buffer, unsigned long si
|
|||||||
|
|
||||||
if (!use_patch(state, patch))
|
if (!use_patch(state, patch))
|
||||||
patch->ws_rule = 0;
|
patch->ws_rule = 0;
|
||||||
|
else if (patch->new_name)
|
||||||
|
patch->ws_rule = whitespace_rule(state->repo->index,
|
||||||
|
patch->new_name);
|
||||||
else
|
else
|
||||||
patch->ws_rule = whitespace_rule(patch->new_name
|
patch->ws_rule = whitespace_rule(state->repo->index,
|
||||||
? patch->new_name
|
patch->old_name);
|
||||||
: patch->old_name);
|
|
||||||
|
|
||||||
patchsize = parse_single_patch(state,
|
patchsize = parse_single_patch(state,
|
||||||
buffer + offset + hdrsize,
|
buffer + offset + hdrsize,
|
||||||
|
2
cache.h
2
cache.h
@ -1694,7 +1694,7 @@ void shift_tree_by(const struct object_id *, const struct object_id *, struct ob
|
|||||||
/* All WS_* -- when extended, adapt diff.c emit_symbol */
|
/* All WS_* -- when extended, adapt diff.c emit_symbol */
|
||||||
#define WS_RULE_MASK 07777
|
#define WS_RULE_MASK 07777
|
||||||
extern unsigned whitespace_rule_cfg;
|
extern unsigned whitespace_rule_cfg;
|
||||||
extern unsigned whitespace_rule(const char *);
|
extern unsigned whitespace_rule(struct index_state *, const char *);
|
||||||
extern unsigned parse_whitespace_rule(const char *);
|
extern unsigned parse_whitespace_rule(const char *);
|
||||||
extern unsigned ws_check(const char *line, int len, unsigned ws_rule);
|
extern unsigned ws_check(const char *line, int len, unsigned ws_rule);
|
||||||
extern void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
|
extern void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
|
||||||
|
6
diff.c
6
diff.c
@ -1705,7 +1705,7 @@ static void emit_rewrite_diff(const char *name_a,
|
|||||||
|
|
||||||
memset(&ecbdata, 0, sizeof(ecbdata));
|
memset(&ecbdata, 0, sizeof(ecbdata));
|
||||||
ecbdata.color_diff = want_color(o->use_color);
|
ecbdata.color_diff = want_color(o->use_color);
|
||||||
ecbdata.ws_rule = whitespace_rule(name_b);
|
ecbdata.ws_rule = whitespace_rule(o->repo->index, name_b);
|
||||||
ecbdata.opt = o;
|
ecbdata.opt = o;
|
||||||
if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
|
if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
|
||||||
mmfile_t mf1, mf2;
|
mmfile_t mf1, mf2;
|
||||||
@ -3480,7 +3480,7 @@ static void builtin_diff(const char *name_a,
|
|||||||
lbl[0] = NULL;
|
lbl[0] = NULL;
|
||||||
ecbdata.label_path = lbl;
|
ecbdata.label_path = lbl;
|
||||||
ecbdata.color_diff = want_color(o->use_color);
|
ecbdata.color_diff = want_color(o->use_color);
|
||||||
ecbdata.ws_rule = whitespace_rule(name_b);
|
ecbdata.ws_rule = whitespace_rule(o->repo->index, name_b);
|
||||||
if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
|
if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
|
||||||
check_blank_at_eof(&mf1, &mf2, &ecbdata);
|
check_blank_at_eof(&mf1, &mf2, &ecbdata);
|
||||||
ecbdata.opt = o;
|
ecbdata.opt = o;
|
||||||
@ -3640,7 +3640,7 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
|
|||||||
data.filename = name_b ? name_b : name_a;
|
data.filename = name_b ? name_b : name_a;
|
||||||
data.lineno = 0;
|
data.lineno = 0;
|
||||||
data.o = o;
|
data.o = o;
|
||||||
data.ws_rule = whitespace_rule(attr_path);
|
data.ws_rule = whitespace_rule(o->repo->index, attr_path);
|
||||||
data.conflict_marker_size = ll_merge_marker_size(o->repo->index, attr_path);
|
data.conflict_marker_size = ll_merge_marker_size(o->repo->index, attr_path);
|
||||||
|
|
||||||
if (fill_mmfile(o->repo, &mf1, one) < 0 ||
|
if (fill_mmfile(o->repo, &mf1, one) < 0 ||
|
||||||
|
5
ws.c
5
ws.c
@ -3,7 +3,6 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2007 Junio C Hamano
|
* Copyright (c) 2007 Junio C Hamano
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "attr.h"
|
#include "attr.h"
|
||||||
|
|
||||||
@ -71,14 +70,14 @@ unsigned parse_whitespace_rule(const char *string)
|
|||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned whitespace_rule(const char *pathname)
|
unsigned whitespace_rule(struct index_state *istate, const char *pathname)
|
||||||
{
|
{
|
||||||
static struct attr_check *attr_whitespace_rule;
|
static struct attr_check *attr_whitespace_rule;
|
||||||
|
|
||||||
if (!attr_whitespace_rule)
|
if (!attr_whitespace_rule)
|
||||||
attr_whitespace_rule = attr_check_initl("whitespace", NULL);
|
attr_whitespace_rule = attr_check_initl("whitespace", NULL);
|
||||||
|
|
||||||
if (!git_check_attr(&the_index, pathname, attr_whitespace_rule)) {
|
if (!git_check_attr(istate, pathname, attr_whitespace_rule)) {
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
value = attr_whitespace_rule->items[0].value;
|
value = attr_whitespace_rule->items[0].value;
|
||||||
|
Loading…
Reference in New Issue
Block a user