Skip to content

Commit fb6e6e0

Browse files
committed
Merge branch 'jk/ort-unused-parameter-cleanups'
Code clean-up. * jk/ort-unused-parameter-cleanups: merge-ort: lowercase a few error messages merge-ort: drop unused "opt" parameter from merge_check_renames_reusable() merge-ort: drop unused parameters from detect_and_process_renames() merge-ort: stop passing "opt" to read_oid_strbuf() merge-ort: drop custom err() function
2 parents 5c0f993 + 24c5a27 commit fb6e6e0

File tree

3 files changed

+16
-39
lines changed

3 files changed

+16
-39
lines changed

merge-ort.c

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -721,23 +721,6 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
721721
renames->callback_data_nr = renames->callback_data_alloc = 0;
722722
}
723723

724-
__attribute__((format (printf, 2, 3)))
725-
static int err(struct merge_options *opt, const char *err, ...)
726-
{
727-
va_list params;
728-
struct strbuf sb = STRBUF_INIT;
729-
730-
strbuf_addstr(&sb, "error: ");
731-
va_start(params, err);
732-
strbuf_vaddf(&sb, err, params);
733-
va_end(params);
734-
735-
error("%s", sb.buf);
736-
strbuf_release(&sb);
737-
738-
return -1;
739-
}
740-
741724
static void format_commit(struct strbuf *sb,
742725
int indent,
743726
struct repository *repo,
@@ -2122,13 +2105,12 @@ static int handle_content_merge(struct merge_options *opt,
21222105
&result_buf);
21232106

21242107
if ((merge_status < 0) || !result_buf.ptr)
2125-
ret = err(opt, _("Failed to execute internal merge"));
2108+
ret = error(_("failed to execute internal merge"));
21262109

21272110
if (!ret &&
21282111
write_object_file(result_buf.ptr, result_buf.size,
21292112
OBJ_BLOB, &result->oid))
2130-
ret = err(opt, _("Unable to add %s to database"),
2131-
path);
2113+
ret = error(_("unable to add %s to database"), path);
21322114

21332115
free(result_buf.ptr);
21342116
if (ret)
@@ -3342,10 +3324,7 @@ static int collect_renames(struct merge_options *opt,
33423324
return clean;
33433325
}
33443326

3345-
static int detect_and_process_renames(struct merge_options *opt,
3346-
struct tree *merge_base,
3347-
struct tree *side1,
3348-
struct tree *side2)
3327+
static int detect_and_process_renames(struct merge_options *opt)
33493328
{
33503329
struct diff_queue_struct combined = { 0 };
33513330
struct rename_info *renames = &opt->priv->renames;
@@ -3509,19 +3488,18 @@ static int sort_dirs_next_to_their_children(const char *one, const char *two)
35093488
return c1 - c2;
35103489
}
35113490

3512-
static int read_oid_strbuf(struct merge_options *opt,
3513-
const struct object_id *oid,
3491+
static int read_oid_strbuf(const struct object_id *oid,
35143492
struct strbuf *dst)
35153493
{
35163494
void *buf;
35173495
enum object_type type;
35183496
unsigned long size;
35193497
buf = repo_read_object_file(the_repository, oid, &type, &size);
35203498
if (!buf)
3521-
return err(opt, _("cannot read object %s"), oid_to_hex(oid));
3499+
return error(_("cannot read object %s"), oid_to_hex(oid));
35223500
if (type != OBJ_BLOB) {
35233501
free(buf);
3524-
return err(opt, _("object %s is not a blob"), oid_to_hex(oid));
3502+
return error(_("object %s is not a blob"), oid_to_hex(oid));
35253503
}
35263504
strbuf_attach(dst, buf, size, size + 1);
35273505
return 0;
@@ -3545,8 +3523,8 @@ static int blob_unchanged(struct merge_options *opt,
35453523
if (oideq(&base->oid, &side->oid))
35463524
return 1;
35473525

3548-
if (read_oid_strbuf(opt, &base->oid, &basebuf) ||
3549-
read_oid_strbuf(opt, &side->oid, &sidebuf))
3526+
if (read_oid_strbuf(&base->oid, &basebuf) ||
3527+
read_oid_strbuf(&side->oid, &sidebuf))
35503528
goto error_return;
35513529
/*
35523530
* Note: binary | is used so that both renormalizations are
@@ -4902,8 +4880,7 @@ static void merge_start(struct merge_options *opt, struct merge_result *result)
49024880
trace2_region_leave("merge", "allocate/init", opt->repo);
49034881
}
49044882

4905-
static void merge_check_renames_reusable(struct merge_options *opt,
4906-
struct merge_result *result,
4883+
static void merge_check_renames_reusable(struct merge_result *result,
49074884
struct tree *merge_base,
49084885
struct tree *side1,
49094886
struct tree *side2)
@@ -4973,7 +4950,7 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,
49734950
* TRANSLATORS: The %s arguments are: 1) tree hash of a merge
49744951
* base, and 2-3) the trees for the two trees we're merging.
49754952
*/
4976-
err(opt, _("collecting merge info failed for trees %s, %s, %s"),
4953+
error(_("collecting merge info failed for trees %s, %s, %s"),
49774954
oid_to_hex(&merge_base->object.oid),
49784955
oid_to_hex(&side1->object.oid),
49794956
oid_to_hex(&side2->object.oid));
@@ -4983,8 +4960,7 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,
49834960
trace2_region_leave("merge", "collect_merge_info", opt->repo);
49844961

49854962
trace2_region_enter("merge", "renames", opt->repo);
4986-
result->clean = detect_and_process_renames(opt, merge_base,
4987-
side1, side2);
4963+
result->clean = detect_and_process_renames(opt);
49884964
trace2_region_leave("merge", "renames", opt->repo);
49894965
if (opt->priv->renames.redo_after_renames == 2) {
49904966
trace2_region_enter("merge", "reset_maps", opt->repo);
@@ -5106,7 +5082,7 @@ void merge_incore_nonrecursive(struct merge_options *opt,
51065082

51075083
trace2_region_enter("merge", "merge_start", opt->repo);
51085084
assert(opt->ancestor != NULL);
5109-
merge_check_renames_reusable(opt, result, merge_base, side1, side2);
5085+
merge_check_renames_reusable(result, merge_base, side1, side2);
51105086
merge_start(opt, result);
51115087
/*
51125088
* Record the trees used in this merge, so if there's a next merge in

merge-recursive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,12 +1383,12 @@ static int merge_mode_and_contents(struct merge_options *opt,
13831383
extra_marker_size);
13841384

13851385
if ((merge_status < 0) || !result_buf.ptr)
1386-
ret = err(opt, _("Failed to execute internal merge"));
1386+
ret = err(opt, _("failed to execute internal merge"));
13871387

13881388
if (!ret &&
13891389
write_object_file(result_buf.ptr, result_buf.size,
13901390
OBJ_BLOB, &result->blob.oid))
1391-
ret = err(opt, _("Unable to add %s to database"),
1391+
ret = err(opt, _("unable to add %s to database"),
13921392
a->path);
13931393

13941394
free(result_buf.ptr);

t/t6406-merge-attr.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ test_expect_success !WINDOWS 'custom merge driver that is killed with a signal'
179179
180180
>./please-abort &&
181181
echo "* merge=custom" >.gitattributes &&
182-
test_must_fail git merge main &&
182+
test_must_fail git merge main 2>err &&
183+
grep "^error: failed to execute internal merge" err &&
183184
git ls-files -u >output &&
184185
git diff --name-only HEAD >>output &&
185186
test_must_be_empty output

0 commit comments

Comments
 (0)