Skip to content

Commit

Permalink
run_diff_{files,index}(): update calling convention.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Feb 22, 2007
1 parent 7b802b8 commit b4e1e4a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
4 changes: 4 additions & 0 deletions builtin-diff-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
if (rev.pending.nr ||
rev.min_age != -1 || rev.max_age != -1)
usage(diff_files_usage);
if (read_cache() < 0) {
perror("read_cache");
return -1;
}
return run_diff_files(&rev, silent);
}
4 changes: 4 additions & 0 deletions builtin-diff-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
if (rev.pending.nr != 1 ||
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
usage(diff_cache_usage);
if (read_cache() < 0) {
perror("read_cache");
return -1;
}
return run_diff_index(&rev, cached);
}
8 changes: 8 additions & 0 deletions builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ static int builtin_diff_files(struct rev_info *revs,
if (revs->max_count < 0 &&
(revs->diffopt.output_format & DIFF_FORMAT_PATCH))
revs->combine_merges = revs->dense_combined_merges = 1;
if (read_cache() < 0) {
perror("read_cache");
return -1;
}
return run_diff_files(revs, silent);
}

Expand Down Expand Up @@ -151,6 +155,10 @@ static int builtin_diff_index(struct rev_info *revs,
revs->max_count != -1 || revs->min_age != -1 ||
revs->max_age != -1)
usage(builtin_diff_usage);
if (read_cache() < 0) {
perror("read_cache");
return -1;
}
return run_diff_index(revs, cached);
}

Expand Down
10 changes: 1 addition & 9 deletions diff-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,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;
Expand Down Expand Up @@ -354,10 +350,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;
Expand Down
12 changes: 10 additions & 2 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,18 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
wt_status_print_trailer();
}

static void wt_read_cache(struct wt_status *s)
{
discard_cache();
read_cache();
}

void wt_status_print_initial(struct wt_status *s)
{
int i;
char buf[PATH_MAX];

read_cache();
wt_read_cache(s);
if (active_nr) {
s->commitable = 1;
wt_status_print_cached_header(NULL);
Expand All @@ -220,6 +226,7 @@ static void wt_status_print_updated(struct wt_status *s)
rev.diffopt.format_callback = wt_status_print_updated_cb;
rev.diffopt.format_callback_data = s;
rev.diffopt.detect_rename = 1;
wt_read_cache(s);
run_diff_index(&rev, 1);
}

Expand All @@ -231,6 +238,7 @@ static void wt_status_print_changed(struct wt_status *s)
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = wt_status_print_changed_cb;
rev.diffopt.format_callback_data = s;
wt_read_cache(s);
run_diff_files(&rev, 0);
}

Expand Down Expand Up @@ -287,6 +295,7 @@ static void wt_status_print_verbose(struct wt_status *s)
setup_revisions(0, NULL, &rev, s->reference);
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
rev.diffopt.detect_rename = 1;
wt_read_cache(s);
run_diff_index(&rev, 1);
}

Expand Down Expand Up @@ -316,7 +325,6 @@ void wt_status_print(struct wt_status *s)
}
else {
wt_status_print_updated(s);
discard_cache();
}

wt_status_print_changed(s);
Expand Down

0 comments on commit b4e1e4a

Please sign in to comment.