Skip to content

Commit d192fa5

Browse files
dschogitster
authored andcommitted
push: anonymize URLs in error messages and warnings
Just like 47abd85 (fetch: Strip usernames from url's before storing them, 2009-04-17) and later 882d49c (push: anonymize URL in status output, 2016-07-13), and even later c1284b2 (curl: anonymize URLs in error messages and warnings, 2019-03-04) this change anonymizes URLs (read: strips them of user names and especially passwords) in user-facing error messages and warnings. Signed-off-by: Johannes Schindelin <[email protected]> Reviewed-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7397ca3 commit d192fa5

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)