diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2011-05-02 23:02:15 -0500 |
---|---|---|
committer | Jonathan Nieder <jrnieder@gmail.com> | 2011-05-02 23:02:15 -0500 |
commit | 59445b0b02c731872c8665ac7e9cf1226fa616e4 (patch) | |
tree | 93922cf13ed9c62859dac628fa7e376977a23d24 /list-objects.c | |
parent | Revert "t0081 (line-buffer): add buffering tests" (diff) | |
parent | Git 1.7.5 (diff) | |
download | tgif-59445b0b02c731872c8665ac7e9cf1226fa616e4.tar.xz |
Merge commit 'v1.7.5' into svn-fe
* commit 'v1.7.5': (436 commits)
Git 1.7.5
Git 1.7.5-rc3
Git 1.7.4.5
git-svn.txt: Document --mergeinfo
Revert "run-command: prettify -D_FORTIFY_SOURCE workaround"
...
Diffstat (limited to 'list-objects.c')
-rw-r--r-- | list-objects.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/list-objects.c b/list-objects.c index 8953548c07..838b6a732e 100644 --- a/list-objects.c +++ b/list-objects.c @@ -61,12 +61,15 @@ static void process_tree(struct rev_info *revs, 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; @@ -82,13 +85,32 @@ static void process_tree(struct rev_info *revs, 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); @@ -97,6 +119,7 @@ static void process_tree(struct rev_info *revs, lookup_blob(entry.sha1), show, &me, entry.path); } + strbuf_setlen(base, baselen); free(tree->buffer); tree->buffer = NULL; } @@ -146,9 +169,16 @@ void traverse_commit_list(struct rev_info *revs, { 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, data); } for (i = 0; i < revs->pending.nr; i++) { @@ -164,7 +194,7 @@ void traverse_commit_list(struct rev_info *revs, } if (obj->type == OBJ_TREE) { process_tree(revs, (struct tree *)obj, show_object, - NULL, name); + NULL, &base, name); continue; } if (obj->type == OBJ_BLOB) { @@ -181,4 +211,5 @@ void traverse_commit_list(struct rev_info *revs, revs->pending.alloc = 0; revs->pending.objects = NULL; } + strbuf_release(&base); } |