pretty: allow %(trailers) options with explicit value
[gitweb.git] / list-objects.c
index 243192af5352752472908ab9a61e80fb2b138829..c41cc80db5bc86279bcf560109f599a9783b2755 100644 (file)
@@ -11,6 +11,7 @@
 #include "list-objects-filter-options.h"
 #include "packfile.h"
 #include "object-store.h"
+#include "trace.h"
 
 struct traversal_context {
        struct rev_info *revs;
@@ -53,7 +54,7 @@ static void process_blob(struct traversal_context *ctx,
 
        pathlen = path->len;
        strbuf_addstr(path, name);
-       if (!(obj->flags & USER_GIVEN) && ctx->filter_fn)
+       if ((obj->flags & NOT_USER_GIVEN) && ctx->filter_fn)
                r = ctx->filter_fn(LOFS_BLOB, obj,
                                   path->buf, &path->buf[pathlen],
                                   ctx->filter_data);
@@ -120,17 +121,19 @@ static void process_tree_contents(struct traversal_context *ctx,
                                continue;
                }
 
-               if (S_ISDIR(entry.mode))
-                       process_tree(ctx,
-                                    lookup_tree(the_repository, entry.oid),
-                                    base, entry.path);
+               if (S_ISDIR(entry.mode)) {
+                       struct tree *t = lookup_tree(the_repository, entry.oid);
+                       t->object.flags |= NOT_USER_GIVEN;
+                       process_tree(ctx, t, base, entry.path);
+               }
                else if (S_ISGITLINK(entry.mode))
                        process_gitlink(ctx, entry.oid->hash,
                                        base, entry.path);
-               else
-                       process_blob(ctx,
-                                    lookup_blob(the_repository, entry.oid),
-                                    base, entry.path);
+               else {
+                       struct blob *b = lookup_blob(the_repository, entry.oid);
+                       b->object.flags |= NOT_USER_GIVEN;
+                       process_blob(ctx, b, base, entry.path);
+               }
        }
 }
 
@@ -171,7 +174,7 @@ static void process_tree(struct traversal_context *ctx,
        }
 
        strbuf_addstr(base, name);
-       if (!(obj->flags & USER_GIVEN) && ctx->filter_fn)
+       if ((obj->flags & NOT_USER_GIVEN) && ctx->filter_fn)
                r = ctx->filter_fn(LOFS_BEGIN_TREE, obj,
                                   base->buf, &base->buf[baselen],
                                   ctx->filter_data);
@@ -182,10 +185,12 @@ static void process_tree(struct traversal_context *ctx,
        if (base->len)
                strbuf_addch(base, '/');
 
-       if (!failed_parse)
+       if (r & LOFR_SKIP_TREE)
+               trace_printf("Skipping contents of tree %s...\n", base->buf);
+       else if (!failed_parse)
                process_tree_contents(ctx, tree, base);
 
-       if (!(obj->flags & USER_GIVEN) && ctx->filter_fn) {
+       if ((obj->flags & NOT_USER_GIVEN) && ctx->filter_fn) {
                r = ctx->filter_fn(LOFS_END_TREE, obj,
                                   base->buf, &base->buf[baselen],
                                   ctx->filter_data);
@@ -209,7 +214,7 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
                struct commit *parent = parents->item;
                if (!(parent->object.flags & UNINTERESTING))
                        continue;
-               mark_tree_uninteresting(get_commit_tree(parent));
+               mark_tree_uninteresting(revs->repo, get_commit_tree(parent));
                if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
                        parent->object.flags |= SHOWN;
                        show_edge(parent);
@@ -226,7 +231,8 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
                struct commit *commit = list->item;
 
                if (commit->object.flags & UNINTERESTING) {
-                       mark_tree_uninteresting(get_commit_tree(commit));
+                       mark_tree_uninteresting(revs->repo,
+                                               get_commit_tree(commit));
                        if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
                                commit->object.flags |= SHOWN;
                                show_edge(commit);
@@ -241,7 +247,8 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
                        struct commit *commit = (struct commit *)obj;
                        if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
                                continue;
-                       mark_tree_uninteresting(get_commit_tree(commit));
+                       mark_tree_uninteresting(revs->repo,
+                                               get_commit_tree(commit));
                        if (!(obj->flags & SHOWN)) {
                                obj->flags |= SHOWN;
                                show_edge(commit);
@@ -301,8 +308,11 @@ static void do_traverse(struct traversal_context *ctx)
                 * an uninteresting boundary commit may not have its tree
                 * parsed yet, but we are not going to show them anyway
                 */
-               if (get_commit_tree(commit))
-                       add_pending_tree(ctx->revs, get_commit_tree(commit));
+               if (get_commit_tree(commit)) {
+                       struct tree *tree = get_commit_tree(commit);
+                       tree->object.flags |= NOT_USER_GIVEN;
+                       add_pending_tree(ctx->revs, tree);
+               }
                ctx->show_commit(commit, ctx->show_data);
 
                if (ctx->revs->tree_blobs_in_commit_order)