aboutsummaryrefslogtreecommitdiffstats
path: root/attr.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-08-13 18:14:33 +0200
committerJunio C Hamano <gitster@pobox.com>2018-08-13 14:14:43 -0700
commitc4500e251f89cbbc49fe90b832348ea9d4899946 (patch)
treeb4d5fa523ffd904e1cc061172230d4af6e50f7ed /attr.c
parent74cfc0ee1d0b4e386b5a07f8b79fbcece94cdff8 (diff)
downloadgit-c4500e251f89cbbc49fe90b832348ea9d4899946.tar.gz
attr: remove index from git_attr_set_direction()
Since attr checking API now take the index, there's no need to set an index in advance with this call. Most call sites are straightforward because they either pass the_index or NULL (which defaults back to the_index previously). There's only one suspicious call site in unpack-trees.c where it sets a different index. This code in unpack-trees is about to check out entries from the new/temporary index after merging is done in it. The attributes will be used by entry.c code to do crlf conversion if needed. entry.c now respects struct checkout's istate field, and this field is correctly set in unpack-trees.c, there should be no regression from this change. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'attr.c')
-rw-r--r--attr.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/attr.c b/attr.c
index 863fad3bd1..98e4953f6e 100644
--- a/attr.c
+++ b/attr.c
@@ -708,10 +708,8 @@ static struct attr_stack *read_attr_from_array(const char **list)
* another thread could potentially be calling into the attribute system.
*/
static enum git_attr_direction direction;
-static const struct index_state *use_index;
-void git_attr_set_direction(enum git_attr_direction new_direction,
- const struct index_state *istate)
+void git_attr_set_direction(enum git_attr_direction new_direction)
{
if (is_bare_repository() && new_direction != GIT_ATTR_INDEX)
BUG("non-INDEX attr direction in a bare repo");
@@ -720,7 +718,6 @@ void git_attr_set_direction(enum git_attr_direction new_direction,
drop_all_attr_stacks();
direction = new_direction;
- use_index = istate;
}
static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
@@ -750,17 +747,11 @@ static struct attr_stack *read_attr_from_index(const struct index_state *istate,
struct attr_stack *res;
char *buf, *sp;
int lineno = 0;
- const struct index_state *to_read_from;
- /*
- * Temporary workaround for c24f3abace (apply: file commited
- * with CRLF should roundtrip diff and apply - 2017-08-19)
- */
- to_read_from = use_index ? use_index : istate;
- if (!to_read_from)
+ if (!istate)
return NULL;
- buf = read_blob_data_from_index(to_read_from, path, NULL);
+ buf = read_blob_data_from_index(istate, path, NULL);
if (!buf)
return NULL;