read-cache.c: remove the_* from index_has_changes()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Nguyễn Thái Ngọc Duy 2019-01-12 09:13:31 +07:00 committed by Junio C Hamano
parent d7cf3a96e9
commit 150fe065f7
4 changed files with 12 additions and 14 deletions

View File

@ -1719,7 +1719,7 @@ static void am_run(struct am_state *state, int resume)


refresh_and_write_cache(); refresh_and_write_cache();


if (index_has_changes(&the_index, NULL, &sb)) { if (repo_index_has_changes(the_repository, NULL, &sb)) {
write_state_bool(state, "dirtyindex", 1); write_state_bool(state, "dirtyindex", 1);
die(_("Dirty index: cannot apply patches (dirty: %s)"), sb.buf); die(_("Dirty index: cannot apply patches (dirty: %s)"), sb.buf);
} }
@ -1777,7 +1777,7 @@ static void am_run(struct am_state *state, int resume)
* the result may have produced the same tree as ours. * the result may have produced the same tree as ours.
*/ */
if (!apply_status && if (!apply_status &&
!index_has_changes(&the_index, NULL, NULL)) { !repo_index_has_changes(the_repository, NULL, NULL)) {
say(state, stdout, _("No changes -- Patch already applied.")); say(state, stdout, _("No changes -- Patch already applied."));
goto next; goto next;
} }
@ -1831,7 +1831,7 @@ static void am_resolve(struct am_state *state)


say(state, stdout, _("Applying: %.*s"), linelen(state->msg), state->msg); say(state, stdout, _("Applying: %.*s"), linelen(state->msg), state->msg);


if (!index_has_changes(&the_index, NULL, NULL)) { if (!repo_index_has_changes(the_repository, NULL, NULL)) {
printf_ln(_("No changes - did you forget to use 'git add'?\n" printf_ln(_("No changes - did you forget to use 'git add'?\n"
"If there is nothing left to stage, chances are that something else\n" "If there is nothing left to stage, chances are that something else\n"
"already introduced the same changes; you might want to skip this patch.")); "already introduced the same changes; you might want to skip this patch."));

View File

@ -706,7 +706,7 @@ extern int unmerged_index(const struct index_state *);
* provided, the space-separated list of files that differ will be appended * provided, the space-separated list of files that differ will be appended
* to it. * to it.
*/ */
extern int index_has_changes(struct index_state *istate, extern int repo_index_has_changes(struct repository *repo,
struct tree *tree, struct tree *tree,
struct strbuf *sb); struct strbuf *sb);



View File

@ -3412,7 +3412,7 @@ int merge_trees(struct merge_options *o,
int code, clean; int code, clean;
struct strbuf sb = STRBUF_INIT; struct strbuf sb = STRBUF_INIT;


if (!o->call_depth && index_has_changes(istate, head, &sb)) { if (!o->call_depth && repo_index_has_changes(o->repo, head, &sb)) {
err(o, _("Your local changes to the following files would be overwritten by merge:\n %s"), err(o, _("Your local changes to the following files would be overwritten by merge:\n %s"),
sb.buf); sb.buf);
return -1; return -1;

View File

@ -2365,22 +2365,20 @@ int unmerged_index(const struct index_state *istate)
return 0; return 0;
} }


int index_has_changes(struct index_state *istate, int repo_index_has_changes(struct repository *repo,
struct tree *tree, struct tree *tree,
struct strbuf *sb) struct strbuf *sb)
{ {
struct index_state *istate = repo->index;
struct object_id cmp; struct object_id cmp;
int i; int i;


if (istate != &the_index) {
BUG("index_has_changes cannot yet accept istate != &the_index; do_diff_cache needs updating first.");
}
if (tree) if (tree)
cmp = tree->object.oid; cmp = tree->object.oid;
if (tree || !get_oid_tree("HEAD", &cmp)) { if (tree || !get_oid_tree("HEAD", &cmp)) {
struct diff_options opt; struct diff_options opt;


repo_diff_setup(the_repository, &opt); repo_diff_setup(repo, &opt);
opt.flags.exit_with_status = 1; opt.flags.exit_with_status = 1;
if (!sb) if (!sb)
opt.flags.quick = 1; opt.flags.quick = 1;