diff-lib.c: remove the_repository references
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
Nov 10, 2018 at 06:49 UTC
ffc00a48efe8f591a05f8e7b61f632bcaf098dde
5 files changed
+11
-8
builtin/commit.c
+2
-1
@@ -908,7 +908,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
908
if (ignore_submodule_arg &&
909
!strcmp(ignore_submodule_arg, "all"))
910
flags.ignore_submodules = 1;
911
- committable = index_differs_from(parent, &flags, 1);
911
+ committable = index_differs_from(the_repository,
912
+ parent, &flags, 1);
913
}
914
}
915
strbuf_release(&committer_ident);
builtin/merge-ours.c
+1
-1
@@ -26,7 +26,7 @@ int cmd_merge_ours(int argc, const char **argv, const char *prefix)
26
*/
27
if (read_cache() < 0)
28
die_errno("read_cache failed");
29
- if (index_differs_from("HEAD", NULL, 0))
29
+ if (index_differs_from(the_repository, "HEAD", NULL, 0))
30
exit(2);
31
exit(0);
32
}
diff-lib.c
+4
-3
@@ -542,7 +542,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
542
{
543
struct rev_info revs;
544
545
- repo_init_revisions(the_repository, &revs, NULL);
545
+ repo_init_revisions(opt->repo, &revs, NULL);
546
copy_pathspec(&revs.prune_data, &opt->pathspec);
547
revs.diffopt = *opt;
548
@@ -551,13 +551,14 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
551
return 0;
552
}
553
554
-int index_differs_from(const char *def, const struct diff_flags *flags,
554
+int index_differs_from(struct repository *r,
555
+ const char *def, const struct diff_flags *flags,
556
int ita_invisible_in_index)
557
{
558
struct rev_info rev;
559
struct setup_revision_opt opt;
560
560
- repo_init_revisions(the_repository, &rev, NULL);
561
+ repo_init_revisions(r, &rev, NULL);
562
memset(&opt, 0, sizeof(opt));
563
opt.def = def;
564
setup_revisions(0, NULL, &rev, &opt);
diff.h
+2
-1
@@ -436,7 +436,8 @@ int diff_result_code(struct diff_options *, int);
436
437
void diff_no_index(struct repository *, struct rev_info *, int, const char **);
438
439
-int index_differs_from(const char *def, const struct diff_flags *flags,
439
+int index_differs_from(struct repository *r, const char *def,
440
+ const struct diff_flags *flags,
441
int ita_invisible_in_index);
442
443
/*
sequencer.c
+2
-2
@@ -1713,7 +1713,7 @@ static int do_pick_commit(struct repository *r,
1713
unborn = 1;
1714
} else if (unborn)
1715
oidcpy(&head, the_hash_algo->empty_tree);
1716
- if (index_differs_from(unborn ? empty_tree_oid_hex() : "HEAD",
1716
+ if (index_differs_from(r, unborn ? empty_tree_oid_hex() : "HEAD",
1717
NULL, 0))
1718
return error_dirty_index(r->index, opts);
1719
}
@@ -3915,7 +3915,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)
3915
if (res)
3916
goto release_todo_list;
3917
}
3918
- if (index_differs_from("HEAD", NULL, 0)) {
3918
+ if (index_differs_from(r, "HEAD", NULL, 0)) {
3919
res = error_dirty_index(r->index, opts);
3920
goto release_todo_list;
3921
}