]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/fetch.c
refspec: add and use refspec_appendf()
[thirdparty/git.git] / builtin / fetch.c
index 320ba9471dee36fc82eb36a1b24af0c1918cd9d0..c555836937564ddc7551a163fde9ef449c1784eb 100644 (file)
@@ -656,7 +656,7 @@ static void prepare_format_display(struct ref *ref_map)
        struct ref *rm;
        const char *format = "full";
 
-       git_config_get_string_const("fetch.output", &format);
+       git_config_get_string_tmp("fetch.output", &format);
        if (!strcasecmp(format, "full"))
                compact_format = 0;
        else if (!strcasecmp(format, "compact"))
@@ -1023,11 +1023,17 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
                                rc |= update_local_ref(ref, what, rm, &note,
                                                       summary_width);
                                free(ref);
-                       } else
+                       } else if (write_fetch_head || dry_run) {
+                               /*
+                                * Display fetches written to FETCH_HEAD (or
+                                * would be written to FETCH_HEAD, if --dry-run
+                                * is set).
+                                */
                                format_display(&note, '*',
                                               *kind ? kind : "branch", NULL,
                                               *what ? what : "HEAD",
                                               "FETCH_HEAD", summary_width);
+                       }
                        if (note.len) {
                                if (verbosity >= 0 && !shown_url) {
                                        fprintf(stderr, _("From %.*s\n"),
@@ -1732,15 +1738,12 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
 
        for (i = 0; i < argc; i++) {
                if (!strcmp(argv[i], "tag")) {
-                       char *tag;
                        i++;
                        if (i >= argc)
                                die(_("You need to specify a tag name."));
 
-                       tag = xstrfmt("refs/tags/%s:refs/tags/%s",
-                                     argv[i], argv[i]);
-                       refspec_append(&rs, tag);
-                       free(tag);
+                       refspec_appendf(&rs, "refs/tags/%s:refs/tags/%s",
+                                       argv[i], argv[i]);
                } else {
                        refspec_append(&rs, argv[i]);
                }