commit - 339c298e66d94d2a92f3b1af99c60e0e4172b1e7
commit + 26a7fe28be950a17dccf0bc3f8bd8f4ad057468c
blob - f3934b9ba13445703d947eeb14449a417dfc113a
blob + 54d3549267b9214299ee19e6ca88f0dfca365267
--- lib/fileindex.c
+++ lib/fileindex.c
#define GOT_FILEIDX_MAX_ENTRIES INT_MAX
};
+uint16_t
+got_fileindex_perms_from_st(struct stat *sb)
+{
+ uint16_t perms = (sb->st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
+ return (perms << GOT_FILEIDX_MODE_PERMS_SHIFT);
+}
+
+mode_t
+got_fileindex_perms_to_st(struct got_fileindex_entry *ie)
+{
+ mode_t perms = (ie->mode >> GOT_FILEIDX_MODE_PERMS_SHIFT);
+ return (perms & (S_IRWXU | S_IRWXG | S_IRWXO));
+}
+
const struct got_error *
got_fileindex_entry_update(struct got_fileindex_entry *entry,
const char *ondisk_path, uint8_t *blob_sha1, uint8_t *commit_sha1,
entry->mode = GOT_FILEIDX_MODE_SYMLINK;
else
entry->mode = GOT_FILEIDX_MODE_REGULAR_FILE;
- entry->mode |= ((sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO)) <<
- GOT_FILEIDX_MODE_PERMS_SHIFT);
+ entry->mode |= got_fileindex_perms_from_st(&sb);
}
if (blob_sha1) {
blob - c3528c754414863d9d51edfae7b866d0ae7f5045
blob + 3e7fc839a1a76055f7215853e6bd1819dd0140d1
--- lib/got_lib_fileindex.h
+++ lib/got_lib_fileindex.h
uint8_t sha1[SHA1_DIGEST_LENGTH]; /* checksum of above on-disk data */
};
+uint16_t got_fileindex_perms_from_st(struct stat *);
+mode_t got_fileindex_perms_to_st(struct got_fileindex_entry *);
+
const struct got_error *got_fileindex_entry_update(struct got_fileindex_entry *,
const char *, uint8_t *, uint8_t *, int);
const struct got_error *got_fileindex_entry_alloc(struct got_fileindex_entry **,
blob - 08d2a404aeb438f0119da97f048a5a3735aa51c1
blob + 5368b2ce4c5f69ed07669a29c83b456c084575d0
--- lib/worktree.c
+++ lib/worktree.c
*status = GOT_STATUS_MISSING;
else
*status = GOT_STATUS_DELETE;
- sb->st_mode =
- ((ie->mode >> GOT_FILEIDX_MODE_PERMS_SHIFT)
- & (S_IRWXU | S_IRWXG | S_IRWXO));
+ sb->st_mode = got_fileindex_perms_to_st(ie);
} else
sb->st_mode = GOT_DEFAULT_FILE_MODE;
return NULL;