Merge branch 'ae/anon-fetch-info'
authorJunio C Hamano <gitster@pobox.com>
Mon, 18 May 2009 15:59:27 +0000 (08:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 18 May 2009 15:59:27 +0000 (08:59 -0700)
* ae/anon-fetch-info:
fetch: Strip usernames from url's before storing them

1  2 
builtin-fetch.c
diff --combined builtin-fetch.c
index ec75df0900358598c024d4039068dd2b9ccf6fe5,0bb290bf2f02a84b8c199de43c876bf22089d621..b944cac6e6546164ca41d66662e395de60ee4337
@@@ -289,7 -289,7 +289,7 @@@ static int update_local_ref(struct ref 
        }
  }
  
- static int store_updated_refs(const char *url, const char *remote_name,
+ static int store_updated_refs(const char *raw_url, const char *remote_name,
                struct ref *ref_map)
  {
        FILE *fp;
        char note[1024];
        const char *what, *kind;
        struct ref *rm;
-       char *filename = git_path("FETCH_HEAD");
+       char *url, *filename = git_path("FETCH_HEAD");
  
        fp = fopen(filename, "a");
        if (!fp)
                return error("cannot open %s: %s\n", filename, strerror(errno));
+       url = transport_anonymize_url(raw_url);
        for (rm = ref_map; rm; rm = rm->next) {
                struct ref *ref = NULL;
  
                                                    kind);
                        note_len += sprintf(note + note_len, "'%s' of ", what);
                }
 -              note_len += sprintf(note + note_len, "%.*s", url_len, url);
 -              fprintf(fp, "%s\t%s\t%s\n",
 +              note[note_len] = '\0';
 +              fprintf(fp, "%s\t%s\t%s",
                        sha1_to_hex(commit ? commit->object.sha1 :
                                    rm->old_sha1),
                        rm->merge ? "" : "not-for-merge",
                        note);
 +              for (i = 0; i < url_len; ++i)
 +                      if ('\n' == url[i])
 +                              fputs("\\n", fp);
 +                      else
 +                              fputc(url[i], fp);
 +              fputc('\n', fp);
  
                if (ref)
                        rc |= update_local_ref(ref, what, note);
                                fprintf(stderr, " %s\n", note);
                }
        }
+       free(url);
        fclose(fp);
        if (rc & 2)
                error("some local refs could not be updated; try running\n"