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 <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Rast committed
Aug 3, 2012 at 14:16 UTC
28452655af988094792483a51d188c58137760cd
13 files changed
+16
-32
builtin/blame.c
+3
-6
@@ -392,8 +392,7 @@ static struct origin *find_origin(struct scoreboard *sb,
392
paths[1] = NULL;
393
394
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);
396
397
if (is_null_sha1(origin->commit->object.sha1))
398
do_diff_cache(parent->tree->object.sha1, &diff_opts);
@@ -479,8 +478,7 @@ static struct origin *find_rename(struct scoreboard *sb,
478
diff_opts.single_follow = origin->path;
479
paths[0] = NULL;
480
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);
482
483
if (is_null_sha1(origin->commit->object.sha1))
484
do_diff_cache(parent->tree->object.sha1, &diff_opts);
@@ -1065,8 +1063,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
1063
1064
paths[0] = NULL;
1065
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);
1067
1068
/* Try "find copies harder" on new path if requested;
1069
* we do not want to use diffcore_rename() actually to
builtin/checkout.c
+1
-2
@@ -315,8 +315,7 @@ static void show_local_changes(struct object *head, struct diff_options *opts)
315
init_revisions(&rev, NULL);
316
rev.diffopt.flags = opts->flags;
317
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);
319
add_pending_object(&rev, head, NULL);
320
run_diff_index(&rev, 0);
321
}
builtin/diff.c
+1
-2
@@ -294,8 +294,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
294
argc = setup_revisions(argc, argv, &rev, NULL);
295
if (!rev.diffopt.output_format) {
296
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);
298
}
299
300
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
builtin/merge.c
+1
-2
@@ -402,8 +402,7 @@ static void finish(struct commit *head_commit,
402
opts.output_format |=
403
DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT;
404
opts.detect_rename = DIFF_DETECT_RENAME;
405
- if (diff_setup_done(&opts) < 0)
406
- die(_("diff_setup_done failed"));
405
+ diff_setup_done(&opts);
406
diff_tree_sha1(head, new_head, "", &opts);
407
diffcore_std(&opts);
408
diff_flush(&opts);
diff-no-index.c
+1
-2
@@ -257,8 +257,7 @@ void diff_no_index(struct rev_info *revs,
257
DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
258
259
revs->max_count = -2;
260
- if (diff_setup_done(&revs->diffopt) < 0)
261
- die("diff_setup_done failed");
260
+ diff_setup_done(&revs->diffopt);
261
262
if (queue_diff(&revs->diffopt, revs->diffopt.pathspec.raw[0],
263
revs->diffopt.pathspec.raw[1]))
diff.c
+1
-3
@@ -3105,7 +3105,7 @@ void diff_setup(struct diff_options *options)
3105
}
3106
}
3107
3108
-int diff_setup_done(struct diff_options *options)
3108
+void diff_setup_done(struct diff_options *options)
3109
{
3110
int count = 0;
3111
@@ -3204,8 +3204,6 @@ int diff_setup_done(struct diff_options *options)
3204
options->output_format = DIFF_FORMAT_NO_OUTPUT;
3205
DIFF_OPT_SET(options, EXIT_WITH_STATUS);
3206
}
3207
-
3208
- return 0;
3207
}
3208
3209
static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val)
diff.h
+1
-1
@@ -236,7 +236,7 @@ extern int git_diff_ui_config(const char *var, const char *value, void *cb);
236
extern int diff_use_color_default;
237
extern void diff_setup(struct diff_options *);
238
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 *);
240
241
#define DIFF_DETECT_RENAME 1
242
#define DIFF_DETECT_COPY 2
merge-recursive.c
+1
-2
@@ -492,8 +492,7 @@ static struct string_list *get_renames(struct merge_options *o,
492
opts.rename_score = o->rename_score;
493
opts.show_rename_progress = o->show_rename_progress;
494
opts.output_format = DIFF_FORMAT_NO_OUTPUT;
495
- if (diff_setup_done(&opts) < 0)
496
- die("diff setup failed");
495
+ diff_setup_done(&opts);
496
diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts);
497
diffcore_std(&opts);
498
if (opts.needed_rename_limit > o->needed_rename_limit)
notes-merge.c
+2
-4
@@ -126,8 +126,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
126
diff_setup(&opt);
127
DIFF_OPT_SET(&opt, RECURSIVE);
128
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);
130
diff_tree_sha1(base, remote, "", &opt);
131
diffcore_std(&opt);
132
@@ -190,8 +189,7 @@ static void diff_tree_local(struct notes_merge_options *o,
189
diff_setup(&opt);
190
DIFF_OPT_SET(&opt, RECURSIVE);
191
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);
193
diff_tree_sha1(base, local, "", &opt);
194
diffcore_std(&opt);
195
patch-ids.c
+1
-2
@@ -39,8 +39,7 @@ int init_patch_ids(struct patch_ids *ids)
39
memset(ids, 0, sizeof(*ids));
40
diff_setup(&ids->diffopts);
41
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);
43
return 0;
44
}
45
revision.c
+1
-2
@@ -1833,8 +1833,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1833
if (revs->combine_merges)
1834
revs->ignore_merges = 0;
1835
revs->diffopt.abbrev = revs->abbrev;
1836
- if (diff_setup_done(&revs->diffopt) < 0)
1837
- die("diff_setup_done failed");
1836
+ diff_setup_done(&revs->diffopt);
1837
1838
compile_grep_patterns(&revs->grep_filter);
1839
submodule.c
+1
-2
@@ -523,8 +523,7 @@ static void calculate_changed_submodule_paths(void)
523
DIFF_OPT_SET(&diff_opts, RECURSIVE);
524
diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
525
diff_opts.format_callback = submodule_collect_changed_cb;
526
- if (diff_setup_done(&diff_opts) < 0)
527
- die("diff_setup_done failed");
526
+ diff_setup_done(&diff_opts);
527
diff_tree_sha1(parent->item->object.sha1, commit->object.sha1, "", &diff_opts);
528
diffcore_std(&diff_opts);
529
diff_flush(&diff_opts);
tree-diff.c
+1
-2
@@ -212,8 +212,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
212
diff_opts.rename_score = opt->rename_score;
213
paths[0] = NULL;
214
diff_tree_setup_paths(paths, &diff_opts);
215
- if (diff_setup_done(&diff_opts) < 0)
216
- die("unable to set up diff options to follow renames");
215
+ diff_setup_done(&diff_opts);
216
diff_tree(t1, t2, base, &diff_opts);
217
diffcore_std(&diff_opts);
218
diff_tree_release_paths(&diff_opts);