Merge branch 'ls/filter-process'
authorJunio C Hamano <gitster@pobox.com>
Mon, 31 Oct 2016 20:15:21 +0000 (13:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 31 Oct 2016 20:15:21 +0000 (13:15 -0700)
The smudge/clean filter API expect an external process is spawned
to filter the contents for each path that has a filter defined. A
new type of "process" filter API has been added to allow the first
request to run the filter for a path to spawn a single process, and
all filtering need is served by this single process for multiple
paths, reducing the process creation overhead.

* ls/filter-process:
contrib/long-running-filter: add long running filter example
convert: add filter.<driver>.process option
convert: prepare filter.<driver>.process option
convert: make apply_filter() adhere to standard Git error handling
pkt-line: add functions to read/write flush terminated packet streams
pkt-line: add packet_write_gently()
pkt-line: add packet_flush_gently()
pkt-line: add packet_write_fmt_gently()
pkt-line: extract set_packet_header()
pkt-line: rename packet_write() to packet_write_fmt()
run-command: add clean_on_exit_handler
run-command: move check_pipe() from write_or_die to run_command
convert: modernize tests
convert: quote filter names in error messages

1  2 
builtin/receive-pack.c
connect.c
convert.c
daemon.c
shallow.c
upload-pack.c
Simple merge
diff --cc connect.c
Simple merge
diff --cc convert.c
Simple merge
diff --cc daemon.c
Simple merge
diff --cc shallow.c
Simple merge
diff --cc upload-pack.c
index d9e381f29126313aa7068478430dd5e3f704f9ef,cd47de69ab4da0cdb82fe71cda9a82ff0334561a..e0db8b42be2d6ba400da987f8cb2ba573c5eda01
@@@ -633,100 -543,6 +633,100 @@@ error
        }
  }
  
-                       packet_write(1, "shallow %s",
-                                    oid_to_hex(&object->oid));
 +static void send_shallow(struct commit_list *result)
 +{
 +      while (result) {
 +              struct object *object = &result->item->object;
 +              if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
-                       packet_write(1, "unshallow %s",
-                                    oid_to_hex(&object->oid));
++                      packet_write_fmt(1, "shallow %s",
++                                       oid_to_hex(&object->oid));
 +                      register_shallow(object->oid.hash);
 +                      shallow_nr++;
 +              }
 +              result = result->next;
 +      }
 +}
 +
 +static void send_unshallow(const struct object_array *shallows)
 +{
 +      int i;
 +
 +      for (i = 0; i < shallows->nr; i++) {
 +              struct object *object = shallows->objects[i].item;
 +              if (object->flags & NOT_SHALLOW) {
 +                      struct commit_list *parents;
++                      packet_write_fmt(1, "unshallow %s",
++                                       oid_to_hex(&object->oid));
 +                      object->flags &= ~CLIENT_SHALLOW;
 +                      /*
 +                       * We want to _register_ "object" as shallow, but we
 +                       * also need to traverse object's parents to deepen a
 +                       * shallow clone. Unregister it for now so we can
 +                       * parse and add the parents to the want list, then
 +                       * re-register it.
 +                       */
 +                      unregister_shallow(object->oid.hash);
 +                      object->parsed = 0;
 +                      parse_commit_or_die((struct commit *)object);
 +                      parents = ((struct commit *)object)->parents;
 +                      while (parents) {
 +                              add_object_array(&parents->item->object,
 +                                               NULL, &want_obj);
 +                              parents = parents->next;
 +                      }
 +                      add_object_array(object, NULL, &extra_edge_obj);
 +              }
 +              /* make sure commit traversal conforms to client */
 +              register_shallow(object->oid.hash);
 +      }
 +}
 +
 +static void deepen(int depth, int deepen_relative,
 +                 struct object_array *shallows)
 +{
 +      if (depth == INFINITE_DEPTH && !is_repository_shallow()) {
 +              int i;
 +
 +              for (i = 0; i < shallows->nr; i++) {
 +                      struct object *object = shallows->objects[i].item;
 +                      object->flags |= NOT_SHALLOW;
 +              }
 +      } else if (deepen_relative) {
 +              struct object_array reachable_shallows = OBJECT_ARRAY_INIT;
 +              struct commit_list *result;
 +
 +              get_reachable_list(shallows, &reachable_shallows);
 +              result = get_shallow_commits(&reachable_shallows,
 +                                           depth + 1,
 +                                           SHALLOW, NOT_SHALLOW);
 +              send_shallow(result);
 +              free_commit_list(result);
 +              object_array_clear(&reachable_shallows);
 +      } else {
 +              struct commit_list *result;
 +
 +              result = get_shallow_commits(&want_obj, depth,
 +                                           SHALLOW, NOT_SHALLOW);
 +              send_shallow(result);
 +              free_commit_list(result);
 +      }
 +
 +      send_unshallow(shallows);
 +      packet_flush(1);
 +}
 +
 +static void deepen_by_rev_list(int ac, const char **av,
 +                             struct object_array *shallows)
 +{
 +      struct commit_list *result;
 +
 +      result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
 +      send_shallow(result);
 +      free_commit_list(result);
 +      send_unshallow(shallows);
 +      packet_flush(1);
 +}
 +
  static void receive_needs(void)
  {
        struct object_array shallows = OBJECT_ARRAY_INIT;