const char *old_target UNUSED,
const char *new_target UNUSED,
enum ref_transaction_error err,
- const char *details UNUSED,
+ const char *details,
void *cb_data)
{
struct strmap *failed_refs = cb_data;
+ if (details)
+ rp_error("%s", details);
+
strmap_put(failed_refs, refname, (char *)ref_transaction_error_msg(err));
}
}
ref_transaction_for_each_rejected_update(transaction,
+
ref_transaction_rejection_handler,
&failed_refs);
if (reported_error)
cmd->error_string = reported_error;
else if (strmap_contains(&failed_refs, cmd->ref_name))
- cmd->error_string = strmap_get(&failed_refs, cmd->ref_name);
+ cmd->error_string = cmd->error_string_owned = xstrdup(strmap_get(&failed_refs, cmd->ref_name));
}
cleanup:
git push testrepo :refs/heads/branch/conflict refs/heads/branch
'
+test_expect_success 'pushing non-commit objects should report error' '
+ test_when_finished "rm -rf dest repo" &&
+ git init dest &&
+ git init repo &&
+
+ (
+ cd repo &&
+ test_commit --annotate test &&
+
+ tagsha=$(git rev-parse test^{tag}) &&
+ test_must_fail git push ../dest "$tagsha:refs/heads/branch" 2>err &&
+ test_grep "trying to write non-commit object $tagsha to branch ${SQ}refs/heads/branch${SQ}" err
+ )
+'
+
test_done