Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'list-objects.c')
-rw-r--r--list-objects.c77
1 files changed, 33 insertions, 44 deletions
diff --git a/list-objects.c b/list-objects.c
index 250d9de41c..f39b68faf5 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -1,6 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "tag.h"
#include "commit.h"
+#include "gettext.h"
+#include "hex.h"
#include "tree.h"
#include "blob.h"
#include "diff.h"
@@ -10,8 +12,9 @@
#include "list-objects-filter.h"
#include "list-objects-filter-options.h"
#include "packfile.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "trace.h"
+#include "environment.h"
struct traversal_context {
struct rev_info *revs;
@@ -19,6 +22,7 @@ struct traversal_context {
show_commit_fn show_commit;
void *show_data;
struct filter *filter;
+ int depth;
};
static void show_commit(struct traversal_context *ctx,
@@ -35,6 +39,9 @@ static void show_object(struct traversal_context *ctx,
{
if (!ctx->show_object)
return;
+ if (ctx->revs->unpacked && has_object_pack(&object->oid))
+ return;
+
ctx->show_object(object, name, ctx->show_data);
}
@@ -64,7 +71,7 @@ static void process_blob(struct traversal_context *ctx,
* of missing objects.
*/
if (ctx->revs->exclude_promisor_objects &&
- !has_object_file(&obj->oid) &&
+ !repo_has_object_file(the_repository, &obj->oid) &&
is_promisor_object(&obj->oid))
return;
@@ -81,36 +88,6 @@ static void process_blob(struct traversal_context *ctx,
strbuf_setlen(path, pathlen);
}
-/*
- * Processing a gitlink entry currently does nothing, since
- * we do not recurse into the subproject.
- *
- * We *could* eventually add a flag that actually does that,
- * which would involve:
- * - is the subproject actually checked out?
- * - if so, see if the subproject has already been added
- * to the alternates list, and add it if not.
- * - process the commit (or tag) the gitlink points to
- * recursively.
- *
- * However, it's unclear whether there is really ever any
- * reason to see superprojects and subprojects as such a
- * "unified" object pool (potentially resulting in a totally
- * humongous pack - avoiding which was the whole point of
- * having gitlinks in the first place!).
- *
- * So for now, there is just a note that we *could* follow
- * the link, and how to do it. Whether it necessarily makes
- * any sense what-so-ever to ever do that is another issue.
- */
-static void process_gitlink(struct traversal_context *ctx,
- const unsigned char *sha1,
- struct strbuf *path,
- const char *name)
-{
- /* Nothing to do */
-}
-
static void process_tree(struct traversal_context *ctx,
struct tree *tree,
struct strbuf *base,
@@ -130,7 +107,7 @@ static void process_tree_contents(struct traversal_context *ctx,
while (tree_entry(&desc, &entry)) {
if (match != all_entries_interesting) {
match = tree_entry_interesting(ctx->revs->repo->index,
- &entry, base, 0,
+ &entry, base,
&ctx->revs->diffopt.pathspec);
if (match == all_entries_not_interesting)
break;
@@ -146,11 +123,12 @@ static void process_tree_contents(struct traversal_context *ctx,
entry.path, oid_to_hex(&tree->object.oid));
}
t->object.flags |= NOT_USER_GIVEN;
+ ctx->depth++;
process_tree(ctx, t, base, entry.path);
+ ctx->depth--;
}
else if (S_ISGITLINK(entry.mode))
- process_gitlink(ctx, entry.oid.hash,
- base, entry.path);
+ ; /* ignore gitlink */
else {
struct blob *b = lookup_blob(ctx->revs->repo, &entry.oid);
if (!b) {
@@ -185,6 +163,9 @@ static void process_tree(struct traversal_context *ctx,
!revs->include_check_obj(&tree->object, revs->include_check_data))
return;
+ if (ctx->depth > max_allowed_tree_depth)
+ die("exceeded maximum allowed tree depth");
+
failed_parse = parse_tree_gently(tree, 1);
if (failed_parse) {
if (revs->ignore_missing_links)
@@ -199,7 +180,7 @@ static void process_tree(struct traversal_context *ctx,
is_promisor_object(&obj->oid))
return;
- if (!revs->do_not_die_on_missing_tree)
+ if (!revs->do_not_die_on_missing_objects)
die("bad tree object %s", oid_to_hex(&obj->oid));
}
@@ -258,7 +239,8 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
struct commit *parent = parents->item;
if (!(parent->object.flags & UNINTERESTING))
continue;
- mark_tree_uninteresting(revs->repo, get_commit_tree(parent));
+ mark_tree_uninteresting(revs->repo,
+ repo_get_commit_tree(the_repository, parent));
if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
parent->object.flags |= SHOWN;
show_edge(parent);
@@ -275,7 +257,8 @@ static void add_edge_parents(struct commit *commit,
for (parents = commit->parents; parents; parents = parents->next) {
struct commit *parent = parents->item;
- struct tree *tree = get_commit_tree(parent);
+ struct tree *tree = repo_get_commit_tree(the_repository,
+ parent);
if (!tree)
continue;
@@ -306,7 +289,8 @@ void mark_edges_uninteresting(struct rev_info *revs,
for (list = revs->commits; list; list = list->next) {
struct commit *commit = list->item;
- struct tree *tree = get_commit_tree(commit);
+ struct tree *tree = repo_get_commit_tree(the_repository,
+ commit);
if (commit->object.flags & UNINTERESTING)
tree->object.flags |= UNINTERESTING;
@@ -322,7 +306,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
struct commit *commit = list->item;
if (commit->object.flags & UNINTERESTING) {
mark_tree_uninteresting(revs->repo,
- get_commit_tree(commit));
+ repo_get_commit_tree(the_repository, commit));
if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
commit->object.flags |= SHOWN;
show_edge(commit);
@@ -340,7 +324,7 @@ void mark_edges_uninteresting(struct rev_info *revs,
if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
continue;
mark_tree_uninteresting(revs->repo,
- get_commit_tree(commit));
+ repo_get_commit_tree(the_repository, commit));
if (!(obj->flags & SHOWN)) {
obj->flags |= SHOWN;
show_edge(commit);
@@ -375,6 +359,7 @@ static void traverse_non_commits(struct traversal_context *ctx,
if (!path)
path = "";
if (obj->type == OBJ_TREE) {
+ ctx->depth = 0;
process_tree(ctx, (struct tree *)obj, base, path);
continue;
}
@@ -407,8 +392,12 @@ static void do_traverse(struct traversal_context *ctx)
*/
if (!ctx->revs->tree_objects)
; /* do not bother loading tree */
- else if (get_commit_tree(commit)) {
- struct tree *tree = get_commit_tree(commit);
+ else if (ctx->revs->do_not_die_on_missing_objects &&
+ oidset_contains(&ctx->revs->missing_commits, &commit->object.oid))
+ ;
+ else if (repo_get_commit_tree(the_repository, commit)) {
+ struct tree *tree = repo_get_commit_tree(the_repository,
+ commit);
tree->object.flags |= NOT_USER_GIVEN;
add_pending_tree(ctx->revs, tree);
} else if (commit->object.parsed) {