2010/8/2 Elijah Newren <newren@xxxxxxxxx>: >> >> if (!revs->tree_objects) >> return; >> @@ -82,13 +85,21 @@ static void process_tree(struct rev_info *revs, >> me.elem = name; >> me.elem_len = strlen(name); >> >> + if (subtree) { >> + slash = strchr(subtree, '/'); >> + subtree_len = slash ? slash - subtree : strlen(subtree); >> + } >> + >> init_tree_desc(&desc, tree->buffer, tree->size); >> >> while (tree_entry(&desc, &entry)) { >> - if (S_ISDIR(entry.mode)) >> - process_tree(revs, >> - lookup_tree(entry.sha1), >> - show, &me, entry.path); >> + if (S_ISDIR(entry.mode)) { >> + if (!subtree || !strncmp(entry.path, subtree, subtree_len)) > > Only one subdirectory allowed? What if someone wants a sparse clone > containing two or more directories? (Actually, that's not so much of > a "what if" -- it's exactly what I want in about half my usecases for > sparse clones.) One is simpler. So one first, multiple may come later. >> + process_tree(revs, >> + lookup_tree(entry.sha1), >> + show, &me, entry.path, >> + slash && slash[1] ? slash+1 : NULL); > > If I read correctly, slash will be used uninitialized here whenever > subtree == NULL. Yes. Thanks. Will fix. -- Duy ��.n��������+%������w��{.n��������n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�