mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 02:16:21 +00:00
index: Correctly write entry mode
The entry mode flags for an entry created from a path name were not correctly written if the entry was a symlink. The st_mode of a statted symlink is 0120777, however git requires the mode to read 0120000, because it does not care about permissions of symlinks. Introduce index_create_mode() that correctly writes the mode flags in the form expected by git.
This commit is contained in:
parent
1869b31e0c
commit
c1a2a14e02
11
src/index.c
11
src/index.c
@ -138,6 +138,15 @@ int unmerged_cmp(const void *a, const void *b)
|
||||
return strcmp(info_a->path, info_b->path);
|
||||
}
|
||||
|
||||
unsigned int index_create_mode(unsigned int mode)
|
||||
{
|
||||
if (S_ISLNK(mode))
|
||||
return S_IFLNK;
|
||||
if (S_ISDIR(mode) || (mode & S_IFMT) == 0160000)
|
||||
return 0160000;
|
||||
return S_IFREG | ((mode & 0100) ? 0755 : 0644);
|
||||
}
|
||||
|
||||
static int index_initialize(git_index **index_out, git_repository *owner, const char *index_path)
|
||||
{
|
||||
git_index *index;
|
||||
@ -419,7 +428,7 @@ static int index_init_entry(git_index_entry *entry, git_index *index, const char
|
||||
/* entry.ctime.nanoseconds = st.st_ctimensec; */
|
||||
entry->dev= st.st_rdev;
|
||||
entry->ino = st.st_ino;
|
||||
entry->mode = st.st_mode;
|
||||
entry->mode = index_create_mode(st.st_mode);
|
||||
entry->uid = st.st_uid;
|
||||
entry->gid = st.st_gid;
|
||||
entry->file_size = st.st_size;
|
||||
|
Loading…
Reference in New Issue
Block a user