transport-helper: warn when export-marks file cannot be finalized

When push_refs_with_export() finalizes a successful push, it writes the fast-export marks file to a .tmp sibling and rename()s it into place. The return value of rename() is currently ignored. If the rename fails (permission denied, full disk, or an antivirus product locking the destination on Windows), the .tmp file is left behind and the existing export_marks file remains stale; the next fast-export operation that resumes from it then silently operates on inconsistent bookkeeping. The push itself succeeded by that point, so promoting this to a fatal error would be inappropriate. Emit warning_errno() naming both paths so the user can recover manually, and keep returning 0. Flagged by Coverity as CID 1427723 ("Unchecked return value"). Assisted-by: Opus 4.7 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 14, 2026 at 22:48 UTC ac767de26c50e275785bbe842f8d51c455668352
1 file changed +3 -1
transport-helper.c
+3 -1
@@ -1184,7 +1184,9 @@ static int push_refs_with_export(struct transport *transport,
1184
1185 if (data->export_marks) {
1186 strbuf_addf(&buf, "%s.tmp", data->export_marks);
1187 - rename(buf.buf, data->export_marks);
1187 + if (rename(buf.buf, data->export_marks))
1188 + warning_errno(_("could not rename '%s' to '%s'"),
1189 + buf.buf, data->export_marks);
1190 strbuf_release(&buf);
1191 }
1192