Merge branches 'bw/ls-files-sans-the-index' and 'bw/config-h' into bw/repo-object
* bw/ls-files-sans-the-index: ls-files: factor out tag calculation ls-files: factor out debug info into a function ls-files: convert show_files to take an index ls-files: convert show_ce_entry to take an index ls-files: convert prune_cache to take an index ls-files: convert ce_excluded to take an index ls-files: convert show_ru_info to take an index ls-files: convert show_other_files to take an index ls-files: convert show_killed_files to take an index ls-files: convert write_eolinfo to take an index ls-files: convert overlay_tree_on_cache to take an index tree: convert read_tree to take an index parameter convert: convert renormalize_buffer to take an index convert: convert convert_to_git to take an index convert: convert convert_to_git_filter_fd to take an index convert: convert crlf_to_git to take an index convert: convert get_cached_convert_stats_ascii to take an index * bw/config-h: config: don't implicitly use gitdir or commondir config: respect commondir setup: teach discover_git_directory to respect the commondir config: don't include config.h by default config: remove git_config_iter config: create config.h alias: use the early config machinery to expand aliases t7006: demonstrate a problem with aliases in subdirectories t1308: relax the test verifying that empty alias values are disallowed help: use early config when autocorrecting aliases config: report correct line number upon error discover_git_directory(): avoid setting invalid git_dir
This commit is contained in:
19
setup.c
19
setup.c
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "string-list.h"
|
||||
|
||||
@ -967,19 +968,21 @@ static enum discovery_result setup_git_directory_gently_1(struct strbuf *dir,
|
||||
}
|
||||
}
|
||||
|
||||
const char *discover_git_directory(struct strbuf *gitdir)
|
||||
int discover_git_directory(struct strbuf *commondir,
|
||||
struct strbuf *gitdir)
|
||||
{
|
||||
struct strbuf dir = STRBUF_INIT, err = STRBUF_INIT;
|
||||
size_t gitdir_offset = gitdir->len, cwd_len;
|
||||
size_t commondir_offset = commondir->len;
|
||||
struct repository_format candidate;
|
||||
|
||||
if (strbuf_getcwd(&dir))
|
||||
return NULL;
|
||||
return -1;
|
||||
|
||||
cwd_len = dir.len;
|
||||
if (setup_git_directory_gently_1(&dir, gitdir, 0) <= 0) {
|
||||
strbuf_release(&dir);
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -995,8 +998,10 @@ const char *discover_git_directory(struct strbuf *gitdir)
|
||||
strbuf_insert(gitdir, gitdir_offset, dir.buf, dir.len);
|
||||
}
|
||||
|
||||
get_common_dir(commondir, gitdir->buf + gitdir_offset);
|
||||
|
||||
strbuf_reset(&dir);
|
||||
strbuf_addf(&dir, "%s/config", gitdir->buf + gitdir_offset);
|
||||
strbuf_addf(&dir, "%s/config", commondir->buf + commondir_offset);
|
||||
read_repository_format(&candidate, dir.buf);
|
||||
strbuf_release(&dir);
|
||||
|
||||
@ -1004,10 +1009,12 @@ const char *discover_git_directory(struct strbuf *gitdir)
|
||||
warning("ignoring git dir '%s': %s",
|
||||
gitdir->buf + gitdir_offset, err.buf);
|
||||
strbuf_release(&err);
|
||||
return NULL;
|
||||
strbuf_setlen(commondir, commondir_offset);
|
||||
strbuf_setlen(gitdir, gitdir_offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return gitdir->buf + gitdir_offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *setup_git_directory_gently(int *nongit_ok)
|
||||
|
||||
Reference in New Issue
Block a user