mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
git/save: sort argv lexicographically
our code assumed that the inputs were sorted, and that scanning forward by prefix would group the dirs by prefix. Sort so that assumption is true.
This commit is contained in:
parent
e4373dd103
commit
b4e8108d6c
1 changed files with 10 additions and 0 deletions
|
@ -25,6 +25,7 @@ int nparents;
|
|||
Idxent *idx;
|
||||
int idxsz;
|
||||
int nidx;
|
||||
|
||||
int
|
||||
gitmode(Dirent *e)
|
||||
{
|
||||
|
@ -40,6 +41,12 @@ gitmode(Dirent *e)
|
|||
return 0100644;
|
||||
}
|
||||
|
||||
int
|
||||
namecmp(void *pa, void *pb)
|
||||
{
|
||||
return strcmp(*(char**)pa, *(char**)pb);
|
||||
}
|
||||
|
||||
int
|
||||
idxcmp(void *pa, void *pb)
|
||||
{
|
||||
|
@ -228,6 +235,8 @@ treeify(Object *t, char **path, char **epath, int off, Hash *h)
|
|||
* paths have been normalized already,
|
||||
* no leading or double-slashes allowed.
|
||||
*/
|
||||
assert(off <= strlen(s));
|
||||
assert(off == 0 || s[off-1] == '/');
|
||||
assert(s[off] != '\0' && s[off] != '/');
|
||||
|
||||
/* get next path element length (from off until '/' or nul) */
|
||||
|
@ -414,6 +423,7 @@ main(int argc, char **argv)
|
|||
while(*argv[i] == '/')
|
||||
argv[i]++;
|
||||
}
|
||||
qsort(argv, argc, sizeof(*argv), namecmp);
|
||||
|
||||
t = findroot();
|
||||
nidx = 0;
|
||||
|
|
Loading…
Reference in a new issue