]> git.ipfire.org Git - thirdparty/git.git/blobdiff - tree-diff.c
upload-pack: pass upload_pack_data to send_acks()
[thirdparty/git.git] / tree-diff.c
index 0e5432461026eff15fe101cf017cd839702e5870..f3d303c6e541acd4ab715c0a5a329abdc24e7819 100644 (file)
@@ -181,7 +181,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
        struct tree_desc *t, struct tree_desc *tp,
        int imin)
 {
-       unsigned mode;
+       unsigned short mode;
        const char *path;
        const struct object_id *oid;
        int pathlen;
@@ -239,7 +239,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
                                                DIFF_STATUS_ADDED;
 
                        if (tpi_valid) {
-                               oid_i = tp[i].entry.oid;
+                               oid_i = &tp[i].entry.oid;
                                mode_i = tp[i].entry.mode;
                        }
                        else {
@@ -280,7 +280,7 @@ static struct combine_diff_path *emit_path(struct combine_diff_path *p,
                        /* same rule as in emitthis */
                        int tpi_valid = tp && !(tp[i].entry.mode & S_IFXMIN_NEQ);
 
-                       parents_oid[i] = tpi_valid ? tp[i].entry.oid : NULL;
+                       parents_oid[i] = tpi_valid ? &tp[i].entry.oid : NULL;
                }
 
                strbuf_add(base, path, pathlen);
@@ -299,7 +299,8 @@ static void skip_uninteresting(struct tree_desc *t, struct strbuf *base,
        enum interesting match;
 
        while (t->size) {
-               match = tree_entry_interesting(&t->entry, base, 0, &opt->pathspec);
+               match = tree_entry_interesting(opt->repo->index, &t->entry,
+                                              base, 0, &opt->pathspec);
                if (match) {
                        if (match == all_entries_not_interesting)
                                t->size = 0;
@@ -421,8 +422,8 @@ static struct combine_diff_path *ll_diff_tree_paths(
         *   diff_tree_oid(parent, commit) )
         */
        for (i = 0; i < nparent; ++i)
-               tptree[i] = fill_tree_descriptor(&tp[i], parents_oid[i]);
-       ttree = fill_tree_descriptor(&t, oid);
+               tptree[i] = fill_tree_descriptor(opt->repo, &tp[i], parents_oid[i]);
+       ttree = fill_tree_descriptor(opt->repo, &t, oid);
 
        /* Enable recursion indefinitely */
        opt->pathspec.recursive = opt->flags.recursive;
@@ -433,6 +434,9 @@ static struct combine_diff_path *ll_diff_tree_paths(
                if (diff_can_quit_early(opt))
                        break;
 
+               if (opt->max_changes && opt->num_changes > opt->max_changes)
+                       break;
+
                if (opt->pathspec.nr) {
                        skip_uninteresting(&t, base, opt);
                        for (i = 0; i < nparent; i++)
@@ -491,7 +495,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
                                                continue;
 
                                        /* diff(t,pi) != ø */
-                                       if (!oideq(t.entry.oid, tp[i].entry.oid) ||
+                                       if (!oideq(&t.entry.oid, &tp[i].entry.oid) ||
                                            (t.entry.mode != tp[i].entry.mode))
                                                continue;
 
@@ -517,6 +521,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
 
                        /* t↓ */
                        update_tree_entry(&t);
+                       opt->num_changes++;
                }
 
                /* t > p[imin] */
@@ -534,6 +539,7 @@ static struct combine_diff_path *ll_diff_tree_paths(
                skip_emit_tp:
                        /* ∀ pi=p[imin]  pi↓ */
                        update_tp_entries(tp, nparent);
+                       opt->num_changes++;
                }
        }
 
@@ -551,6 +557,7 @@ struct combine_diff_path *diff_tree_paths(
        const struct object_id **parents_oid, int nparent,
        struct strbuf *base, struct diff_options *opt)
 {
+       opt->num_changes = 0;
        p = ll_diff_tree_paths(p, oid, parents_oid, nparent, base, opt);
 
        /*