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>
Nguyễn Thái Ngọc Duy committed
Jan 12, 2019 at 09:13 UTC
150fe065f71778a6591566d6fde65171569a4b7a
4 files changed
+12
-14
builtin/am.c
+3
-3
@@ -1719,7 +1719,7 @@ static void am_run(struct am_state *state, int resume)
1719
1720
refresh_and_write_cache();
1721
1722
- if (index_has_changes(&the_index, NULL, &sb)) {
1722
+ if (repo_index_has_changes(the_repository, NULL, &sb)) {
1723
write_state_bool(state, "dirtyindex", 1);
1724
die(_("Dirty index: cannot apply patches (dirty: %s)"), sb.buf);
1725
}
@@ -1777,7 +1777,7 @@ static void am_run(struct am_state *state, int resume)
1777
* the result may have produced the same tree as ours.
1778
*/
1779
if (!apply_status &&
1780
- !index_has_changes(&the_index, NULL, NULL)) {
1780
+ !repo_index_has_changes(the_repository, NULL, NULL)) {
1781
say(state, stdout, _("No changes -- Patch already applied."));
1782
goto next;
1783
}
@@ -1831,7 +1831,7 @@ static void am_resolve(struct am_state *state)
1831
1832
say(state, stdout, _("Applying: %.*s"), linelen(state->msg), state->msg);
1833
1834
- if (!index_has_changes(&the_index, NULL, NULL)) {
1834
+ if (!repo_index_has_changes(the_repository, NULL, NULL)) {
1835
printf_ln(_("No changes - did you forget to use 'git add'?\n"
1836
"If there is nothing left to stage, chances are that something else\n"
1837
"already introduced the same changes; you might want to skip this patch."));
cache.h
+3
-3
@@ -706,9 +706,9 @@ extern int unmerged_index(const struct index_state *);
706
* provided, the space-separated list of files that differ will be appended
707
* to it.
708
*/
709
-extern int index_has_changes(struct index_state *istate,
710
- struct tree *tree,
711
- struct strbuf *sb);
709
+extern int repo_index_has_changes(struct repository *repo,
710
+ struct tree *tree,
711
+ struct strbuf *sb);
712
713
extern int verify_path(const char *path, unsigned mode);
714
extern int strcmp_offset(const char *s1, const char *s2, size_t *first_change);
merge-recursive.c
+1
-1
@@ -3412,7 +3412,7 @@ int merge_trees(struct merge_options *o,
3412
int code, clean;
3413
struct strbuf sb = STRBUF_INIT;
3414
3415
- if (!o->call_depth && index_has_changes(istate, head, &sb)) {
3415
+ if (!o->call_depth && repo_index_has_changes(o->repo, head, &sb)) {
3416
err(o, _("Your local changes to the following files would be overwritten by merge:\n %s"),
3417
sb.buf);
3418
return -1;
read-cache.c
+5
-7
@@ -2365,22 +2365,20 @@ int unmerged_index(const struct index_state *istate)
2365
return 0;
2366
}
2367
2368
-int index_has_changes(struct index_state *istate,
2369
- struct tree *tree,
2370
- struct strbuf *sb)
2368
+int repo_index_has_changes(struct repository *repo,
2369
+ struct tree *tree,
2370
+ struct strbuf *sb)
2371
{
2372
+ struct index_state *istate = repo->index;
2373
struct object_id cmp;
2374
int i;
2375
2375
- if (istate != &the_index) {
2376
- BUG("index_has_changes cannot yet accept istate != &the_index; do_diff_cache needs updating first.");
2377
- }
2376
if (tree)
2377
cmp = tree->object.oid;
2378
if (tree || !get_oid_tree("HEAD", &cmp)) {
2379
struct diff_options opt;
2380
2383
- repo_diff_setup(the_repository, &opt);
2381
+ repo_diff_setup(repo, &opt);
2382
opt.flags.exit_with_status = 1;
2383
if (!sb)
2384
opt.flags.quick = 1;