diff --git a/sys/src/cmd/git/save.c b/sys/src/cmd/git/save.c index 7783e72cc..ef4c57400 100644 --- a/sys/src/cmd/git/save.c +++ b/sys/src/cmd/git/save.c @@ -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;