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:
authorJeff King <peff@peff.net>2018-11-02 08:22:59 +0300
committerJunio C Hamano <gitster@pobox.com>2018-11-02 14:49:52 +0300
commitb4cfcde4db8f5787c6c8a3912b0f2667becd1995 (patch)
tree70c0443f5cd536fc7daa1979893d6c9683eb5e34 /revision.c
parentd582ea202b626dcc6c3b01e1e11a296d9badd730 (diff)
rev-list: handle flags for --indexed-objects
When a traversal sees the --indexed-objects option, it adds all blobs and valid cache-trees from the index to the traversal using add_index_objects_to_pending(). But that function totally ignores its flags parameter! That means that doing: git rev-list --objects --indexed-objects and git rev-list --objects --not --indexed-objects produce the same output, because we ignore the UNINTERESTING flag when walking the index in the second example. Nobody noticed because this feature was added as a way for tools like repack to increase their coverage of reachable objects, meaning it would only be used like the first example above. But since it's user facing (and because the documentation describes it "as if the objects are listed on the command line"), we should make sure the negative case behaves sensibly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/revision.c b/revision.c
index a1ddb9e11c..8e56c9641f 100644
--- a/revision.c
+++ b/revision.c
@@ -1321,13 +1321,14 @@ void add_reflogs_to_pending(struct rev_info *revs, unsigned flags)
}
static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,
- struct strbuf *path)
+ struct strbuf *path, unsigned int flags)
{
size_t baselen = path->len;
int i;
if (it->entry_count >= 0) {
struct tree *tree = lookup_tree(revs->repo, &it->oid);
+ tree->object.flags |= flags;
add_pending_object_with_path(revs, &tree->object, "",
040000, path->buf);
}
@@ -1335,14 +1336,15 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,
for (i = 0; i < it->subtree_nr; i++) {
struct cache_tree_sub *sub = it->down[i];
strbuf_addf(path, "%s%s", baselen ? "/" : "", sub->name);
- add_cache_tree(sub->cache_tree, revs, path);
+ add_cache_tree(sub->cache_tree, revs, path, flags);
strbuf_setlen(path, baselen);
}
}
static void do_add_index_objects_to_pending(struct rev_info *revs,
- struct index_state *istate)
+ struct index_state *istate,
+ unsigned int flags)
{
int i;
@@ -1356,13 +1358,14 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,
blob = lookup_blob(revs->repo, &ce->oid);
if (!blob)
die("unable to add index blob to traversal");
+ blob->object.flags |= flags;
add_pending_object_with_path(revs, &blob->object, "",
ce->ce_mode, ce->name);
}
if (istate->cache_tree) {
struct strbuf path = STRBUF_INIT;
- add_cache_tree(istate->cache_tree, revs, &path);
+ add_cache_tree(istate->cache_tree, revs, &path, flags);
strbuf_release(&path);
}
}
@@ -1372,7 +1375,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
struct worktree **worktrees, **p;
read_index(revs->repo->index);
- do_add_index_objects_to_pending(revs, revs->repo->index);
+ do_add_index_objects_to_pending(revs, revs->repo->index, flags);
if (revs->single_worktree)
return;
@@ -1388,7 +1391,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
if (read_index_from(&istate,
worktree_git_path(wt, "index"),
get_worktree_git_dir(wt)) > 0)
- do_add_index_objects_to_pending(revs, &istate);
+ do_add_index_objects_to_pending(revs, &istate, flags);
discard_index(&istate);
}
free_worktrees(worktrees);