]> git.ipfire.org Git - thirdparty/git.git/commitdiff
push: anonymize URLs in error messages and warnings
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 24 Apr 2020 14:20:08 +0000 (14:20 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Apr 2020 22:17:45 +0000 (15:17 -0700)
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>
builtin/push.c

index 6dbf0f0bb713f167947e8d3d3aa0b8ecae0dc44e..59c8acb556801ab92822e100767d2ccde3921d0b 100644 (file)
@@ -340,6 +340,7 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
 {
        int err;
        unsigned int reject_reasons;
+       char *anon_url = transport_anonymize_url(transport->url);
 
        transport_set_verbosity(transport, verbosity, progress);
        transport->family = family;
@@ -357,18 +358,19 @@ static int push_with_options(struct transport *transport, struct refspec *rs,
        }
 
        if (verbosity > 0)
-               fprintf(stderr, _("Pushing to %s\n"), transport->url);
+               fprintf(stderr, _("Pushing to %s\n"), anon_url);
        trace2_region_enter("push", "transport_push", the_repository);
        err = transport_push(the_repository, transport,
                             rs, flags, &reject_reasons);
        trace2_region_leave("push", "transport_push", the_repository);
        if (err != 0) {
                fprintf(stderr, "%s", push_get_color(PUSH_COLOR_ERROR));
-               error(_("failed to push some refs to '%s'"), transport->url);
+               error(_("failed to push some refs to '%s'"), anon_url);
                fprintf(stderr, "%s", push_get_color(PUSH_COLOR_RESET));
        }
 
        err |= transport_disconnect(transport);
+       free(anon_url);
        if (!err)
                return 0;