Merge branch 'ks/combine-diff'
authorJunio C Hamano <gitster@pobox.com>
Wed, 5 Mar 2014 23:06:26 +0000 (15:06 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Mar 2014 23:06:26 +0000 (15:06 -0800)
Teach combine-diff to honour the path-output-order imposed by
diffcore-order, and optimize how matching paths are found in
the N-way diffs made with parents.

* ks/combine-diff:
tests: add checking that combine-diff emits only correct paths
combine-diff: simplify intersect_paths() further
combine-diff: combine_diff_path.len is not needed anymore
combine-diff: optimize combine_diff_path sets intersection
diff test: add tests for combine-diff with orderfile
diffcore-order: export generic ordering interface

1  2 
diff-lib.c
diffcore.h
diff --combined diff-lib.c
index 2eddc66bbd5cf37e4649e219a28c951ed134557c,bf624e77161d3337746bd5f5e8719c97cff1fbbd..ec5f722eff72ba3dff4b64f0961fa8e65a259170
@@@ -11,7 -11,6 +11,7 @@@
  #include "unpack-trees.h"
  #include "refs.h"
  #include "submodule.h"
 +#include "dir.h"
  
  /*
   * diff-files
@@@ -109,7 -108,7 +109,7 @@@ int run_diff_files(struct rev_info *rev
                if (diff_can_quit_early(&revs->diffopt))
                        break;
  
 -              if (!ce_path_match(ce, &revs->prune_data))
 +              if (!ce_path_match(ce, &revs->prune_data, NULL))
                        continue;
  
                if (ce_stage(ce)) {
                        dpath->path = (char *) &(dpath->parent[5]);
  
                        dpath->next = NULL;
-                       dpath->len = path_len;
                        memcpy(dpath->path, ce->name, path_len);
                        dpath->path[path_len] = '\0';
                        hashclr(dpath->sha1);
@@@ -327,7 -325,6 +326,6 @@@ static int show_modified(struct rev_inf
                p = xmalloc(combine_diff_path_size(2, pathlen));
                p->path = (char *) &p->parent[2];
                p->next = NULL;
-               p->len = pathlen;
                memcpy(p->path, new->name, pathlen);
                p->path[pathlen] = 0;
                p->mode = mode;
@@@ -439,7 -436,7 +437,7 @@@ static int oneway_diff(const struct cac
        if (tree == o->df_conflict_entry)
                tree = NULL;
  
 -      if (ce_path_match(idx ? idx : tree, &revs->prune_data)) {
 +      if (ce_path_match(idx ? idx : tree, &revs->prune_data, NULL)) {
                do_oneway_diff(o, idx, tree);
                if (diff_can_quit_early(&revs->diffopt)) {
                        o->exiting_early = 1;
diff --combined diffcore.h
index 1315cfd4ef0fbe0aeb0cae9a14bf09fd53212124,cbe9e62b49aa56f964817b60fa3d625959e492dc..92788ee4de8e59068a204729a8d6f7f89aaa6ee6
@@@ -68,8 -68,6 +68,8 @@@ struct diff_filepair 
        unsigned broken_pair : 1;
        unsigned renamed_pair : 1;
        unsigned is_unmerged : 1;
 +      unsigned done_skip_stat_unmatch : 1;
 +      unsigned skip_stat_unmatch_result : 1;
  };
  #define DIFF_PAIR_UNMERGED(p) ((p)->is_unmerged)
  
@@@ -111,6 -109,20 +111,20 @@@ extern void diffcore_merge_broken(void)
  extern void diffcore_pickaxe(struct diff_options *);
  extern void diffcore_order(const char *orderfile);
  
+ /* low-level interface to diffcore_order */
+ struct obj_order {
+       void *obj;      /* setup by caller */
+       /* setup/used by order_objects() */
+       int orig_order;
+       int order;
+ };
+ typedef const char *(*obj_path_fn_t)(void *obj);
+ void order_objects(const char *orderfile, obj_path_fn_t obj_path,
+                  struct obj_order *objs, int nr);
  #define DIFF_DEBUG 0
  #if DIFF_DEBUG
  void diff_debug_filespec(struct diff_filespec *, int, const char *);