author | Junio C Hamano <gitster@pobox.com> | |
Wed, 23 Mar 2011 04:37:59 +0000 (21:37 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 23 Mar 2011 04:37:59 +0000 (21:37 -0700) |
* jc/maint-rev-list-culled-boundary:
list-objects.c: don't add an unparsed NULL as a pending tree
Conflicts:
list-objects.c
list-objects.c: don't add an unparsed NULL as a pending tree
Conflicts:
list-objects.c
1 | 2 | |||
---|---|---|---|---|
list-objects.c | patch | | diff1 | | diff2 | | blob | history |
t/t6110-rev-list-sparse.sh | patch | | | | diff2 | | blob | history |
diff --combined list-objects.c
index 61f6cc98d917c3e4395ec397ac74df6a40eeb07f,518c6650e1827567be48976138aff621dc50eb92..838b6a732e4758265432cbc9c8e8fc81568a2b50
--- 1/list-objects.c
--- 2/list-objects.c
+++ b/list-objects.c
if (obj->flags & (UNINTERESTING | SEEN))
return;
obj->flags |= SEEN;
- show(obj, path_name(path, name));
+ show(obj, path, name);
}
/*
struct tree *tree,
show_object_fn show,
struct name_path *path,
+ struct strbuf *base,
const char *name)
{
struct object *obj = &tree->object;
struct tree_desc desc;
struct name_entry entry;
struct name_path me;
+ int all_interesting = (revs->diffopt.pathspec.nr == 0);
+ int baselen = base->len;
if (!revs->tree_objects)
return;
if (parse_tree(tree) < 0)
die("bad tree object %s", sha1_to_hex(obj->sha1));
obj->flags |= SEEN;
- show(obj, path_name(path, name));
+ show(obj, path, name);
me.up = path;
me.elem = name;
me.elem_len = strlen(name);
+ if (!all_interesting) {
+ strbuf_addstr(base, name);
+ if (base->len)
+ strbuf_addch(base, '/');
+ }
+
init_tree_desc(&desc, tree->buffer, tree->size);
while (tree_entry(&desc, &entry)) {
+ if (!all_interesting) {
+ int showit = tree_entry_interesting(&entry,
+ base, 0,
+ &revs->diffopt.pathspec);
+
+ if (showit < 0)
+ break;
+ else if (!showit)
+ continue;
+ else if (showit == 2)
+ all_interesting = 1;
+ }
+
if (S_ISDIR(entry.mode))
process_tree(revs,
lookup_tree(entry.sha1),
- show, &me, entry.path);
+ show, &me, base, entry.path);
else if (S_ISGITLINK(entry.mode))
process_gitlink(revs, entry.sha1,
show, &me, entry.path);
lookup_blob(entry.sha1),
show, &me, entry.path);
}
+ strbuf_setlen(base, baselen);
free(tree->buffer);
tree->buffer = NULL;
}
}
void traverse_commit_list(struct rev_info *revs,
- void (*show_commit)(struct commit *),
- void (*show_object)(struct object *, const char *))
+ show_commit_fn show_commit,
+ show_object_fn show_object,
+ void *data)
{
int i;
struct commit *commit;
+ struct strbuf base;
+ strbuf_init(&base, PATH_MAX);
while ((commit = get_revision(revs)) != NULL) {
- add_pending_tree(revs, commit->tree);
+ /*
+ * an uninteresting boundary commit may not have its tree
+ * parsed yet, but we are not going to show them anyway
+ */
+ if (commit->tree)
+ add_pending_tree(revs, commit->tree);
- show_commit(commit);
+ show_commit(commit, data);
}
for (i = 0; i < revs->pending.nr; i++) {
struct object_array_entry *pending = revs->pending.objects + i;
continue;
if (obj->type == OBJ_TAG) {
obj->flags |= SEEN;
- show_object(obj, name);
+ show_object(obj, NULL, name);
continue;
}
if (obj->type == OBJ_TREE) {
process_tree(revs, (struct tree *)obj, show_object,
- NULL, name);
+ NULL, &base, name);
continue;
}
if (obj->type == OBJ_BLOB) {
revs->pending.alloc = 0;
revs->pending.objects = NULL;
}
+ strbuf_release(&base);
}
diff --combined t/t6110-rev-list-sparse.sh
index 0000000000000000000000000000000000000000,2a267e84cdaebce5b0a1e043521c68204d16eb6c..656ac7fe9dc1074c5173bcfcf96503b65f33c2f5
mode 000000,100755..100755
mode 000000,100755..100755
--- /dev/null
-test_commit () {
- echo "$1" >"$1.file" &&
- git add "$1.file" &&
- test_tick &&
- git commit -m "$1"
-}
-
+ #!/bin/sh
+
+ test_description='operations that cull histories in unusual ways'
+ . ./test-lib.sh
+
+ test_expect_success setup '
+ test_commit A &&
+ test_commit B &&
+ test_commit C &&
+ git checkout -b side HEAD^ &&
+ test_commit D &&
+ test_commit E &&
+ git merge master
+ '
+
+ test_expect_success 'rev-list --first-parent --boundary' '
+ git rev-list --first-parent --boundary HEAD^..
+ '
+
+ test_done