Merge branch 'jk/push-scrub-url' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 8 Aug 2016 21:21:34 +0000 (14:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Aug 2016 21:21:34 +0000 (14:21 -0700)
"git fetch http://user:pass@host/repo..." scrubbed the userinfo
part, but "git push" didn't.

* jk/push-scrub-url:
t5541: fix url scrubbing test when GPG is not set
push: anonymize URL in status output

t/t5541-http-push-smart.sh
transport.c
index fd7d06b9a23664d0e20cc32a03955ff8816cac7f..9593fc17f36650f8e02fdae1dafd1419d84f71f3 100755 (executable)
@@ -368,5 +368,14 @@ test_expect_success GPG 'push with post-receive to inspect certificate' '
        test_cmp expect "$HTTPD_DOCUMENT_ROOT_PATH/push-cert-status"
 '
 
+test_expect_success 'push status output scrubs password' '
+       cd "$ROOT_PATH/test_repo_clone" &&
+       git push --porcelain \
+               "$HTTPD_URL_USER_PASS/smart/test_repo.git" \
+               +HEAD:scrub >status &&
+       # should have been scrubbed down to vanilla URL
+       grep "^To $HTTPD_URL/smart/test_repo.git" status
+'
+
 stop_httpd
 test_done
index 095e61f0adde0741a3c95817f10df4b957d473ee..be4a63ec1952f7eeb59ea24cdc6835e7d0ba70f9 100644 (file)
@@ -359,8 +359,11 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
 
 static int print_one_push_status(struct ref *ref, const char *dest, int count, int porcelain)
 {
-       if (!count)
-               fprintf(porcelain ? stdout : stderr, "To %s\n", dest);
+       if (!count) {
+               char *url = transport_anonymize_url(dest);
+               fprintf(porcelain ? stdout : stderr, "To %s\n", url);
+               free(url);
+       }
 
        switch(ref->status) {
        case REF_STATUS_NONE: