Merge branch 'sb/submodule-cleanup-export-git-dir-env'
[gitweb.git] / builtin / fetch.c
index 74c0546362d9a6aab185f2a4327cd489a91a3f89..f1570e346434e8695e80ba568c28b1363b2c0cb5 100644 (file)
@@ -122,7 +122,7 @@ static struct option builtin_fetch_options[] = {
        OPT_STRING(0, "shallow-since", &deepen_since, N_("time"),
                   N_("deepen history of shallow repository based on time")),
        OPT_STRING_LIST(0, "shallow-exclude", &deepen_not, N_("revision"),
-                       N_("deepen history of shallow clone by excluding rev")),
+                       N_("deepen history of shallow clone, excluding rev")),
        OPT_INTEGER(0, "deepen", &deepen_relative,
                    N_("deepen history of shallow clone")),
        { OPTION_SET_INT, 0, "unshallow", &unshallow, NULL,
@@ -359,9 +359,6 @@ static struct ref *get_ref_map(struct transport *transport,
 
                for (i = 0; i < fetch_refspec_nr; i++)
                        get_fetch_map(ref_map, &fetch_refspec[i], &oref_tail, 1);
-
-               if (tags == TAGS_SET)
-                       get_fetch_map(remote_refs, tag_refspec, &tail, 0);
        } else if (refmap_array) {
                die("--refmap option is only meaningful with command-line refspec(s).");
        } else {
@@ -577,9 +574,12 @@ static void print_compact(struct strbuf *display,
 
 static void format_display(struct strbuf *display, char code,
                           const char *summary, const char *error,
-                          const char *remote, const char *local)
+                          const char *remote, const char *local,
+                          int summary_width)
 {
-       strbuf_addf(display, "%c %-*s ", code, TRANSPORT_SUMMARY(summary));
+       int width = (summary_width + strlen(summary) - gettext_width(summary));
+
+       strbuf_addf(display, "%c %-*s ", code, width, summary);
        if (!compact_format)
                print_remote_to_local(display, remote, local);
        else
@@ -591,7 +591,8 @@ static void format_display(struct strbuf *display, char code,
 static int update_local_ref(struct ref *ref,
                            const char *remote,
                            const struct ref *remote_ref,
-                           struct strbuf *display)
+                           struct strbuf *display,
+                           int summary_width)
 {
        struct commit *current = NULL, *updated;
        enum object_type type;
@@ -605,7 +606,7 @@ static int update_local_ref(struct ref *ref,
        if (!oidcmp(&ref->old_oid, &ref->new_oid)) {
                if (verbosity > 0)
                        format_display(display, '=', _("[up to date]"), NULL,
-                                      remote, pretty_ref);
+                                      remote, pretty_ref, summary_width);
                return 0;
        }
 
@@ -619,7 +620,7 @@ static int update_local_ref(struct ref *ref,
                 */
                format_display(display, '!', _("[rejected]"),
                               _("can't fetch in current branch"),
-                              remote, pretty_ref);
+                              remote, pretty_ref, summary_width);
                return 1;
        }
 
@@ -629,7 +630,7 @@ static int update_local_ref(struct ref *ref,
                r = s_update_ref("updating tag", ref, 0);
                format_display(display, r ? '!' : 't', _("[tag update]"),
                               r ? _("unable to update local ref") : NULL,
-                              remote, pretty_ref);
+                              remote, pretty_ref, summary_width);
                return r;
        }
 
@@ -662,7 +663,7 @@ static int update_local_ref(struct ref *ref,
                r = s_update_ref(msg, ref, 0);
                format_display(display, r ? '!' : '*', what,
                               r ? _("unable to update local ref") : NULL,
-                              remote, pretty_ref);
+                              remote, pretty_ref, summary_width);
                return r;
        }
 
@@ -678,7 +679,7 @@ static int update_local_ref(struct ref *ref,
                r = s_update_ref("fast-forward", ref, 1);
                format_display(display, r ? '!' : ' ', quickref.buf,
                               r ? _("unable to update local ref") : NULL,
-                              remote, pretty_ref);
+                              remote, pretty_ref, summary_width);
                strbuf_release(&quickref);
                return r;
        } else if (force || ref->force) {
@@ -693,12 +694,12 @@ static int update_local_ref(struct ref *ref,
                r = s_update_ref("forced-update", ref, 1);
                format_display(display, r ? '!' : '+', quickref.buf,
                               r ? _("unable to update local ref") : _("forced update"),
-                              remote, pretty_ref);
+                              remote, pretty_ref, summary_width);
                strbuf_release(&quickref);
                return r;
        } else {
                format_display(display, '!', _("[rejected]"), _("non-fast-forward"),
-                              remote, pretty_ref);
+                              remote, pretty_ref, summary_width);
                return 1;
        }
 }
@@ -729,6 +730,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
        char *url;
        const char *filename = dry_run ? "/dev/null" : git_path_fetch_head();
        int want_status;
+       int summary_width = transport_summary_width(ref_map);
 
        fp = fopen(filename, "a");
        if (!fp)
@@ -838,13 +840,14 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
 
                        strbuf_reset(&note);
                        if (ref) {
-                               rc |= update_local_ref(ref, what, rm, &note);
+                               rc |= update_local_ref(ref, what, rm, &note,
+                                                      summary_width);
                                free(ref);
                        } else
                                format_display(&note, '*',
                                               *kind ? kind : "branch", NULL,
                                               *what ? what : "HEAD",
-                                              "FETCH_HEAD");
+                                              "FETCH_HEAD", summary_width);
                        if (note.len) {
                                if (verbosity >= 0 && !shown_url) {
                                        fprintf(stderr, _("From %.*s\n"),
@@ -911,6 +914,7 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
        int url_len, i, result = 0;
        struct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);
        char *url;
+       int summary_width = transport_summary_width(stale_refs);
        const char *dangling_msg = dry_run
                ? _("   (%s will become dangling)")
                : _("   (%s has become dangling)");
@@ -946,7 +950,8 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
                                shown_url = 1;
                        }
                        format_display(&sb, '-', _("[deleted]"), NULL,
-                                      _("(none)"), prettify_refname(ref->name));
+                                      _("(none)"), prettify_refname(ref->name),
+                                      summary_width);
                        fprintf(stderr, " %s\n",sb.buf);
                        strbuf_release(&sb);
                        warn_dangling_symref(stderr, dangling_msg, ref->name);