Merge branch 'nd/fetch-compact-update'
authorJunio C Hamano <gitster@pobox.com>
Tue, 5 Feb 2019 22:26:18 +0000 (14:26 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Feb 2019 22:26:18 +0000 (14:26 -0800)
"git fetch" output cleanup.

* nd/fetch-compact-update:
fetch: prefer suffix substitution in compact fetch.output

1  2 
builtin/fetch.c
diff --combined builtin/fetch.c
index 61a443031d9ace9f2019e1c02ff265e7da0ec960,e0173f8a339c5cd2aff8a9781801cf1a20c2fd5f..39c42106109f35f49550133580bf34b6eb60aa26
@@@ -629,9 -629,14 +629,14 @@@ static int find_and_replace(struct strb
                            const char *needle,
                            const char *placeholder)
  {
-       const char *p = strstr(haystack->buf, needle);
+       const char *p = NULL;
        int plen, nlen;
  
+       nlen = strlen(needle);
+       if (ends_with(haystack->buf, needle))
+               p = haystack->buf + haystack->len - nlen;
+       else
+               p = strstr(haystack->buf, needle);
        if (!p)
                return 0;
  
                return 0;
  
        plen = strlen(p);
-       nlen = strlen(needle);
        if (plen > nlen && p[nlen] != '/')
                return 0;
  
@@@ -763,6 -767,9 +767,6 @@@ static int update_local_ref(struct ref 
                        what = _("[new ref]");
                }
  
 -              if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
 -                  (recurse_submodules != RECURSE_SUBMODULES_ON))
 -                      check_for_new_submodule_commits(&ref->new_oid);
                r = s_update_ref(msg, ref, 0);
                format_display(display, r ? '!' : '*', what,
                               r ? _("unable to update local ref") : NULL,
                strbuf_add_unique_abbrev(&quickref, &current->object.oid, DEFAULT_ABBREV);
                strbuf_addstr(&quickref, "..");
                strbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);
 -              if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
 -                  (recurse_submodules != RECURSE_SUBMODULES_ON))
 -                      check_for_new_submodule_commits(&ref->new_oid);
                r = s_update_ref("fast-forward", ref, 1);
                format_display(display, r ? '!' : ' ', quickref.buf,
                               r ? _("unable to update local ref") : NULL,
                strbuf_add_unique_abbrev(&quickref, &current->object.oid, DEFAULT_ABBREV);
                strbuf_addstr(&quickref, "...");
                strbuf_add_unique_abbrev(&quickref, &ref->new_oid, DEFAULT_ABBREV);
 -              if ((recurse_submodules != RECURSE_SUBMODULES_OFF) &&
 -                  (recurse_submodules != RECURSE_SUBMODULES_ON))
 -                      check_for_new_submodule_commits(&ref->new_oid);
                r = s_update_ref("forced-update", ref, 1);
                format_display(display, r ? '!' : '+', quickref.buf,
                               r ? _("unable to update local ref") : _("forced update"),
@@@ -883,8 -896,6 +887,8 @@@ static int store_updated_refs(const cha
                                ref->force = rm->peer_ref->force;
                        }
  
 +                      if (recurse_submodules != RECURSE_SUBMODULES_OFF)
 +                              check_for_new_submodule_commits(&rm->old_oid);
  
                        if (!strcmp(rm->name, "HEAD")) {
                                kind = "";
@@@ -1165,7 -1176,6 +1169,7 @@@ static void add_negotiation_tips(struc
  static struct transport *prepare_transport(struct remote *remote, int deepen)
  {
        struct transport *transport;
 +
        transport = transport_get(remote, NULL);
        transport_set_verbosity(transport, verbosity, progress);
        transport->family = family;
        if (update_shallow)
                set_option(transport, TRANS_OPT_UPDATE_SHALLOW, "yes");
        if (filter_options.choice) {
 +              struct strbuf expanded_filter_spec = STRBUF_INIT;
 +              expand_list_objects_filter_spec(&filter_options,
 +                                              &expanded_filter_spec);
                set_option(transport, TRANS_OPT_LIST_OBJECTS_FILTER,
 -                         filter_options.filter_spec);
 +                         expanded_filter_spec.buf);
                set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
 +              strbuf_release(&expanded_filter_spec);
        }
        if (negotiation_tip.nr) {
                if (transport->smart_options)
@@@ -1476,8 -1482,7 +1480,8 @@@ static inline void fetch_one_setup_part
         */
        if (strcmp(remote->name, repository_format_partial_clone)) {
                if (filter_options.choice)
 -                      die(_("--filter can only be used with the remote configured in core.partialClone"));
 +                      die(_("--filter can only be used with the remote "
 +                            "configured in extensions.partialclone"));
                return;
        }
  
@@@ -1645,8 -1650,7 +1649,8 @@@ int cmd_fetch(int argc, const char **ar
                result = fetch_one(remote, argc, argv, prune_tags_ok);
        } else {
                if (filter_options.choice)
 -                      die(_("--filter can only be used with the remote configured in core.partialClone"));
 +                      die(_("--filter can only be used with the remote "
 +                            "configured in extensions.partialclone"));
                /* TODO should this also die if we have a previous partial-clone? */
                result = fetch_multiple(&list);
        }