MCPcopy Create free account
hub / github.com/git/git / git_config_perm

Function git_config_perm

setup.c:2107–2156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2105}
2106
2107int git_config_perm(const char *var, const char *value)
2108{
2109 int i;
2110 char *endptr;
2111
2112 if (!value)
2113 return PERM_GROUP;
2114
2115 if (!strcmp(value, "umask"))
2116 return PERM_UMASK;
2117 if (!strcmp(value, "group"))
2118 return PERM_GROUP;
2119 if (!strcmp(value, "all") ||
2120 !strcmp(value, "world") ||
2121 !strcmp(value, "everybody"))
2122 return PERM_EVERYBODY;
2123
2124 /* Parse octal numbers */
2125 i = strtol(value, &endptr, 8);
2126
2127 /* If not an octal number, maybe true/false? */
2128 if (*endptr != 0)
2129 return git_config_bool(var, value) ? PERM_GROUP : PERM_UMASK;
2130
2131 /*
2132 * Treat values 0, 1 and 2 as compatibility cases, otherwise it is
2133 * a chmod value to restrict to.
2134 */
2135 switch (i) {
2136 case PERM_UMASK: /* 0 */
2137 return PERM_UMASK;
2138 case OLD_PERM_GROUP: /* 1 */
2139 return PERM_GROUP;
2140 case OLD_PERM_EVERYBODY: /* 2 */
2141 return PERM_EVERYBODY;
2142 }
2143
2144 /* A filemode value was given: 0xxx */
2145
2146 if ((i & 0600) != 0600)
2147 die(_("problem with core.sharedRepository filemode value "
2148 "(0%.3o).\nThe owner of files must always have "
2149 "read and write permissions."), i);
2150
2151 /*
2152 * Mask filemode value. Others can not get write permission.
2153 * x flags for directories are handled separately.
2154 */
2155 return -(i & 0666);
2156}
2157
2158/*
2159 * Returns the "prefix", a path to the current working directory

Callers 2

shared_callbackFunction · 0.85

Calls 2

git_config_boolFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected