зеркало из https://github.com/microsoft/git.git
Merge branch 'rj/config-cygwin'
* rj/config-cygwin: config.c: Make git_config() work correctly when called recursively t1301-*.sh: Fix the 'forced modes' test on cygwin help.c: Fix detection of custom merge strategy on cygwin
This commit is contained in:
Коммит
551d75dbd8
|
@ -114,8 +114,7 @@ static int git_cygwin_config(const char *var, const char *value, void *cb)
|
||||||
|
|
||||||
static int init_stat(void)
|
static int init_stat(void)
|
||||||
{
|
{
|
||||||
if (have_git_dir()) {
|
if (have_git_dir() && git_config(git_cygwin_config,NULL)) {
|
||||||
git_config(git_cygwin_config, NULL);
|
|
||||||
if (!core_filemode && native_stat) {
|
if (!core_filemode && native_stat) {
|
||||||
cygwin_stat_fn = cygwin_stat;
|
cygwin_stat_fn = cygwin_stat;
|
||||||
cygwin_lstat_fn = cygwin_lstat;
|
cygwin_lstat_fn = cygwin_lstat;
|
||||||
|
|
80
config.c
80
config.c
|
@ -12,10 +12,18 @@
|
||||||
|
|
||||||
#define MAXNAME (256)
|
#define MAXNAME (256)
|
||||||
|
|
||||||
static FILE *config_file;
|
typedef struct config_file {
|
||||||
static const char *config_file_name;
|
struct config_file *prev;
|
||||||
static int config_linenr;
|
FILE *f;
|
||||||
static int config_file_eof;
|
const char *name;
|
||||||
|
int linenr;
|
||||||
|
int eof;
|
||||||
|
struct strbuf value;
|
||||||
|
char var[MAXNAME];
|
||||||
|
} config_file;
|
||||||
|
|
||||||
|
static config_file *cf;
|
||||||
|
|
||||||
static int zlib_compression_seen;
|
static int zlib_compression_seen;
|
||||||
|
|
||||||
const char *config_exclusive_filename = NULL;
|
const char *config_exclusive_filename = NULL;
|
||||||
|
@ -99,7 +107,7 @@ static int get_next_char(void)
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
c = '\n';
|
c = '\n';
|
||||||
if ((f = config_file) != NULL) {
|
if (cf && ((f = cf->f) != NULL)) {
|
||||||
c = fgetc(f);
|
c = fgetc(f);
|
||||||
if (c == '\r') {
|
if (c == '\r') {
|
||||||
/* DOS like systems */
|
/* DOS like systems */
|
||||||
|
@ -110,9 +118,9 @@ static int get_next_char(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
config_linenr++;
|
cf->linenr++;
|
||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
config_file_eof = 1;
|
cf->eof = 1;
|
||||||
c = '\n';
|
c = '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,21 +129,20 @@ static int get_next_char(void)
|
||||||
|
|
||||||
static char *parse_value(void)
|
static char *parse_value(void)
|
||||||
{
|
{
|
||||||
static struct strbuf value = STRBUF_INIT;
|
|
||||||
int quote = 0, comment = 0, space = 0;
|
int quote = 0, comment = 0, space = 0;
|
||||||
|
|
||||||
strbuf_reset(&value);
|
strbuf_reset(&cf->value);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int c = get_next_char();
|
int c = get_next_char();
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
if (quote)
|
if (quote)
|
||||||
return NULL;
|
return NULL;
|
||||||
return value.buf;
|
return cf->value.buf;
|
||||||
}
|
}
|
||||||
if (comment)
|
if (comment)
|
||||||
continue;
|
continue;
|
||||||
if (isspace(c) && !quote) {
|
if (isspace(c) && !quote) {
|
||||||
if (value.len)
|
if (cf->value.len)
|
||||||
space++;
|
space++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +153,7 @@ static char *parse_value(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (; space; space--)
|
for (; space; space--)
|
||||||
strbuf_addch(&value, ' ');
|
strbuf_addch(&cf->value, ' ');
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
c = get_next_char();
|
c = get_next_char();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -168,14 +175,14 @@ static char *parse_value(void)
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strbuf_addch(&value, c);
|
strbuf_addch(&cf->value, c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (c == '"') {
|
if (c == '"') {
|
||||||
quote = 1-quote;
|
quote = 1-quote;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
strbuf_addch(&value, c);
|
strbuf_addch(&cf->value, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +199,7 @@ static int get_value(config_fn_t fn, void *data, char *name, unsigned int len)
|
||||||
/* Get the full name */
|
/* Get the full name */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = get_next_char();
|
c = get_next_char();
|
||||||
if (config_file_eof)
|
if (cf->eof)
|
||||||
break;
|
break;
|
||||||
if (!iskeychar(c))
|
if (!iskeychar(c))
|
||||||
break;
|
break;
|
||||||
|
@ -256,7 +263,7 @@ static int get_base_var(char *name)
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int c = get_next_char();
|
int c = get_next_char();
|
||||||
if (config_file_eof)
|
if (cf->eof)
|
||||||
return -1;
|
return -1;
|
||||||
if (c == ']')
|
if (c == ']')
|
||||||
return baselen;
|
return baselen;
|
||||||
|
@ -274,7 +281,7 @@ static int git_parse_file(config_fn_t fn, void *data)
|
||||||
{
|
{
|
||||||
int comment = 0;
|
int comment = 0;
|
||||||
int baselen = 0;
|
int baselen = 0;
|
||||||
static char var[MAXNAME];
|
char *var = cf->var;
|
||||||
|
|
||||||
/* U+FEFF Byte Order Mark in UTF8 */
|
/* U+FEFF Byte Order Mark in UTF8 */
|
||||||
static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
|
static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
|
||||||
|
@ -298,7 +305,7 @@ static int git_parse_file(config_fn_t fn, void *data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
if (config_file_eof)
|
if (cf->eof)
|
||||||
return 0;
|
return 0;
|
||||||
comment = 0;
|
comment = 0;
|
||||||
continue;
|
continue;
|
||||||
|
@ -323,7 +330,7 @@ static int git_parse_file(config_fn_t fn, void *data)
|
||||||
if (get_value(fn, data, var, baselen+1) < 0)
|
if (get_value(fn, data, var, baselen+1) < 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
die("bad config file line %d in %s", config_linenr, config_file_name);
|
die("bad config file line %d in %s", cf->linenr, cf->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_unit_factor(const char *end, unsigned long *val)
|
static int parse_unit_factor(const char *end, unsigned long *val)
|
||||||
|
@ -374,8 +381,8 @@ int git_parse_ulong(const char *value, unsigned long *ret)
|
||||||
|
|
||||||
static void die_bad_config(const char *name)
|
static void die_bad_config(const char *name)
|
||||||
{
|
{
|
||||||
if (config_file_name)
|
if (cf && cf->name)
|
||||||
die("bad config value for '%s' in %s", name, config_file_name);
|
die("bad config value for '%s' in %s", name, cf->name);
|
||||||
die("bad config value for '%s'", name);
|
die("bad config value for '%s'", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -795,13 +802,24 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if (f) {
|
if (f) {
|
||||||
config_file = f;
|
config_file top;
|
||||||
config_file_name = filename;
|
|
||||||
config_linenr = 1;
|
/* push config-file parsing state stack */
|
||||||
config_file_eof = 0;
|
top.prev = cf;
|
||||||
|
top.f = f;
|
||||||
|
top.name = filename;
|
||||||
|
top.linenr = 1;
|
||||||
|
top.eof = 0;
|
||||||
|
strbuf_init(&top.value, 1024);
|
||||||
|
cf = ⊤
|
||||||
|
|
||||||
ret = git_parse_file(fn, data);
|
ret = git_parse_file(fn, data);
|
||||||
|
|
||||||
|
/* pop config-file parsing state stack */
|
||||||
|
strbuf_release(&top.value);
|
||||||
|
cf = top.prev;
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
config_file_name = NULL;
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -909,6 +927,7 @@ static int store_aux(const char *key, const char *value, void *cb)
|
||||||
{
|
{
|
||||||
const char *ep;
|
const char *ep;
|
||||||
size_t section_len;
|
size_t section_len;
|
||||||
|
FILE *f = cf->f;
|
||||||
|
|
||||||
switch (store.state) {
|
switch (store.state) {
|
||||||
case KEY_SEEN:
|
case KEY_SEEN:
|
||||||
|
@ -920,7 +939,7 @@ static int store_aux(const char *key, const char *value, void *cb)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
store.offset[store.seen] = ftell(config_file);
|
store.offset[store.seen] = ftell(f);
|
||||||
store.seen++;
|
store.seen++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -947,19 +966,19 @@ static int store_aux(const char *key, const char *value, void *cb)
|
||||||
* Do not increment matches: this is no match, but we
|
* Do not increment matches: this is no match, but we
|
||||||
* just made sure we are in the desired section.
|
* just made sure we are in the desired section.
|
||||||
*/
|
*/
|
||||||
store.offset[store.seen] = ftell(config_file);
|
store.offset[store.seen] = ftell(f);
|
||||||
/* fallthru */
|
/* fallthru */
|
||||||
case SECTION_END_SEEN:
|
case SECTION_END_SEEN:
|
||||||
case START:
|
case START:
|
||||||
if (matches(key, value)) {
|
if (matches(key, value)) {
|
||||||
store.offset[store.seen] = ftell(config_file);
|
store.offset[store.seen] = ftell(f);
|
||||||
store.state = KEY_SEEN;
|
store.state = KEY_SEEN;
|
||||||
store.seen++;
|
store.seen++;
|
||||||
} else {
|
} else {
|
||||||
if (strrchr(key, '.') - key == store.baselen &&
|
if (strrchr(key, '.') - key == store.baselen &&
|
||||||
!strncmp(key, store.key, store.baselen)) {
|
!strncmp(key, store.key, store.baselen)) {
|
||||||
store.state = SECTION_SEEN;
|
store.state = SECTION_SEEN;
|
||||||
store.offset[store.seen] = ftell(config_file);
|
store.offset[store.seen] = ftell(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1415,6 +1434,7 @@ int git_config_rename_section(const char *old_name, const char *new_name)
|
||||||
struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1);
|
struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1);
|
||||||
int out_fd;
|
int out_fd;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
FILE *config_file;
|
||||||
|
|
||||||
if (config_exclusive_filename)
|
if (config_exclusive_filename)
|
||||||
config_filename = xstrdup(config_exclusive_filename);
|
config_filename = xstrdup(config_exclusive_filename);
|
||||||
|
|
5
help.c
5
help.c
|
@ -127,7 +127,10 @@ static int is_executable(const char *name)
|
||||||
!S_ISREG(st.st_mode))
|
!S_ISREG(st.st_mode))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#ifdef WIN32
|
#if defined(WIN32) || defined(__CYGWIN__)
|
||||||
|
#if defined(__CYGWIN__)
|
||||||
|
if ((st.st_mode & S_IXUSR) == 0)
|
||||||
|
#endif
|
||||||
{ /* cannot trust the executable bit, peek into the file instead */
|
{ /* cannot trust the executable bit, peek into the file instead */
|
||||||
char buf[3] = { 0 };
|
char buf[3] = { 0 };
|
||||||
int n;
|
int n;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче