Merge branch 'ls/convert-filter-progress'
authorJunio C Hamano <gitster@pobox.com>
Sun, 10 Sep 2017 08:08:22 +0000 (17:08 +0900)
committerJunio C Hamano <gitster@pobox.com>
Sun, 10 Sep 2017 08:08:22 +0000 (17:08 +0900)
The codepath to call external process filter for smudge/clean
operation learned to show the progress meter.

* ls/convert-filter-progress:
convert: display progress for filtered objects that have been delayed

1  2 
entry.c
unpack-trees.c
diff --combined entry.c
index 65458f07a4453fa29731fe2b9c20848d6b192b20,1d1a09f47e80ce0eb454fbe86ab44948fac597a0..cb291aa88bf148608184edeff68943315b44e6ab
+++ b/entry.c
@@@ -3,6 -3,7 +3,7 @@@
  #include "dir.h"
  #include "streaming.h"
  #include "submodule.h"
+ #include "progress.h"
  
  static void create_directories(const char *path, int path_len,
                               const struct checkout *state)
@@@ -161,16 -162,23 +162,22 @@@ static int remove_available_paths(struc
  int finish_delayed_checkout(struct checkout *state)
  {
        int errs = 0;
+       unsigned delayed_object_count;
+       off_t filtered_bytes = 0;
        struct string_list_item *filter, *path;
+       struct progress *progress;
        struct delayed_checkout *dco = state->delayed_checkout;
  
        if (!state->delayed_checkout)
                return errs;
  
        dco->state = CE_RETRY;
 -      progress = start_progress_delay(
 -              _("Filtering content"), delayed_object_count, 50, 1);
+       delayed_object_count = dco->paths.nr;
++      progress = start_delayed_progress(_("Filtering content"), delayed_object_count);
        while (dco->filters.nr > 0) {
                for_each_string_list_item(filter, &dco->filters) {
                        struct string_list available_paths = STRING_LIST_INIT_NODUP;
+                       display_progress(progress, delayed_object_count - dco->paths.nr);
  
                        if (!async_query_available_blobs(filter->string, &available_paths)) {
                                /* Filter reported an error */
                                }
                                ce = index_file_exists(state->istate, path->string,
                                                       strlen(path->string), 0);
-                               errs |= (ce ? checkout_entry(ce, state, NULL) : 1);
+                               if (ce) {
+                                       errs |= checkout_entry(ce, state, NULL);
+                                       filtered_bytes += ce->ce_stat_data.sd_size;
+                                       display_throughput(progress, filtered_bytes);
+                               } else
+                                       errs = 1;
                        }
                }
                string_list_remove_empty_items(&dco->filters, 0);
        }
+       stop_progress(&progress);
        string_list_clear(&dco->filters, 0);
  
        /* At this point we should not have any delayed paths anymore. */
diff --combined unpack-trees.c
index 87e8c695971c470657fdd0b9fe29555e14604edd,0013a1194f15fe23dc8ce4014c885ad7bdb6cdfb..71b70ccb12756cde1f1c5aeda952be6e2b91f5b8
@@@ -1,6 -1,5 +1,6 @@@
  #define NO_THE_INDEX_COMPATIBILITY_MACROS
  #include "cache.h"
 +#include "repository.h"
  #include "config.h"
  #include "dir.h"
  #include "tree.h"
@@@ -163,7 -162,7 +163,7 @@@ void setup_unpack_trees_porcelain(struc
        msgs[ERROR_BIND_OVERLAP] = _("Entry '%s' overlaps with '%s'.  Cannot bind.");
  
        msgs[ERROR_SPARSE_NOT_UPTODATE_FILE] =
 -              _("Cannot update sparse checkout: the following entries are not up-to-date:\n%s");
 +              _("Cannot update sparse checkout: the following entries are not up to date:\n%s");
        msgs[ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN] =
                _("The following working tree files would be overwritten by sparse checkout update:\n%s");
        msgs[ERROR_WOULD_LOSE_ORPHANED_REMOVED] =
@@@ -256,41 -255,47 +256,41 @@@ static int check_submodule_move_head(co
  {
        unsigned flags = SUBMODULE_MOVE_HEAD_DRY_RUN;
        const struct submodule *sub = submodule_from_ce(ce);
 +
        if (!sub)
                return 0;
  
        if (o->reset)
                flags |= SUBMODULE_MOVE_HEAD_FORCE;
  
 -      switch (sub->update_strategy.type) {
 -      case SM_UPDATE_UNSPECIFIED:
 -      case SM_UPDATE_CHECKOUT:
 -              if (submodule_move_head(ce->name, old_id, new_id, flags))
 -                      return o->gently ? -1 :
 -                              add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name);
 -              return 0;
 -      case SM_UPDATE_NONE:
 -              return 0;
 -      case SM_UPDATE_REBASE:
 -      case SM_UPDATE_MERGE:
 -      case SM_UPDATE_COMMAND:
 -      default:
 -              warning(_("submodule update strategy not supported for submodule '%s'"), ce->name);
 -              return -1;
 -      }
 +      if (submodule_move_head(ce->name, old_id, new_id, flags))
 +              return o->gently ? -1 :
 +                                 add_rejected_path(o, ERROR_WOULD_LOSE_SUBMODULE, ce->name);
 +      return 0;
  }
  
 -static void reload_gitmodules_file(struct index_state *index,
 -                                 struct checkout *state)
 +/*
 + * Preform the loading of the repository's gitmodules file.  This function is
 + * used by 'check_update()' to perform loading of the gitmodules file in two
 + * differnt situations:
 + * (1) before removing entries from the working tree if the gitmodules file has
 + *     been marked for removal.  This situation is specified by 'state' == NULL.
 + * (2) before checking out entries to the working tree if the gitmodules file
 + *     has been marked for update.  This situation is specified by 'state' != NULL.
 + */
 +static void load_gitmodules_file(struct index_state *index,
 +                               struct checkout *state)
  {
 -      int i;
 -      for (i = 0; i < index->cache_nr; i++) {
 -              struct cache_entry *ce = index->cache[i];
 -              if (ce->ce_flags & CE_UPDATE) {
 -                      int r = strcmp(ce->name, GITMODULES_FILE);
 -                      if (r < 0)
 -                              continue;
 -                      else if (r == 0) {
 -                              submodule_free();
 -                              checkout_entry(ce, state, NULL);
 -                              gitmodules_config();
 -                              git_config(submodule_config, NULL);
 -                      } else
 -                              break;
 +      int pos = index_name_pos(index, GITMODULES_FILE, strlen(GITMODULES_FILE));
 +
 +      if (pos >= 0) {
 +              struct cache_entry *ce = index->cache[pos];
 +              if (!state && ce->ce_flags & CE_WT_REMOVE) {
 +                      repo_read_gitmodules(the_repository);
 +              } else if (state && (ce->ce_flags & CE_UPDATE)) {
 +                      submodule_free();
 +                      checkout_entry(ce, state, NULL);
 +                      repo_read_gitmodules(the_repository);
                }
        }
  }
@@@ -303,9 -308,19 +303,9 @@@ static void unlink_entry(const struct c
  {
        const struct submodule *sub = submodule_from_ce(ce);
        if (sub) {
 -              switch (sub->update_strategy.type) {
 -              case SM_UPDATE_UNSPECIFIED:
 -              case SM_UPDATE_CHECKOUT:
 -              case SM_UPDATE_REBASE:
 -              case SM_UPDATE_MERGE:
 -                      /* state.force is set at the caller. */
 -                      submodule_move_head(ce->name, "HEAD", NULL,
 -                                          SUBMODULE_MOVE_HEAD_FORCE);
 -                      break;
 -              case SM_UPDATE_NONE:
 -              case SM_UPDATE_COMMAND:
 -                      return; /* Do not touch the submodule. */
 -              }
 +              /* state.force is set at the caller. */
 +              submodule_move_head(ce->name, "HEAD", NULL,
 +                                  SUBMODULE_MOVE_HEAD_FORCE);
        }
        if (!check_leading_path(ce->name, ce_namelen(ce)))
                return;
@@@ -349,10 -364,6 +349,10 @@@ static int check_updates(struct unpack_
  
        if (o->update)
                git_attr_set_direction(GIT_ATTR_CHECKOUT, index);
 +
 +      if (should_update_submodules() && o->update && !o->dry_run)
 +              load_gitmodules_file(index, NULL);
 +
        for (i = 0; i < index->cache_nr; i++) {
                const struct cache_entry *ce = index->cache[i];
  
        remove_scheduled_dirs();
  
        if (should_update_submodules() && o->update && !o->dry_run)
 -              reload_gitmodules_file(index, &state);
 +              load_gitmodules_file(index, &state);
  
        enable_delayed_checkout(&state);
        for (i = 0; i < index->cache_nr; i++) {
                        }
                }
        }
-       errs |= finish_delayed_checkout(&state);
        stop_progress(&progress);
+       errs |= finish_delayed_checkout(&state);
        if (o->update)
                git_attr_set_direction(GIT_ATTR_CHECKIN, NULL);
        return errs != 0;