]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ab/fetch-prune'
authorJunio C Hamano <gitster@pobox.com>
Tue, 6 Mar 2018 22:54:01 +0000 (14:54 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Mar 2018 22:54:01 +0000 (14:54 -0800)
Clarify how configured fetch refspecs interact with the "--prune"
option of "git fetch", and also add a handy short-hand for getting
rid of stale tags that are locally held.

* ab/fetch-prune:
  fetch: make the --prune-tags work with <url>
  fetch: add a --prune-tags option and fetch.pruneTags config
  fetch tests: add scaffolding for the new fetch.pruneTags
  git-fetch & config doc: link to the new PRUNING section
  git remote doc: correct dangerous lies about what prune does
  git fetch doc: add a new section to explain the ins & outs of pruning
  fetch tests: fetch <url> <spec> as well as fetch [<remote>]
  fetch tests: expand case/esac for later change
  fetch tests: double quote a variable for interpolation
  fetch tests: test --prune and refspec interaction
  fetch tests: add a tag to be deleted to the pruning tests
  fetch tests: re-arrange arguments for future readability
  fetch tests: refactor in preparation for testing tag pruning
  remote: add a macro for "refs/tags/*:refs/tags/*"
  fetch: stop accessing "remote" variable indirectly
  fetch: trivially refactor assignment to ref_nr
  fetch: don't redundantly NULL something calloc() gave us

1  2 
Documentation/config.txt
builtin/fetch.c
contrib/completion/git-completion.bash
t/t5510-fetch.sh

Simple merge
diff --cc builtin/fetch.c
index 8ee998ea2ee8f736a49afe285d31b0be478cf15b,c96f17a9a3c39d9f66439b7ca12e649c46a20a76..d32d94692c7eae8372c4a8abac45f172e6693247
@@@ -1273,57 -1278,7 +1286,57 @@@ static int fetch_multiple(struct string
        return result;
  }
  
- static int fetch_one(struct remote *remote, int argc, const char **argv)
 +/*
 + * Fetching from the promisor remote should use the given filter-spec
 + * or inherit the default filter-spec from the config.
 + */
 +static inline void fetch_one_setup_partial(struct remote *remote)
 +{
 +      /*
 +       * Explicit --no-filter argument overrides everything, regardless
 +       * of any prior partial clones and fetches.
 +       */
 +      if (filter_options.no_filter)
 +              return;
 +
 +      /*
 +       * If no prior partial clone/fetch and the current fetch DID NOT
 +       * request a partial-fetch, do a normal fetch.
 +       */
 +      if (!repository_format_partial_clone && !filter_options.choice)
 +              return;
 +
 +      /*
 +       * If this is the FIRST partial-fetch request, we enable partial
 +       * on this repo and remember the given filter-spec as the default
 +       * for subsequent fetches to this remote.
 +       */
 +      if (!repository_format_partial_clone && filter_options.choice) {
 +              partial_clone_register(remote->name, &filter_options);
 +              return;
 +      }
 +
 +      /*
 +       * We are currently limited to only ONE promisor remote and only
 +       * allow partial-fetches from the promisor remote.
 +       */
 +      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"));
 +              return;
 +      }
 +
 +      /*
 +       * Do a partial-fetch from the promisor remote using either the
 +       * explicitly given filter-spec or inherit the filter-spec from
 +       * the config.
 +       */
 +      if (!filter_options.choice)
 +              partial_clone_get_default_filter_spec(&filter_options);
 +      return;
 +}
 +
+ static int fetch_one(struct remote *remote, int argc, const char **argv, int prune_tags_ok)
  {
        static const char **refs = NULL;
        struct refspec *refspec;
@@@ -1378,8 -1356,8 +1414,9 @@@ int cmd_fetch(int argc, const char **ar
  {
        int i;
        struct string_list list = STRING_LIST_INIT_DUP;
 -      struct remote *remote;
 +      struct remote *remote = NULL;
        int result = 0;
++      int prune_tags_ok = 1;
        struct argv_array argv_gc_auto = ARGV_ARRAY_INIT;
  
        packet_trace_identity("fetch");
                } else {
                        /* Zero or one remotes */
                        remote = remote_get(argv[0]);
 -                      result = fetch_one(remote, argc-1, argv+1, argc == 1);
++                      prune_tags_ok = (argc == 1);
 +                      argc--;
 +                      argv++;
                }
        }
  
-               result = fetch_one(remote, argc, argv);
 +      if (remote) {
 +              if (filter_options.choice || repository_format_partial_clone)
 +                      fetch_one_setup_partial(remote);
++              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"));
 +              /* TODO should this also die if we have a previous partial-clone? */
 +              result = fetch_multiple(&list);
 +      }
 +
        if (!result && (recurse_submodules != RECURSE_SUBMODULES_OFF)) {
                struct argv_array options = ARGV_ARRAY_INIT;
  
Simple merge