@matheusbsbs / matheus-bagliano / commits / d192fa5006
Fork 0

push: anonymize URLs in error messages and warnings

Just like 47abd85ba0 (fetch: Strip usernames from url's before storing them, 2009-04-17) and later 882d49ca5c (push: anonymize URL in status output, 2016-07-13), and even later c1284b21f243 (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 <johannes.schindelin@gmx.de> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Apr 24, 2020 at 14:20 UTC d192fa50067d1630312a966aba22c90139812fc5
1 file changed +4 -2
builtin/push.c
+4 -2
@@ -340,6 +340,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
340 {
341 int err;
342 unsigned int reject_reasons;
343 + char *anon_url = transport_anonymize_url(transport->url);
344
345 transport_set_verbosity(transport, verbosity, progress);
346 transport->family = family;
@@ -357,18 +358,19 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
358 }
359
360 if (verbosity > 0)
360 - fprintf(stderr, _("Pushing to %s\n"), transport->url);
361 + fprintf(stderr, _("Pushing to %s\n"), anon_url);
362 trace2_region_enter("push", "transport_push", the_repository);
363 err = transport_push(the_repository, transport,
364 rs, flags, &reject_reasons);
365 trace2_region_leave("push", "transport_push", the_repository);
366 if (err != 0) {
367 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);
369 fprintf(stderr, "%s", push_get_color(PUSH_COLOR_RESET));
370 }
371
372 err |= transport_disconnect(transport);
373 + free(anon_url);
374 if (!err)
375 return 0;
376