mirror of
https://github.com/git/git
synced 2024-10-02 14:45:21 +00:00
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
This commit is contained in:
commit
fb6e6e06d5
48
merge-ort.c
48
merge-ort.c
|
@ -721,23 +721,6 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
|
|||
renames->callback_data_nr = renames->callback_data_alloc = 0;
|
||||
}
|
||||
|
||||
__attribute__((format (printf, 2, 3)))
|
||||
static int err(struct merge_options *opt, const char *err, ...)
|
||||
{
|
||||
va_list params;
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
strbuf_addstr(&sb, "error: ");
|
||||
va_start(params, err);
|
||||
strbuf_vaddf(&sb, err, params);
|
||||
va_end(params);
|
||||
|
||||
error("%s", sb.buf);
|
||||
strbuf_release(&sb);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void format_commit(struct strbuf *sb,
|
||||
int indent,
|
||||
struct repository *repo,
|
||||
|
@ -2122,13 +2105,12 @@ static int handle_content_merge(struct merge_options *opt,
|
|||
&result_buf);
|
||||
|
||||
if ((merge_status < 0) || !result_buf.ptr)
|
||||
ret = err(opt, _("Failed to execute internal merge"));
|
||||
ret = error(_("failed to execute internal merge"));
|
||||
|
||||
if (!ret &&
|
||||
write_object_file(result_buf.ptr, result_buf.size,
|
||||
OBJ_BLOB, &result->oid))
|
||||
ret = err(opt, _("Unable to add %s to database"),
|
||||
path);
|
||||
ret = error(_("unable to add %s to database"), path);
|
||||
|
||||
free(result_buf.ptr);
|
||||
if (ret)
|
||||
|
@ -3342,10 +3324,7 @@ static int collect_renames(struct merge_options *opt,
|
|||
return clean;
|
||||
}
|
||||
|
||||
static int detect_and_process_renames(struct merge_options *opt,
|
||||
struct tree *merge_base,
|
||||
struct tree *side1,
|
||||
struct tree *side2)
|
||||
static int detect_and_process_renames(struct merge_options *opt)
|
||||
{
|
||||
struct diff_queue_struct combined = { 0 };
|
||||
struct rename_info *renames = &opt->priv->renames;
|
||||
|
@ -3509,8 +3488,7 @@ static int sort_dirs_next_to_their_children(const char *one, const char *two)
|
|||
return c1 - c2;
|
||||
}
|
||||
|
||||
static int read_oid_strbuf(struct merge_options *opt,
|
||||
const struct object_id *oid,
|
||||
static int read_oid_strbuf(const struct object_id *oid,
|
||||
struct strbuf *dst)
|
||||
{
|
||||
void *buf;
|
||||
|
@ -3518,10 +3496,10 @@ static int read_oid_strbuf(struct merge_options *opt,
|
|||
unsigned long size;
|
||||
buf = repo_read_object_file(the_repository, oid, &type, &size);
|
||||
if (!buf)
|
||||
return err(opt, _("cannot read object %s"), oid_to_hex(oid));
|
||||
return error(_("cannot read object %s"), oid_to_hex(oid));
|
||||
if (type != OBJ_BLOB) {
|
||||
free(buf);
|
||||
return err(opt, _("object %s is not a blob"), oid_to_hex(oid));
|
||||
return error(_("object %s is not a blob"), oid_to_hex(oid));
|
||||
}
|
||||
strbuf_attach(dst, buf, size, size + 1);
|
||||
return 0;
|
||||
|
@ -3545,8 +3523,8 @@ static int blob_unchanged(struct merge_options *opt,
|
|||
if (oideq(&base->oid, &side->oid))
|
||||
return 1;
|
||||
|
||||
if (read_oid_strbuf(opt, &base->oid, &basebuf) ||
|
||||
read_oid_strbuf(opt, &side->oid, &sidebuf))
|
||||
if (read_oid_strbuf(&base->oid, &basebuf) ||
|
||||
read_oid_strbuf(&side->oid, &sidebuf))
|
||||
goto error_return;
|
||||
/*
|
||||
* 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)
|
|||
trace2_region_leave("merge", "allocate/init", opt->repo);
|
||||
}
|
||||
|
||||
static void merge_check_renames_reusable(struct merge_options *opt,
|
||||
struct merge_result *result,
|
||||
static void merge_check_renames_reusable(struct merge_result *result,
|
||||
struct tree *merge_base,
|
||||
struct tree *side1,
|
||||
struct tree *side2)
|
||||
|
@ -4973,7 +4950,7 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,
|
|||
* TRANSLATORS: The %s arguments are: 1) tree hash of a merge
|
||||
* base, and 2-3) the trees for the two trees we're merging.
|
||||
*/
|
||||
err(opt, _("collecting merge info failed for trees %s, %s, %s"),
|
||||
error(_("collecting merge info failed for trees %s, %s, %s"),
|
||||
oid_to_hex(&merge_base->object.oid),
|
||||
oid_to_hex(&side1->object.oid),
|
||||
oid_to_hex(&side2->object.oid));
|
||||
|
@ -4983,8 +4960,7 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,
|
|||
trace2_region_leave("merge", "collect_merge_info", opt->repo);
|
||||
|
||||
trace2_region_enter("merge", "renames", opt->repo);
|
||||
result->clean = detect_and_process_renames(opt, merge_base,
|
||||
side1, side2);
|
||||
result->clean = detect_and_process_renames(opt);
|
||||
trace2_region_leave("merge", "renames", opt->repo);
|
||||
if (opt->priv->renames.redo_after_renames == 2) {
|
||||
trace2_region_enter("merge", "reset_maps", opt->repo);
|
||||
|
@ -5106,7 +5082,7 @@ void merge_incore_nonrecursive(struct merge_options *opt,
|
|||
|
||||
trace2_region_enter("merge", "merge_start", opt->repo);
|
||||
assert(opt->ancestor != NULL);
|
||||
merge_check_renames_reusable(opt, result, merge_base, side1, side2);
|
||||
merge_check_renames_reusable(result, merge_base, side1, side2);
|
||||
merge_start(opt, result);
|
||||
/*
|
||||
* Record the trees used in this merge, so if there's a next merge in
|
||||
|
|
|
@ -1383,12 +1383,12 @@ static int merge_mode_and_contents(struct merge_options *opt,
|
|||
extra_marker_size);
|
||||
|
||||
if ((merge_status < 0) || !result_buf.ptr)
|
||||
ret = err(opt, _("Failed to execute internal merge"));
|
||||
ret = err(opt, _("failed to execute internal merge"));
|
||||
|
||||
if (!ret &&
|
||||
write_object_file(result_buf.ptr, result_buf.size,
|
||||
OBJ_BLOB, &result->blob.oid))
|
||||
ret = err(opt, _("Unable to add %s to database"),
|
||||
ret = err(opt, _("unable to add %s to database"),
|
||||
a->path);
|
||||
|
||||
free(result_buf.ptr);
|
||||
|
|
|
@ -179,7 +179,8 @@ test_expect_success !WINDOWS 'custom merge driver that is killed with a signal'
|
|||
|
||||
>./please-abort &&
|
||||
echo "* merge=custom" >.gitattributes &&
|
||||
test_must_fail git merge main &&
|
||||
test_must_fail git merge main 2>err &&
|
||||
grep "^error: failed to execute internal merge" err &&
|
||||
git ls-files -u >output &&
|
||||
git diff --name-only HEAD >>output &&
|
||||
test_must_be_empty output
|
||||
|
|
Loading…
Reference in a new issue