Skip to content

Commit 2c42fb7

Browse files
committed
Merge branch 'js/anonymise-push-url-in-errors'
Error and verbose trace messages from "git push" did not redact credential material embedded in URLs. * js/anonymise-push-url-in-errors: push: anonymize URLs in error messages and warnings
2 parents dd094c2 + d192fa5 commit 2c42fb7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

builtin/push.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
340340
{
341341
int err;
342342
unsigned int reject_reasons;
343+
char *anon_url = transport_anonymize_url(transport->url);
343344

344345
transport_set_verbosity(transport, verbosity, progress);
345346
transport->family = family;
@@ -357,18 +358,19 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
357358
}
358359

359360
if (verbosity > 0)
360-
fprintf(stderr, _("Pushing to %s\n"), transport->url);
361+
fprintf(stderr, _("Pushing to %s\n"), anon_url);
361362
trace2_region_enter("push", "transport_push", the_repository);
362363
err = transport_push(the_repository, transport,
363364
rs, flags, &reject_reasons);
364365
trace2_region_leave("push", "transport_push", the_repository);
365366
if (err != 0) {
366367
fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
367-
error(_("failed to push some refs to '%s'"), transport->url);
368+
error(_("failed to push some refs to '%s'"), anon_url);
368369
fprintf(stderr, "%s", push_get_color(PUSH_COLOR_RESET));
369370
}
370371

371372
err |= transport_disconnect(transport);
373+
free(anon_url);
372374
if (!err)
373375
return 0;
374376

0 commit comments

Comments
 (0)