run_diff_{files,index}(): update calling convention.
They used to open and read index themselves, but they now expect their callers to do so. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Feb 9, 2007 at 18:51 UTC
b4e1e4a787d3771f617182b3344dcdd9224bd0cb
5 files changed
+27
-11
builtin-diff-files.c
+4
@@ -47,5 +47,9 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
47
if (rev.pending.nr ||
48
rev.min_age != -1 || rev.max_age != -1)
49
usage(diff_files_usage);
50
+ if (read_cache() < 0) {
51
+ perror("read_cache");
52
+ return -1;
53
+ }
54
return run_diff_files(&rev, silent);
55
}
builtin-diff-index.c
+4
@@ -38,5 +38,9 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
38
if (rev.pending.nr != 1 ||
39
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
40
usage(diff_cache_usage);
41
+ if (read_cache() < 0) {
42
+ perror("read_cache");
43
+ return -1;
44
+ }
45
return run_diff_index(&rev, cached);
46
}
builtin-diff.c
+8
@@ -56,6 +56,10 @@ static int builtin_diff_files(struct rev_info *revs,
56
if (revs->max_count < 0 &&
57
(revs->diffopt.output_format & DIFF_FORMAT_PATCH))
58
revs->combine_merges = revs->dense_combined_merges = 1;
59
+ if (read_cache() < 0) {
60
+ perror("read_cache");
61
+ return -1;
62
+ }
63
return run_diff_files(revs, silent);
64
}
65
@@ -151,6 +155,10 @@ static int builtin_diff_index(struct rev_info *revs,
155
revs->max_count != -1 || revs->min_age != -1 ||
156
revs->max_age != -1)
157
usage(builtin_diff_usage);
158
+ if (read_cache() < 0) {
159
+ perror("read_cache");
160
+ return -1;
161
+ }
162
return run_diff_index(revs, cached);
163
}
164
diff-lib.c
+1
-9
@@ -20,11 +20,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
20
21
if (diff_unmerged_stage < 0)
22
diff_unmerged_stage = 2;
23
- entries = read_cache();
24
- if (entries < 0) {
25
- perror("read_cache");
26
- return -1;
27
- }
23
+ entries = active_nr;
24
for (i = 0; i < entries; i++) {
25
struct stat st;
26
unsigned int oldmode, newmode;
@@ -354,10 +350,6 @@ int run_diff_index(struct rev_info *revs, int cached)
350
if (!revs->ignore_merges)
351
match_missing = 1;
352
357
- if (read_cache() < 0) {
358
- perror("read_cache");
359
- return -1;
360
- }
353
mark_merge_entries();
354
355
ent = revs->pending.objects[0].item;
wt-status.c
+10
-2
@@ -191,12 +191,18 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
191
wt_status_print_trailer();
192
}
193
194
+static void wt_read_cache(struct wt_status *s)
195
+{
196
+ discard_cache();
197
+ read_cache();
198
+}
199
+
200
void wt_status_print_initial(struct wt_status *s)
201
{
202
int i;
203
char buf[PATH_MAX];
204
199
- read_cache();
205
+ wt_read_cache(s);
206
if (active_nr) {
207
s->commitable = 1;
208
wt_status_print_cached_header(NULL);
@@ -220,6 +226,7 @@ static void wt_status_print_updated(struct wt_status *s)
226
rev.diffopt.format_callback = wt_status_print_updated_cb;
227
rev.diffopt.format_callback_data = s;
228
rev.diffopt.detect_rename = 1;
229
+ wt_read_cache(s);
230
run_diff_index(&rev, 1);
231
}
232
@@ -231,6 +238,7 @@ static void wt_status_print_changed(struct wt_status *s)
238
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
239
rev.diffopt.format_callback = wt_status_print_changed_cb;
240
rev.diffopt.format_callback_data = s;
241
+ wt_read_cache(s);
242
run_diff_files(&rev, 0);
243
}
244
@@ -287,6 +295,7 @@ static void wt_status_print_verbose(struct wt_status *s)
295
setup_revisions(0, NULL, &rev, s->reference);
296
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
297
rev.diffopt.detect_rename = 1;
298
+ wt_read_cache(s);
299
run_diff_index(&rev, 1);
300
}
301
@@ -316,7 +325,6 @@ void wt_status_print(struct wt_status *s)
325
}
326
else {
327
wt_status_print_updated(s);
319
- discard_cache();
328
}
329
330
wt_status_print_changed(s);