summaryrefslogtreecommitdiff
path: root/diff-lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/diff-lib.c b/diff-lib.c
index a9b5149d1b..1d184422a5 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -217,6 +217,10 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
return 0;
}
+ if (read_cache() < 0) {
+ perror("read_cache");
+ return -1;
+ }
return run_diff_files(revs, silent_on_removed);
}
@@ -227,11 +231,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
if (diff_unmerged_stage < 0)
diff_unmerged_stage = 2;
- entries = read_cache();
- if (entries < 0) {
- perror("read_cache");
- return -1;
- }
+ entries = active_nr;
for (i = 0; i < entries; i++) {
struct stat st;
unsigned int oldmode, newmode;
@@ -559,10 +559,6 @@ int run_diff_index(struct rev_info *revs, int cached)
if (!revs->ignore_merges)
match_missing = 1;
- if (read_cache() < 0) {
- perror("read_cache");
- return -1;
- }
mark_merge_entries();
ent = revs->pending.objects[0].item;