git/save: leave submodules unmangled
When modifying a submodule, we would garble the mode, leading to an apparently dangling object. This fixes the issue.
This commit is contained in:
parent
5a15acc7f0
commit
3909b83a90
1 changed files with 11 additions and 9 deletions
|
@ -15,16 +15,18 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
gitmode(int m)
|
gitmode(Dirent *e)
|
||||||
{
|
{
|
||||||
if(m & DMDIR) /* directory */
|
if(e->islink)
|
||||||
return 0040000;
|
|
||||||
else if(m & 0111) /* executable */
|
|
||||||
return 0100755;
|
|
||||||
else if(m != 0) /* regular */
|
|
||||||
return 0100644;
|
|
||||||
else /* symlink */
|
|
||||||
return 0120000;
|
return 0120000;
|
||||||
|
else if(e->ismod)
|
||||||
|
return 0160000;
|
||||||
|
else if(e->mode & DMDIR)
|
||||||
|
return 0040000;
|
||||||
|
else if(e->mode & 0111)
|
||||||
|
return 0100755;
|
||||||
|
else
|
||||||
|
return 0100644;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -141,7 +143,7 @@ writetree(Dirent *ent, int nent, Hash *h)
|
||||||
for(d = ent; d != ent + nent; d++){
|
for(d = ent; d != ent + nent; d++){
|
||||||
if(strlen(d->name) >= 255)
|
if(strlen(d->name) >= 255)
|
||||||
sysfatal("overly long filename: %s", d->name);
|
sysfatal("overly long filename: %s", d->name);
|
||||||
t = seprint(t, etxt, "%o %s", gitmode(d->mode), d->name) + 1;
|
t = seprint(t, etxt, "%o %s", gitmode(d), d->name) + 1;
|
||||||
memcpy(t, d->h.h, sizeof(d->h.h));
|
memcpy(t, d->h.h, sizeof(d->h.h));
|
||||||
t += sizeof(d->h.h);
|
t += sizeof(d->h.h);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue