From: Junio C Hamano Date: Wed, 23 Mar 2011 04:37:59 +0000 (-0700) Subject: Merge branch 'jc/maint-rev-list-culled-boundary' X-Git-Tag: v1.7.5-rc0~43 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/4b28cd9f2fb755cdfe1b97130e84644ae932988c?ds=inline;hp=-c Merge branch 'jc/maint-rev-list-culled-boundary' * jc/maint-rev-list-culled-boundary: list-objects.c: don't add an unparsed NULL as a pending tree Conflicts: list-objects.c --- 4b28cd9f2fb755cdfe1b97130e84644ae932988c diff --combined list-objects.c index 61f6cc98d9,518c6650e1..838b6a732e --- a/list-objects.c +++ b/list-objects.c @@@ -23,7 -23,7 +23,7 @@@ static void process_blob(struct rev_inf if (obj->flags & (UNINTERESTING | SEEN)) return; obj->flags |= SEEN; - show(obj, path_name(path, name)); + show(obj, path, name); } /* @@@ -61,15 -61,12 +61,15 @@@ static void process_tree(struct rev_inf 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; @@@ -80,37 -77,18 +80,37 @@@ 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); @@@ -119,7 -97,6 +119,7 @@@ lookup_blob(entry.sha1), show, &me, entry.path); } + strbuf_setlen(base, baselen); free(tree->buffer); tree->buffer = NULL; } @@@ -163,18 -140,20 +163,23 @@@ static void add_pending_tree(struct rev } 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; @@@ -184,12 -163,12 +189,12 @@@ 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) { @@@ -206,5 -185,4 +211,5 @@@ revs->pending.alloc = 0; revs->pending.objects = NULL; } + strbuf_release(&base); } diff --combined t/t6110-rev-list-sparse.sh index 0000000000,2a267e84cd..656ac7fe9d mode 000000,100755..100755 --- a/t/t6110-rev-list-sparse.sh +++ b/t/t6110-rev-list-sparse.sh @@@ -1,0 -1,27 +1,20 @@@ + #!/bin/sh + + test_description='operations that cull histories in unusual ways' + . ./test-lib.sh + -test_commit () { - echo "$1" >"$1.file" && - git add "$1.file" && - test_tick && - git commit -m "$1" -} - + 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