mirror of
https://github.com/git/git.git
synced 2024-11-23 18:05:29 +08:00
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>
This commit is contained in:
parent
74cfc0ee1d
commit
c4500e251f
@ -274,7 +274,7 @@ int write_archive_entries(struct archiver_args *args,
|
|||||||
init_tree_desc(&t, args->tree->buffer, args->tree->size);
|
init_tree_desc(&t, args->tree->buffer, args->tree->size);
|
||||||
if (unpack_trees(1, &t, &opts))
|
if (unpack_trees(1, &t, &opts))
|
||||||
return -1;
|
return -1;
|
||||||
git_attr_set_direction(GIT_ATTR_INDEX, &the_index);
|
git_attr_set_direction(GIT_ATTR_INDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = read_tree_recursive(args->tree, "", 0, 0, &args->pathspec,
|
err = read_tree_recursive(args->tree, "", 0, 0, &args->pathspec,
|
||||||
|
15
attr.c
15
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.
|
* another thread could potentially be calling into the attribute system.
|
||||||
*/
|
*/
|
||||||
static enum git_attr_direction direction;
|
static enum git_attr_direction direction;
|
||||||
static const struct index_state *use_index;
|
|
||||||
|
|
||||||
void git_attr_set_direction(enum git_attr_direction new_direction,
|
void git_attr_set_direction(enum git_attr_direction new_direction)
|
||||||
const struct index_state *istate)
|
|
||||||
{
|
{
|
||||||
if (is_bare_repository() && new_direction != GIT_ATTR_INDEX)
|
if (is_bare_repository() && new_direction != GIT_ATTR_INDEX)
|
||||||
BUG("non-INDEX attr direction in a bare repo");
|
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();
|
drop_all_attr_stacks();
|
||||||
|
|
||||||
direction = new_direction;
|
direction = new_direction;
|
||||||
use_index = istate;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct attr_stack *read_attr_from_file(const char *path, int macro_ok)
|
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;
|
struct attr_stack *res;
|
||||||
char *buf, *sp;
|
char *buf, *sp;
|
||||||
int lineno = 0;
|
int lineno = 0;
|
||||||
const struct index_state *to_read_from;
|
|
||||||
|
|
||||||
/*
|
if (!istate)
|
||||||
* 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)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
buf = read_blob_data_from_index(to_read_from, path, NULL);
|
buf = read_blob_data_from_index(istate, path, NULL);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
3
attr.h
3
attr.h
@ -77,8 +77,7 @@ enum git_attr_direction {
|
|||||||
GIT_ATTR_CHECKOUT,
|
GIT_ATTR_CHECKOUT,
|
||||||
GIT_ATTR_INDEX
|
GIT_ATTR_INDEX
|
||||||
};
|
};
|
||||||
void git_attr_set_direction(enum git_attr_direction new_direction,
|
void git_attr_set_direction(enum git_attr_direction new_direction);
|
||||||
const struct index_state *istate);
|
|
||||||
|
|
||||||
void attr_start(void);
|
void attr_start(void);
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cached_attrs)
|
if (cached_attrs)
|
||||||
git_attr_set_direction(GIT_ATTR_INDEX, NULL);
|
git_attr_set_direction(GIT_ATTR_INDEX);
|
||||||
|
|
||||||
doubledash = -1;
|
doubledash = -1;
|
||||||
for (i = 0; doubledash < 0 && i < argc; i++) {
|
for (i = 0; doubledash < 0 && i < argc; i++) {
|
||||||
|
@ -353,7 +353,7 @@ static int check_updates(struct unpack_trees_options *o)
|
|||||||
progress = get_progress(o);
|
progress = get_progress(o);
|
||||||
|
|
||||||
if (o->update)
|
if (o->update)
|
||||||
git_attr_set_direction(GIT_ATTR_CHECKOUT, index);
|
git_attr_set_direction(GIT_ATTR_CHECKOUT);
|
||||||
|
|
||||||
if (should_update_submodules() && o->update && !o->dry_run)
|
if (should_update_submodules() && o->update && !o->dry_run)
|
||||||
load_gitmodules_file(index, NULL);
|
load_gitmodules_file(index, NULL);
|
||||||
@ -413,7 +413,7 @@ static int check_updates(struct unpack_trees_options *o)
|
|||||||
stop_progress(&progress);
|
stop_progress(&progress);
|
||||||
errs |= finish_delayed_checkout(&state);
|
errs |= finish_delayed_checkout(&state);
|
||||||
if (o->update)
|
if (o->update)
|
||||||
git_attr_set_direction(GIT_ATTR_CHECKIN, NULL);
|
git_attr_set_direction(GIT_ATTR_CHECKIN);
|
||||||
return errs != 0;
|
return errs != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user