From: Elijah Newren Date: Wed, 25 Aug 2010 04:11:43 GMT Subject: Re: [PATCH 10/32] rev-list: support traversing in narrow repository mode Message-ID: In-Reply-To: <1282688422-7738-11-git-send-email-pclouds@gmail.com> 2010/8/24 Nguyễn Thái Ngọc Duy : > In this mode, only trees within revs->narrow_prefix is traversed. This > narrows down the whole repository to the given subtree. This mode will > be used by upload-pack/pack-objects to create a narrow pack, and by > all git operations in narrow repository (i.e. $GIT_DIR/narrow exists). My fix-rev-list series I posted is going to cause a few conflicts with this patch... > +               if (!subtree) > +                       ;       /* no subtree restriction, go on */ > +               else if (S_ISDIR(entry.mode) && > +                        !strncmp(entry.path, subtree, subtree_len) && > +                        entry.path[subtree_len] == '\0') > +                       ;       /* inside subtree, go on */ Instead of writing your own comparison code, you may want to consider using tree_entry_interesting() here. That would also provide you with a natural extension to multiple subtrees, rather than your currently hardcoded single tree. You may want to take a look at tree-diff.c:show_tree() for inspiration here.