@matheusbsbs / matheus-bagliano / commits / b6b32ccb92
Fork 0

Fix 'quickfix' on pack-objects.

The earlier quickfix forced world-readable permission bits. This updates it to honor umask and core.sharedrepository settings. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Apr 22, 2007 at 12:28 UTC b6b32ccb927de0c631b1aaf27b1664bd4eb300c7
1 file changed +14 -2
builtin-pack-objects.c
+14 -2
@@ -1612,6 +1612,13 @@ static void get_object_list(int ac, const char **av)
1612 traverse_commit_list(&revs, show_commit, show_object);
1613 }
1614
1615 +static int adjust_perm(const char *path, mode_t mode)
1616 +{
1617 + if (chmod(path, mode))
1618 + return -1;
1619 + return adjust_shared_perm(path);
1620 +}
1621 +
1622 int cmd_pack_objects(int argc, const char **argv, const char *prefix)
1623 {
1624 int depth = 10;
@@ -1780,10 +1787,15 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
1787 last_obj_offset = write_pack_file();
1788 if (!pack_to_stdout) {
1789 unsigned char object_list_sha1[20];
1790 + mode_t mode = umask(0);
1791 +
1792 + umask(mode);
1793 + mode = 0666 & ~mode;
1794 +
1795 write_index_file(last_obj_offset, object_list_sha1);
1796 snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
1797 base_name, sha1_to_hex(object_list_sha1));
1786 - if (chmod(pack_tmp_name, 0644))
1798 + if (adjust_perm(pack_tmp_name, mode))
1799 die("unable to make temporary pack file readable: %s",
1800 strerror(errno));
1801 if (rename(pack_tmp_name, tmpname))
@@ -1791,7 +1803,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
1803 strerror(errno));
1804 snprintf(tmpname, sizeof(tmpname), "%s-%s.idx",
1805 base_name, sha1_to_hex(object_list_sha1));
1794 - if (chmod(idx_tmp_name, 0644))
1806 + if (adjust_perm(idx_tmp_name, mode))
1807 die("unable to make temporary index file readable: %s",
1808 strerror(errno));
1809 if (rename(idx_tmp_name, tmpname))