Use 'UTF-8' rather than 'utf-8' everywhere for backward compatibility
[gitweb.git] / builtin-fetch.c
index 0bb290bf2f02a84b8c199de43c876bf22089d621..b944cac6e6546164ca41d66662e395de60ee4337 100644 (file)
@@ -355,12 +355,18 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
                                                    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);