Skip to content

Commit 2845265

Browse files
trastgitster
authored andcommitted
diff_setup_done(): return void
diff_setup_done() has historically returned an error code, but lost the last nonzero return in 943d5b7 (allow diff.renamelimit to be set regardless of -M/-C, 2006-08-09). The callers were in a pretty confused state: some actually checked for the return code, and some did not. Let it return void, and patch all callers to take this into account. This conveniently also gets rid of a handful of different(!) error messages that could never be triggered anyway. Note that the function can still die(). Signed-off-by: Thomas Rast <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0f1ea6 commit 2845265

File tree

13 files changed

+16
-32
lines changed

13 files changed

+16
-32
lines changed

builtin/blame.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,7 @@ static struct origin *find_origin(struct scoreboard *sb,
392392
paths[1] = NULL;
393393

394394
diff_tree_setup_paths(paths, &diff_opts);
395-
if (diff_setup_done(&diff_opts) < 0)
396-
die("diff-setup");
395+
diff_setup_done(&diff_opts);
397396

398397
if (is_null_sha1(origin->commit->object.sha1))
399398
do_diff_cache(parent->tree->object.sha1, &diff_opts);
@@ -479,8 +478,7 @@ static struct origin *find_rename(struct scoreboard *sb,
479478
diff_opts.single_follow = origin->path;
480479
paths[0] = NULL;
481480
diff_tree_setup_paths(paths, &diff_opts);
482-
if (diff_setup_done(&diff_opts) < 0)
483-
die("diff-setup");
481+
diff_setup_done(&diff_opts);
484482

485483
if (is_null_sha1(origin->commit->object.sha1))
486484
do_diff_cache(parent->tree->object.sha1, &diff_opts);
@@ -1065,8 +1063,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
10651063

10661064
paths[0] = NULL;
10671065
diff_tree_setup_paths(paths, &diff_opts);
1068-
if (diff_setup_done(&diff_opts) < 0)
1069-
die("diff-setup");
1066+
diff_setup_done(&diff_opts);
10701067

10711068
/* Try "find copies harder" on new path if requested;
10721069
* we do not want to use diffcore_rename() actually to

builtin/checkout.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ static void show_local_changes(struct object *head, struct diff_options *opts)
315315
init_revisions(&rev, NULL);
316316
rev.diffopt.flags = opts->flags;
317317
rev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;
318-
if (diff_setup_done(&rev.diffopt) < 0)
319-
die(_("diff_setup_done failed"));
318+
diff_setup_done(&rev.diffopt);
320319
add_pending_object(&rev, head, NULL);
321320
run_diff_index(&rev, 0);
322321
}

builtin/diff.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
294294
argc = setup_revisions(argc, argv, &rev, NULL);
295295
if (!rev.diffopt.output_format) {
296296
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
297-
if (diff_setup_done(&rev.diffopt) < 0)
298-
die(_("diff_setup_done failed"));
297+
diff_setup_done(&rev.diffopt);
299298
}
300299

301300
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);

builtin/merge.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,7 @@ static void finish(struct commit *head_commit,
402402
opts.output_format |=
403403
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
404404
opts.detect_rename = DIFF_DETECT_RENAME;
405-
if (diff_setup_done(&opts) < 0)
406-
die(_("diff_setup_done failed"));
405+
diff_setup_done(&opts);
407406
diff_tree_sha1(head, new_head, "", &opts);
408407
diffcore_std(&opts);
409408
diff_flush(&opts);

diff-no-index.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ void diff_no_index(struct rev_info *revs,
257257
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
258258

259259
revs->max_count = -2;
260-
if (diff_setup_done(&revs->diffopt) < 0)
261-
die("diff_setup_done failed");
260+
diff_setup_done(&revs->diffopt);
262261

263262
if (queue_diff(&revs->diffopt, revs->diffopt.pathspec.raw[0],
264263
revs->diffopt.pathspec.raw[1]))

diff.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3105,7 +3105,7 @@ void diff_setup(struct diff_options *options)
31053105
}
31063106
}
31073107

3108-
int diff_setup_done(struct diff_options *options)
3108+
void diff_setup_done(struct diff_options *options)
31093109
{
31103110
int count = 0;
31113111

@@ -3204,8 +3204,6 @@ int diff_setup_done(struct diff_options *options)
32043204
options->output_format = DIFF_FORMAT_NO_OUTPUT;
32053205
DIFF_OPT_SET(options, EXIT_WITH_STATUS);
32063206
}
3207-
3208-
return 0;
32093207
}
32103208

32113209
static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val)

diff.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ extern int git_diff_ui_config(const char *var, const char *value, void *cb);
236236
extern int diff_use_color_default;
237237
extern void diff_setup(struct diff_options *);
238238
extern int diff_opt_parse(struct diff_options *, const char **, int);
239-
extern int diff_setup_done(struct diff_options *);
239+
extern void diff_setup_done(struct diff_options *);
240240

241241
#define DIFF_DETECT_RENAME 1
242242
#define DIFF_DETECT_COPY 2

merge-recursive.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,7 @@ static struct string_list *get_renames(struct merge_options *o,
492492
opts.rename_score = o->rename_score;
493493
opts.show_rename_progress = o->show_rename_progress;
494494
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
495-
if (diff_setup_done(&opts) < 0)
496-
die("diff setup failed");
495+
diff_setup_done(&opts);
497496
diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts);
498497
diffcore_std(&opts);
499498
if (opts.needed_rename_limit > o->needed_rename_limit)

notes-merge.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
126126
diff_setup(&opt);
127127
DIFF_OPT_SET(&opt, RECURSIVE);
128128
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
129-
if (diff_setup_done(&opt) < 0)
130-
die("diff_setup_done failed");
129+
diff_setup_done(&opt);
131130
diff_tree_sha1(base, remote, "", &opt);
132131
diffcore_std(&opt);
133132

@@ -190,8 +189,7 @@ static void diff_tree_local(struct notes_merge_options *o,
190189
diff_setup(&opt);
191190
DIFF_OPT_SET(&opt, RECURSIVE);
192191
opt.output_format = DIFF_FORMAT_NO_OUTPUT;
193-
if (diff_setup_done(&opt) < 0)
194-
die("diff_setup_done failed");
192+
diff_setup_done(&opt);
195193
diff_tree_sha1(base, local, "", &opt);
196194
diffcore_std(&opt);
197195

patch-ids.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ int init_patch_ids(struct patch_ids *ids)
3939
memset(ids, 0, sizeof(*ids));
4040
diff_setup(&ids->diffopts);
4141
DIFF_OPT_SET(&ids->diffopts, RECURSIVE);
42-
if (diff_setup_done(&ids->diffopts) < 0)
43-
return error("diff_setup_done failed");
42+
diff_setup_done(&ids->diffopts);
4443
return 0;
4544
}
4645

0 commit comments

Comments
 (0)