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:
commit
25bf951381
1
advice.c
1
advice.c
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
|
||||
int advice_push_update_rejected = 1;
|
||||
int advice_push_non_ff_current = 1;
|
||||
|
29
alias.c
29
alias.c
@ -1,14 +1,29 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
|
||||
struct config_alias_data {
|
||||
const char *alias;
|
||||
char *v;
|
||||
};
|
||||
|
||||
static int config_alias_cb(const char *key, const char *value, void *d)
|
||||
{
|
||||
struct config_alias_data *data = d;
|
||||
const char *p;
|
||||
|
||||
if (skip_prefix(key, "alias.", &p) && !strcmp(p, data->alias))
|
||||
return git_config_string((const char **)&data->v, key, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *alias_lookup(const char *alias)
|
||||
{
|
||||
char *v = NULL;
|
||||
struct strbuf key = STRBUF_INIT;
|
||||
strbuf_addf(&key, "alias.%s", alias);
|
||||
if (git_config_key_is_valid(key.buf))
|
||||
git_config_get_string(key.buf, &v);
|
||||
strbuf_release(&key);
|
||||
return v;
|
||||
struct config_alias_data data = { alias, NULL };
|
||||
|
||||
read_early_config(config_alias_cb, &data);
|
||||
|
||||
return data.v;
|
||||
}
|
||||
|
||||
#define SPLIT_CMDLINE_BAD_ENDING 1
|
||||
|
3
apply.c
3
apply.c
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "blob.h"
|
||||
#include "delta.h"
|
||||
#include "diff.h"
|
||||
@ -2267,7 +2268,7 @@ static int read_old_data(struct stat *st, const char *path, struct strbuf *buf)
|
||||
case S_IFREG:
|
||||
if (strbuf_read_file(buf, path, st->st_size) != st->st_size)
|
||||
return error(_("unable to open or read %s"), path);
|
||||
convert_to_git(path, buf->buf, buf->len, buf, 0);
|
||||
convert_to_git(&the_index, path, buf->buf, buf->len, buf, 0);
|
||||
return 0;
|
||||
default:
|
||||
return -1;
|
||||
|
@ -2,6 +2,7 @@
|
||||
* Copyright (c) 2005, 2006 Rene Scharfe
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "tar.h"
|
||||
#include "archive.h"
|
||||
#include "streaming.h"
|
||||
|
@ -2,6 +2,7 @@
|
||||
* Copyright (c) 2006 Rene Scharfe
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "archive.h"
|
||||
#include "streaming.h"
|
||||
#include "utf8.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "commit.h"
|
||||
#include "tree-walk.h"
|
||||
|
1
attr.c
1
attr.c
@ -9,6 +9,7 @@
|
||||
|
||||
#define NO_THE_INDEX_COMPATIBILITY_MACROS
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "exec_cmd.h"
|
||||
#include "attr.h"
|
||||
#include "dir.h"
|
||||
|
1
bisect.c
1
bisect.c
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
#include "revision.h"
|
||||
|
2
blame.c
2
blame.c
@ -229,7 +229,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
|
||||
if (strbuf_read(&buf, 0, 0) < 0)
|
||||
die_errno("failed to read from stdin");
|
||||
}
|
||||
convert_to_git(path, buf.buf, buf.len, &buf, 0);
|
||||
convert_to_git(&the_index, path, buf.buf, buf.len, &buf, 0);
|
||||
origin->file.ptr = buf.buf;
|
||||
origin->file.size = buf.len;
|
||||
pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_oid.hash);
|
||||
|
1
branch.c
1
branch.c
@ -1,5 +1,6 @@
|
||||
#include "git-compat-util.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "branch.h"
|
||||
#include "refs.h"
|
||||
#include "remote.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2006 Linus Torvalds
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "lockfile.h"
|
||||
#include "dir.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Based on git-am.sh by Junio C Hamano.
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "exec_cmd.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "color.h"
|
||||
#include "refs.h"
|
||||
#include "commit.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "diff.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "attr.h"
|
||||
#include "quote.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "quote.h"
|
||||
#include "pathspec.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "mailmap.h"
|
||||
#include "parse-options.h"
|
||||
#include "string-list.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "quote.h"
|
||||
#include "cache-tree.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "parse-options.h"
|
||||
#include "refs.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "parse-options.h"
|
||||
#include "string-list.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "parse-options.h"
|
||||
#include "fetch-pack.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "strbuf.h"
|
||||
#include "parse-options.h"
|
||||
#include "string-list.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "tree.h"
|
||||
#include "builtin.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "cache-tree.h"
|
||||
#include "color.h"
|
||||
@ -253,7 +254,8 @@ static int list_paths(struct string_list *list, const char *with_tree,
|
||||
|
||||
if (with_tree) {
|
||||
char *max_prefix = common_prefix(pattern);
|
||||
overlay_tree_on_cache(with_tree, max_prefix ? max_prefix : prefix);
|
||||
overlay_tree_on_index(&the_index, with_tree,
|
||||
max_prefix ? max_prefix : prefix);
|
||||
free(max_prefix);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "color.h"
|
||||
#include "parse-options.h"
|
||||
#include "urlmatch.h"
|
||||
@ -242,8 +243,8 @@ static int get_value(const char *key_, const char *regex_)
|
||||
}
|
||||
}
|
||||
|
||||
git_config_with_options(collect_config, &values,
|
||||
&given_config_source, &config_options);
|
||||
config_with_options(collect_config, &values,
|
||||
&given_config_source, &config_options);
|
||||
|
||||
ret = !values.nr;
|
||||
|
||||
@ -320,8 +321,8 @@ static void get_color(const char *var, const char *def_color)
|
||||
get_color_slot = var;
|
||||
get_color_found = 0;
|
||||
parsed_color[0] = '\0';
|
||||
git_config_with_options(git_get_color_config, NULL,
|
||||
&given_config_source, &config_options);
|
||||
config_with_options(git_get_color_config, NULL,
|
||||
&given_config_source, &config_options);
|
||||
|
||||
if (!get_color_found && def_color) {
|
||||
if (color_parse(def_color, parsed_color) < 0)
|
||||
@ -352,8 +353,8 @@ static int get_colorbool(const char *var, int print)
|
||||
get_colorbool_found = -1;
|
||||
get_diff_color_found = -1;
|
||||
get_color_ui_found = -1;
|
||||
git_config_with_options(git_get_colorbool_config, NULL,
|
||||
&given_config_source, &config_options);
|
||||
config_with_options(git_get_colorbool_config, NULL,
|
||||
&given_config_source, &config_options);
|
||||
|
||||
if (get_colorbool_found < 0) {
|
||||
if (!strcmp(get_colorbool_slot, "color.diff"))
|
||||
@ -441,8 +442,8 @@ static int get_urlmatch(const char *var, const char *url)
|
||||
show_keys = 1;
|
||||
}
|
||||
|
||||
git_config_with_options(urlmatch_config_entry, &config,
|
||||
&given_config_source, &config_options);
|
||||
config_with_options(urlmatch_config_entry, &config,
|
||||
&given_config_source, &config_options);
|
||||
|
||||
ret = !values.nr;
|
||||
|
||||
@ -538,6 +539,10 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
||||
config_options.respect_includes = !given_config_source.file;
|
||||
else
|
||||
config_options.respect_includes = respect_includes_opt;
|
||||
if (!nongit) {
|
||||
config_options.commondir = get_git_common_dir();
|
||||
config_options.git_dir = get_git_dir();
|
||||
}
|
||||
|
||||
if (end_null) {
|
||||
term = '\0';
|
||||
@ -582,9 +587,9 @@ int cmd_config(int argc, const char **argv, const char *prefix)
|
||||
|
||||
if (actions == ACTION_LIST) {
|
||||
check_argc(argc, 0, 0);
|
||||
if (git_config_with_options(show_all_config, NULL,
|
||||
&given_config_source,
|
||||
&config_options) < 0) {
|
||||
if (config_with_options(show_all_config, NULL,
|
||||
&given_config_source,
|
||||
&config_options) < 0) {
|
||||
if (given_config_source.file)
|
||||
die_errno("unable to read config file '%s'",
|
||||
given_config_source.file);
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "commit.h"
|
||||
#include "tag.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "diff.h"
|
||||
#include "commit.h"
|
||||
#include "revision.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "diff.h"
|
||||
#include "commit.h"
|
||||
#include "revision.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "diff.h"
|
||||
#include "commit.h"
|
||||
#include "log-tree.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (c) 2006 Junio C Hamano
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "color.h"
|
||||
#include "commit.h"
|
||||
|
@ -12,6 +12,7 @@
|
||||
* Copyright (C) 2016 Johannes Schindelin
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "run-command.h"
|
||||
#include "exec_cmd.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "commit.h"
|
||||
#include "object.h"
|
||||
|
@ -2,6 +2,7 @@
|
||||
* "git fetch"
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "commit.h"
|
||||
#include "builtin.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "object.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "tree.h"
|
||||
#include "blob.h"
|
||||
|
@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "tempfile.h"
|
||||
#include "lockfile.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (c) 2006 Junio C Hamano
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "blob.h"
|
||||
#include "tree.h"
|
||||
#include "commit.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Copyright (C) Junio C Hamano, 2005
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "blob.h"
|
||||
#include "quote.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -2,6 +2,7 @@
|
||||
* Builtin help command
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "exec_cmd.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "delta.h"
|
||||
#include "pack.h"
|
||||
#include "csum-file.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "builtin.h"
|
||||
#include "exec_cmd.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
* 2006 Junio Hamano
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "color.h"
|
||||
#include "commit.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "quote.h"
|
||||
#include "dir.h"
|
||||
#include "builtin.h"
|
||||
@ -53,17 +54,17 @@ static const char *tag_modified = "";
|
||||
static const char *tag_skip_worktree = "";
|
||||
static const char *tag_resolve_undo = "";
|
||||
|
||||
static void write_eolinfo(const struct cache_entry *ce, const char *path)
|
||||
static void write_eolinfo(const struct index_state *istate,
|
||||
const struct cache_entry *ce, const char *path)
|
||||
{
|
||||
if (!show_eol)
|
||||
return;
|
||||
else {
|
||||
if (show_eol) {
|
||||
struct stat st;
|
||||
const char *i_txt = "";
|
||||
const char *w_txt = "";
|
||||
const char *a_txt = get_convert_attr_ascii(path);
|
||||
if (ce && S_ISREG(ce->ce_mode))
|
||||
i_txt = get_cached_convert_stats_ascii(ce->name);
|
||||
i_txt = get_cached_convert_stats_ascii(istate,
|
||||
ce->name);
|
||||
if (!lstat(path, &st) && S_ISREG(st.st_mode))
|
||||
w_txt = get_wt_convert_stats_ascii(path);
|
||||
printf("i/%-5s w/%-5s attr/%-17s\t", i_txt, w_txt, a_txt);
|
||||
@ -93,6 +94,43 @@ static void write_name(const char *name)
|
||||
strbuf_release(&full_name);
|
||||
}
|
||||
|
||||
static const char *get_tag(const struct cache_entry *ce, const char *tag)
|
||||
{
|
||||
static char alttag[4];
|
||||
|
||||
if (tag && *tag && show_valid_bit && (ce->ce_flags & CE_VALID)) {
|
||||
memcpy(alttag, tag, 3);
|
||||
|
||||
if (isalpha(tag[0])) {
|
||||
alttag[0] = tolower(tag[0]);
|
||||
} else if (tag[0] == '?') {
|
||||
alttag[0] = '!';
|
||||
} else {
|
||||
alttag[0] = 'v';
|
||||
alttag[1] = tag[0];
|
||||
alttag[2] = ' ';
|
||||
alttag[3] = 0;
|
||||
}
|
||||
|
||||
tag = alttag;
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
static void print_debug(const struct cache_entry *ce)
|
||||
{
|
||||
if (debug_mode) {
|
||||
const struct stat_data *sd = &ce->ce_stat_data;
|
||||
|
||||
printf(" ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
|
||||
printf(" mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
|
||||
printf(" dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
|
||||
printf(" uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
|
||||
printf(" size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
|
||||
}
|
||||
}
|
||||
|
||||
static void show_dir_entry(const char *tag, struct dir_entry *ent)
|
||||
{
|
||||
int len = max_prefix_len;
|
||||
@ -104,23 +142,25 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)
|
||||
return;
|
||||
|
||||
fputs(tag, stdout);
|
||||
write_eolinfo(NULL, ent->name);
|
||||
write_eolinfo(NULL, NULL, ent->name);
|
||||
write_name(ent->name);
|
||||
}
|
||||
|
||||
static void show_other_files(struct dir_struct *dir)
|
||||
static void show_other_files(const struct index_state *istate,
|
||||
const struct dir_struct *dir)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < dir->nr; i++) {
|
||||
struct dir_entry *ent = dir->entries[i];
|
||||
if (!cache_name_is_other(ent->name, ent->len))
|
||||
if (!index_name_is_other(istate, ent->name, ent->len))
|
||||
continue;
|
||||
show_dir_entry(tag_other, ent);
|
||||
}
|
||||
}
|
||||
|
||||
static void show_killed_files(struct dir_struct *dir)
|
||||
static void show_killed_files(const struct index_state *istate,
|
||||
const struct dir_struct *dir)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < dir->nr; i++) {
|
||||
@ -134,29 +174,29 @@ static void show_killed_files(struct dir_struct *dir)
|
||||
/* If ent->name is prefix of an entry in the
|
||||
* cache, it will be killed.
|
||||
*/
|
||||
pos = cache_name_pos(ent->name, ent->len);
|
||||
pos = index_name_pos(istate, ent->name, ent->len);
|
||||
if (0 <= pos)
|
||||
die("BUG: killed-file %.*s not found",
|
||||
ent->len, ent->name);
|
||||
pos = -pos - 1;
|
||||
while (pos < active_nr &&
|
||||
ce_stage(active_cache[pos]))
|
||||
while (pos < istate->cache_nr &&
|
||||
ce_stage(istate->cache[pos]))
|
||||
pos++; /* skip unmerged */
|
||||
if (active_nr <= pos)
|
||||
if (istate->cache_nr <= pos)
|
||||
break;
|
||||
/* pos points at a name immediately after
|
||||
* ent->name in the cache. Does it expect
|
||||
* ent->name to be a directory?
|
||||
*/
|
||||
len = ce_namelen(active_cache[pos]);
|
||||
len = ce_namelen(istate->cache[pos]);
|
||||
if ((ent->len < len) &&
|
||||
!strncmp(active_cache[pos]->name,
|
||||
!strncmp(istate->cache[pos]->name,
|
||||
ent->name, ent->len) &&
|
||||
active_cache[pos]->name[ent->len] == '/')
|
||||
istate->cache[pos]->name[ent->len] == '/')
|
||||
killed = 1;
|
||||
break;
|
||||
}
|
||||
if (0 <= cache_name_pos(ent->name, sp - ent->name)) {
|
||||
if (0 <= index_name_pos(istate, ent->name, sp - ent->name)) {
|
||||
/* If any of the leading directories in
|
||||
* ent->name is registered in the cache,
|
||||
* ent->name will be killed.
|
||||
@ -230,7 +270,8 @@ static void show_gitlink(const struct cache_entry *ce)
|
||||
exit(status);
|
||||
}
|
||||
|
||||
static void show_ce_entry(const char *tag, const struct cache_entry *ce)
|
||||
static void show_ce_entry(const struct index_state *istate,
|
||||
const char *tag, const struct cache_entry *ce)
|
||||
{
|
||||
struct strbuf name = STRBUF_INIT;
|
||||
int len = max_prefix_len;
|
||||
@ -248,22 +289,7 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
|
||||
len, ps_matched,
|
||||
S_ISDIR(ce->ce_mode) ||
|
||||
S_ISGITLINK(ce->ce_mode))) {
|
||||
if (tag && *tag && show_valid_bit &&
|
||||
(ce->ce_flags & CE_VALID)) {
|
||||
static char alttag[4];
|
||||
memcpy(alttag, tag, 3);
|
||||
if (isalpha(tag[0]))
|
||||
alttag[0] = tolower(tag[0]);
|
||||
else if (tag[0] == '?')
|
||||
alttag[0] = '!';
|
||||
else {
|
||||
alttag[0] = 'v';
|
||||
alttag[1] = tag[0];
|
||||
alttag[2] = ' ';
|
||||
alttag[3] = 0;
|
||||
}
|
||||
tag = alttag;
|
||||
}
|
||||
tag = get_tag(ce, tag);
|
||||
|
||||
if (!show_stage) {
|
||||
fputs(tag, stdout);
|
||||
@ -274,30 +300,22 @@ static void show_ce_entry(const char *tag, const struct cache_entry *ce)
|
||||
find_unique_abbrev(ce->oid.hash, abbrev),
|
||||
ce_stage(ce));
|
||||
}
|
||||
write_eolinfo(ce, ce->name);
|
||||
write_eolinfo(istate, ce, ce->name);
|
||||
write_name(ce->name);
|
||||
if (debug_mode) {
|
||||
const struct stat_data *sd = &ce->ce_stat_data;
|
||||
|
||||
printf(" ctime: %d:%d\n", sd->sd_ctime.sec, sd->sd_ctime.nsec);
|
||||
printf(" mtime: %d:%d\n", sd->sd_mtime.sec, sd->sd_mtime.nsec);
|
||||
printf(" dev: %d\tino: %d\n", sd->sd_dev, sd->sd_ino);
|
||||
printf(" uid: %d\tgid: %d\n", sd->sd_uid, sd->sd_gid);
|
||||
printf(" size: %d\tflags: %x\n", sd->sd_size, ce->ce_flags);
|
||||
}
|
||||
print_debug(ce);
|
||||
}
|
||||
|
||||
strbuf_release(&name);
|
||||
}
|
||||
|
||||
static void show_ru_info(void)
|
||||
static void show_ru_info(const struct index_state *istate)
|
||||
{
|
||||
struct string_list_item *item;
|
||||
|
||||
if (!the_index.resolve_undo)
|
||||
if (!istate->resolve_undo)
|
||||
return;
|
||||
|
||||
for_each_string_list_item(item, the_index.resolve_undo) {
|
||||
for_each_string_list_item(item, istate->resolve_undo) {
|
||||
const char *path = item->string;
|
||||
struct resolve_undo_info *ui = item->util;
|
||||
int i, len;
|
||||
@ -319,13 +337,14 @@ static void show_ru_info(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int ce_excluded(struct dir_struct *dir, const struct cache_entry *ce)
|
||||
static int ce_excluded(struct dir_struct *dir, struct index_state *istate,
|
||||
const struct cache_entry *ce)
|
||||
{
|
||||
int dtype = ce_to_dtype(ce);
|
||||
return is_excluded(dir, &the_index, ce->name, &dtype);
|
||||
return is_excluded(dir, istate, ce->name, &dtype);
|
||||
}
|
||||
|
||||
static void show_files(struct dir_struct *dir)
|
||||
static void show_files(struct index_state *istate, struct dir_struct *dir)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -333,33 +352,33 @@ static void show_files(struct dir_struct *dir)
|
||||
if (show_others || show_killed) {
|
||||
if (!show_others)
|
||||
dir->flags |= DIR_COLLECT_KILLED_ONLY;
|
||||
fill_directory(dir, &the_index, &pathspec);
|
||||
fill_directory(dir, istate, &pathspec);
|
||||
if (show_others)
|
||||
show_other_files(dir);
|
||||
show_other_files(istate, dir);
|
||||
if (show_killed)
|
||||
show_killed_files(dir);
|
||||
show_killed_files(istate, dir);
|
||||
}
|
||||
if (show_cached || show_stage) {
|
||||
for (i = 0; i < active_nr; i++) {
|
||||
const struct cache_entry *ce = active_cache[i];
|
||||
for (i = 0; i < istate->cache_nr; i++) {
|
||||
const struct cache_entry *ce = istate->cache[i];
|
||||
if ((dir->flags & DIR_SHOW_IGNORED) &&
|
||||
!ce_excluded(dir, ce))
|
||||
!ce_excluded(dir, istate, ce))
|
||||
continue;
|
||||
if (show_unmerged && !ce_stage(ce))
|
||||
continue;
|
||||
if (ce->ce_flags & CE_UPDATE)
|
||||
continue;
|
||||
show_ce_entry(ce_stage(ce) ? tag_unmerged :
|
||||
show_ce_entry(istate, ce_stage(ce) ? tag_unmerged :
|
||||
(ce_skip_worktree(ce) ? tag_skip_worktree : tag_cached), ce);
|
||||
}
|
||||
}
|
||||
if (show_deleted || show_modified) {
|
||||
for (i = 0; i < active_nr; i++) {
|
||||
const struct cache_entry *ce = active_cache[i];
|
||||
for (i = 0; i < istate->cache_nr; i++) {
|
||||
const struct cache_entry *ce = istate->cache[i];
|
||||
struct stat st;
|
||||
int err;
|
||||
if ((dir->flags & DIR_SHOW_IGNORED) &&
|
||||
!ce_excluded(dir, ce))
|
||||
!ce_excluded(dir, istate, ce))
|
||||
continue;
|
||||
if (ce->ce_flags & CE_UPDATE)
|
||||
continue;
|
||||
@ -367,9 +386,9 @@ static void show_files(struct dir_struct *dir)
|
||||
continue;
|
||||
err = lstat(ce->name, &st);
|
||||
if (show_deleted && err)
|
||||
show_ce_entry(tag_removed, ce);
|
||||
if (show_modified && ce_modified(ce, &st, 0))
|
||||
show_ce_entry(tag_modified, ce);
|
||||
show_ce_entry(istate, tag_removed, ce);
|
||||
if (show_modified && ie_modified(istate, ce, &st, 0))
|
||||
show_ce_entry(istate, tag_modified, ce);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -377,30 +396,31 @@ static void show_files(struct dir_struct *dir)
|
||||
/*
|
||||
* Prune the index to only contain stuff starting with "prefix"
|
||||
*/
|
||||
static void prune_cache(const char *prefix, size_t prefixlen)
|
||||
static void prune_index(struct index_state *istate,
|
||||
const char *prefix, size_t prefixlen)
|
||||
{
|
||||
int pos;
|
||||
unsigned int first, last;
|
||||
|
||||
if (!prefix)
|
||||
return;
|
||||
pos = cache_name_pos(prefix, prefixlen);
|
||||
pos = index_name_pos(istate, prefix, prefixlen);
|
||||
if (pos < 0)
|
||||
pos = -pos-1;
|
||||
first = pos;
|
||||
last = active_nr;
|
||||
last = istate->cache_nr;
|
||||
while (last > first) {
|
||||
int next = (last + first) >> 1;
|
||||
const struct cache_entry *ce = active_cache[next];
|
||||
const struct cache_entry *ce = istate->cache[next];
|
||||
if (!strncmp(ce->name, prefix, prefixlen)) {
|
||||
first = next+1;
|
||||
continue;
|
||||
}
|
||||
last = next;
|
||||
}
|
||||
memmove(active_cache, active_cache + pos,
|
||||
memmove(istate->cache, istate->cache + pos,
|
||||
(last - pos) * sizeof(struct cache_entry *));
|
||||
active_nr = last - pos;
|
||||
istate->cache_nr = last - pos;
|
||||
}
|
||||
|
||||
static int get_common_prefix_len(const char *common_prefix)
|
||||
@ -430,7 +450,8 @@ static int get_common_prefix_len(const char *common_prefix)
|
||||
* that were given from the command line. We are not
|
||||
* going to write this index out.
|
||||
*/
|
||||
void overlay_tree_on_cache(const char *tree_name, const char *prefix)
|
||||
void overlay_tree_on_index(struct index_state *istate,
|
||||
const char *tree_name, const char *prefix)
|
||||
{
|
||||
struct tree *tree;
|
||||
struct object_id oid;
|
||||
@ -445,8 +466,8 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
|
||||
die("bad tree-ish %s", tree_name);
|
||||
|
||||
/* Hoist the unmerged entries up to stage #3 to make room */
|
||||
for (i = 0; i < active_nr; i++) {
|
||||
struct cache_entry *ce = active_cache[i];
|
||||
for (i = 0; i < istate->cache_nr; i++) {
|
||||
struct cache_entry *ce = istate->cache[i];
|
||||
if (!ce_stage(ce))
|
||||
continue;
|
||||
ce->ce_flags |= CE_STAGEMASK;
|
||||
@ -459,11 +480,11 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
|
||||
PATHSPEC_PREFER_CWD, prefix, matchbuf);
|
||||
} else
|
||||
memset(&pathspec, 0, sizeof(pathspec));
|
||||
if (read_tree(tree, 1, &pathspec))
|
||||
if (read_tree(tree, 1, &pathspec, istate))
|
||||
die("unable to read tree entries %s", tree_name);
|
||||
|
||||
for (i = 0; i < active_nr; i++) {
|
||||
struct cache_entry *ce = active_cache[i];
|
||||
for (i = 0; i < istate->cache_nr; i++) {
|
||||
struct cache_entry *ce = istate->cache[i];
|
||||
switch (ce_stage(ce)) {
|
||||
case 0:
|
||||
last_stage0 = ce;
|
||||
@ -657,7 +678,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
|
||||
max_prefix = common_prefix(&pathspec);
|
||||
max_prefix_len = get_common_prefix_len(max_prefix);
|
||||
|
||||
prune_cache(max_prefix, max_prefix_len);
|
||||
prune_index(&the_index, max_prefix, max_prefix_len);
|
||||
|
||||
/* Treat unmatching pathspec elements as errors */
|
||||
if (pathspec.nr && error_unmatch)
|
||||
@ -678,11 +699,11 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
|
||||
*/
|
||||
if (show_stage || show_unmerged)
|
||||
die("ls-files --with-tree is incompatible with -s or -u");
|
||||
overlay_tree_on_cache(with_tree, max_prefix);
|
||||
overlay_tree_on_index(&the_index, with_tree, max_prefix);
|
||||
}
|
||||
show_files(&dir);
|
||||
show_files(&the_index, &dir);
|
||||
if (show_resolve_undo)
|
||||
show_ru_info();
|
||||
show_ru_info(&the_index);
|
||||
|
||||
if (ps_matched) {
|
||||
int bad;
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "blob.h"
|
||||
#include "tree.h"
|
||||
#include "commit.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "refs.h"
|
||||
#include "diff.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "xdiff/xdiff.h"
|
||||
#include "xdiff-interface.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "parse-options.h"
|
||||
#include "builtin.h"
|
||||
#include "lockfile.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2006 Johannes Schindelin
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "pathspec.h"
|
||||
#include "lockfile.h"
|
||||
#include "dir.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "tag.h"
|
||||
#include "refs.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "notes.h"
|
||||
#include "blob.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "attr.h"
|
||||
#include "object.h"
|
||||
#include "blob.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
|
||||
static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)
|
||||
{
|
||||
|
@ -6,6 +6,7 @@
|
||||
* Fetch one or more remote refs and merge it/them into the current HEAD.
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
#include "exec_cmd.h"
|
||||
|
@ -2,6 +2,7 @@
|
||||
* "git push"
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "run-command.h"
|
||||
#include "builtin.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "object.h"
|
||||
#include "tree.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "parse-options.h"
|
||||
#include "sequencer.h"
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "pack.h"
|
||||
#include "refs.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "commit.h"
|
||||
#include "refs.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "parse-options.h"
|
||||
#include "transport.h"
|
||||
#include "remote.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "parse-options.h"
|
||||
#include "run-command.h"
|
||||
|
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "refs.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "dir.h"
|
||||
#include "parse-options.h"
|
||||
#include "string-list.h"
|
||||
|
@ -8,6 +8,7 @@
|
||||
* Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "tag.h"
|
||||
#include "object.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
#include "revision.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "refs.h"
|
||||
#include "quote.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
#include "diff.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Linus Torvalds 2006
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "dir.h"
|
||||
#include "cache-tree.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "refs.h"
|
||||
#include "pkt-line.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
#include "string-list.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "commit.h"
|
||||
#include "refs.h"
|
||||
#include "builtin.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "parse-options.h"
|
||||
#include "strbuf.h"
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "parse-options.h"
|
||||
#include "quote.h"
|
||||
#include "pathspec.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
#include "cache.h"
|
||||
#include "refs.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "refs.h"
|
||||
#include "tag.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
|
||||
static char *create_temp_file(unsigned char *sha1)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "object.h"
|
||||
#include "delta.h"
|
||||
#include "pack.h"
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Linus Torvalds, 2005
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "quote.h"
|
||||
#include "cache-tree.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "refs.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Copyright (C) Eric Biederman, 2005
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "config.h"
|
||||
|
||||
static const char var_usage[] = "git var (-l | <variable>)";
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
* Based on git-verify-tag
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "commit.h"
|
||||
#include "run-command.h"
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "run-command.h"
|
||||
#include "parse-options.h"
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
* Based on git-verify-tag.sh
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "tag.h"
|
||||
#include "run-command.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "builtin.h"
|
||||
#include "dir.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
#include "builtin.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "tree.h"
|
||||
#include "cache-tree.h"
|
||||
#include "parse-options.h"
|
||||
|
205
cache.h
205
cache.h
@ -525,12 +525,15 @@ extern void set_git_work_tree(const char *tree);
|
||||
|
||||
extern void setup_work_tree(void);
|
||||
/*
|
||||
* Find GIT_DIR of the repository that contains the current working directory,
|
||||
* without changing the working directory or other global state. The result is
|
||||
* appended to gitdir. The return value is either NULL if no repository was
|
||||
* found, or pointing to the path inside gitdir's buffer.
|
||||
* Find the commondir and gitdir of the repository that contains the current
|
||||
* working directory, without changing the working directory or other global
|
||||
* state. The result is appended to commondir and gitdir. If the discovered
|
||||
* gitdir does not correspond to a worktree, then 'commondir' and 'gitdir' will
|
||||
* both have the same result appended to the buffer. The return value is
|
||||
* either 0 upon success and non-zero if no repository was found.
|
||||
*/
|
||||
extern const char *discover_git_directory(struct strbuf *gitdir);
|
||||
extern int discover_git_directory(struct strbuf *commondir,
|
||||
struct strbuf *gitdir);
|
||||
extern const char *setup_git_directory_gently(int *);
|
||||
extern const char *setup_git_directory(void);
|
||||
extern char *prefix_path(const char *prefix, int len, const char *path);
|
||||
@ -1879,188 +1882,9 @@ extern int packed_object_info(struct packed_git *pack, off_t offset, struct obje
|
||||
/* Dumb servers support */
|
||||
extern int update_server_info(int);
|
||||
|
||||
/* git_config_parse_key() returns these negated: */
|
||||
#define CONFIG_INVALID_KEY 1
|
||||
#define CONFIG_NO_SECTION_OR_NAME 2
|
||||
/* git_config_set_gently(), git_config_set_multivar_gently() return the above or these: */
|
||||
#define CONFIG_NO_LOCK -1
|
||||
#define CONFIG_INVALID_FILE 3
|
||||
#define CONFIG_NO_WRITE 4
|
||||
#define CONFIG_NOTHING_SET 5
|
||||
#define CONFIG_INVALID_PATTERN 6
|
||||
#define CONFIG_GENERIC_ERROR 7
|
||||
|
||||
#define CONFIG_REGEX_NONE ((void *)1)
|
||||
|
||||
struct git_config_source {
|
||||
unsigned int use_stdin:1;
|
||||
const char *file;
|
||||
const char *blob;
|
||||
};
|
||||
|
||||
enum config_origin_type {
|
||||
CONFIG_ORIGIN_BLOB,
|
||||
CONFIG_ORIGIN_FILE,
|
||||
CONFIG_ORIGIN_STDIN,
|
||||
CONFIG_ORIGIN_SUBMODULE_BLOB,
|
||||
CONFIG_ORIGIN_CMDLINE
|
||||
};
|
||||
|
||||
struct config_options {
|
||||
unsigned int respect_includes : 1;
|
||||
const char *git_dir;
|
||||
};
|
||||
|
||||
typedef int (*config_fn_t)(const char *, const char *, void *);
|
||||
extern int git_default_config(const char *, const char *, void *);
|
||||
extern int git_config_from_file(config_fn_t fn, const char *, void *);
|
||||
extern int git_config_from_mem(config_fn_t fn, const enum config_origin_type,
|
||||
const char *name, const char *buf, size_t len, void *data);
|
||||
extern int git_config_from_blob_sha1(config_fn_t fn, const char *name,
|
||||
const unsigned char *sha1, void *data);
|
||||
extern void git_config_push_parameter(const char *text);
|
||||
extern int git_config_from_parameters(config_fn_t fn, void *data);
|
||||
extern void read_early_config(config_fn_t cb, void *data);
|
||||
extern void git_config(config_fn_t fn, void *);
|
||||
extern int git_config_with_options(config_fn_t fn, void *,
|
||||
struct git_config_source *config_source,
|
||||
const struct config_options *opts);
|
||||
extern int git_parse_ulong(const char *, unsigned long *);
|
||||
extern int git_parse_maybe_bool(const char *);
|
||||
extern int git_config_int(const char *, const char *);
|
||||
extern int64_t git_config_int64(const char *, const char *);
|
||||
extern unsigned long git_config_ulong(const char *, const char *);
|
||||
extern ssize_t git_config_ssize_t(const char *, const char *);
|
||||
extern int git_config_bool_or_int(const char *, const char *, int *);
|
||||
extern int git_config_bool(const char *, const char *);
|
||||
extern int git_config_maybe_bool(const char *, const char *);
|
||||
extern int git_config_string(const char **, const char *, const char *);
|
||||
extern int git_config_pathname(const char **, const char *, const char *);
|
||||
extern int git_config_set_in_file_gently(const char *, const char *, const char *);
|
||||
extern void git_config_set_in_file(const char *, const char *, const char *);
|
||||
extern int git_config_set_gently(const char *, const char *);
|
||||
extern void git_config_set(const char *, const char *);
|
||||
extern int git_config_parse_key(const char *, char **, int *);
|
||||
extern int git_config_key_is_valid(const char *key);
|
||||
extern int git_config_set_multivar_gently(const char *, const char *, const char *, int);
|
||||
extern void git_config_set_multivar(const char *, const char *, const char *, int);
|
||||
extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int);
|
||||
extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);
|
||||
extern int git_config_rename_section(const char *, const char *);
|
||||
extern int git_config_rename_section_in_file(const char *, const char *, const char *);
|
||||
extern const char *git_etc_gitconfig(void);
|
||||
extern int git_env_bool(const char *, int);
|
||||
extern unsigned long git_env_ulong(const char *, unsigned long);
|
||||
extern int git_config_system(void);
|
||||
extern int config_error_nonbool(const char *);
|
||||
#if defined(__GNUC__)
|
||||
#define config_error_nonbool(s) (config_error_nonbool(s), const_error())
|
||||
#endif
|
||||
extern const char *get_log_output_encoding(void);
|
||||
extern const char *get_commit_output_encoding(void);
|
||||
|
||||
extern int git_config_parse_parameter(const char *, config_fn_t fn, void *data);
|
||||
|
||||
enum config_scope {
|
||||
CONFIG_SCOPE_UNKNOWN = 0,
|
||||
CONFIG_SCOPE_SYSTEM,
|
||||
CONFIG_SCOPE_GLOBAL,
|
||||
CONFIG_SCOPE_REPO,
|
||||
CONFIG_SCOPE_CMDLINE,
|
||||
};
|
||||
|
||||
extern enum config_scope current_config_scope(void);
|
||||
extern const char *current_config_origin_type(void);
|
||||
extern const char *current_config_name(void);
|
||||
|
||||
struct config_include_data {
|
||||
int depth;
|
||||
config_fn_t fn;
|
||||
void *data;
|
||||
const struct config_options *opts;
|
||||
};
|
||||
#define CONFIG_INCLUDE_INIT { 0 }
|
||||
extern int git_config_include(const char *name, const char *value, void *data);
|
||||
|
||||
/*
|
||||
* Match and parse a config key of the form:
|
||||
*
|
||||
* section.(subsection.)?key
|
||||
*
|
||||
* (i.e., what gets handed to a config_fn_t). The caller provides the section;
|
||||
* we return -1 if it does not match, 0 otherwise. The subsection and key
|
||||
* out-parameters are filled by the function (and *subsection is NULL if it is
|
||||
* missing).
|
||||
*
|
||||
* If the subsection pointer-to-pointer passed in is NULL, returns 0 only if
|
||||
* there is no subsection at all.
|
||||
*/
|
||||
extern int parse_config_key(const char *var,
|
||||
const char *section,
|
||||
const char **subsection, int *subsection_len,
|
||||
const char **key);
|
||||
|
||||
struct config_set_element {
|
||||
struct hashmap_entry ent;
|
||||
char *key;
|
||||
struct string_list value_list;
|
||||
};
|
||||
|
||||
struct configset_list_item {
|
||||
struct config_set_element *e;
|
||||
int value_index;
|
||||
};
|
||||
|
||||
/*
|
||||
* the contents of the list are ordered according to their
|
||||
* position in the config files and order of parsing the files.
|
||||
* (i.e. key-value pair at the last position of .git/config will
|
||||
* be at the last item of the list)
|
||||
*/
|
||||
struct configset_list {
|
||||
struct configset_list_item *items;
|
||||
unsigned int nr, alloc;
|
||||
};
|
||||
|
||||
struct config_set {
|
||||
struct hashmap config_hash;
|
||||
int hash_initialized;
|
||||
struct configset_list list;
|
||||
};
|
||||
|
||||
extern void git_configset_init(struct config_set *cs);
|
||||
extern int git_configset_add_file(struct config_set *cs, const char *filename);
|
||||
extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value);
|
||||
extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key);
|
||||
extern void git_configset_clear(struct config_set *cs);
|
||||
extern int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest);
|
||||
extern int git_configset_get_string(struct config_set *cs, const char *key, char **dest);
|
||||
extern int git_configset_get_int(struct config_set *cs, const char *key, int *dest);
|
||||
extern int git_configset_get_ulong(struct config_set *cs, const char *key, unsigned long *dest);
|
||||
extern int git_configset_get_bool(struct config_set *cs, const char *key, int *dest);
|
||||
extern int git_configset_get_bool_or_int(struct config_set *cs, const char *key, int *is_bool, int *dest);
|
||||
extern int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *dest);
|
||||
extern int git_configset_get_pathname(struct config_set *cs, const char *key, const char **dest);
|
||||
|
||||
extern int git_config_get_value(const char *key, const char **value);
|
||||
extern const struct string_list *git_config_get_value_multi(const char *key);
|
||||
extern void git_config_clear(void);
|
||||
extern void git_config_iter(config_fn_t fn, void *data);
|
||||
extern int git_config_get_string_const(const char *key, const char **dest);
|
||||
extern int git_config_get_string(const char *key, char **dest);
|
||||
extern int git_config_get_int(const char *key, int *dest);
|
||||
extern int git_config_get_ulong(const char *key, unsigned long *dest);
|
||||
extern int git_config_get_bool(const char *key, int *dest);
|
||||
extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest);
|
||||
extern int git_config_get_maybe_bool(const char *key, int *dest);
|
||||
extern int git_config_get_pathname(const char *key, const char **dest);
|
||||
extern int git_config_get_untracked_cache(void);
|
||||
extern int git_config_get_split_index(void);
|
||||
extern int git_config_get_max_percent_split_change(void);
|
||||
|
||||
/* This dies if the configured or default date is in the future */
|
||||
extern int git_config_get_expiry(const char *key, const char **output);
|
||||
|
||||
/*
|
||||
* This is a hack for test programs like test-dump-untracked-cache to
|
||||
* ensure that they do not modify the untracked cache when reading it.
|
||||
@ -2068,16 +1892,6 @@ extern int git_config_get_expiry(const char *key, const char **output);
|
||||
*/
|
||||
extern int ignore_untracked_cache_config;
|
||||
|
||||
struct key_value_info {
|
||||
const char *filename;
|
||||
int linenr;
|
||||
enum config_origin_type origin_type;
|
||||
enum config_scope scope;
|
||||
};
|
||||
|
||||
extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
|
||||
extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr);
|
||||
|
||||
extern int committer_ident_sufficiently_given(void);
|
||||
extern int author_ident_sufficiently_given(void);
|
||||
|
||||
@ -2193,7 +2007,8 @@ extern int ws_blank_line(const char *line, int len, unsigned ws_rule);
|
||||
#define ws_tab_width(rule) ((rule) & WS_TAB_WIDTH_MASK)
|
||||
|
||||
/* ls-files */
|
||||
void overlay_tree_on_cache(const char *tree_name, const char *prefix);
|
||||
void overlay_tree_on_index(struct index_state *istate,
|
||||
const char *tree_name, const char *prefix);
|
||||
|
||||
char *alias_lookup(const char *alias);
|
||||
int split_cmdline(char *cmdline, const char ***argv);
|
||||
|
1
color.c
1
color.c
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "color.h"
|
||||
|
||||
static int git_use_color_default = GIT_COLOR_AUTO;
|
||||
|
1
column.c
1
column.c
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "column.h"
|
||||
#include "string-list.h"
|
||||
#include "parse-options.h"
|
||||
|
@ -1053,7 +1053,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
|
||||
if (is_file) {
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
|
||||
if (convert_to_git(elem->path, result, len, &buf, safe_crlf)) {
|
||||
if (convert_to_git(&the_index, elem->path, result, len, &buf, safe_crlf)) {
|
||||
free(result);
|
||||
result = strbuf_detach(&buf, &len);
|
||||
result_size = len;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define PRECOMPOSE_UNICODE_C
|
||||
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "utf8.h"
|
||||
#include "precompose_utf8.h"
|
||||
|
||||
|
44
config.c
44
config.c
@ -6,6 +6,7 @@
|
||||
*
|
||||
*/
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "lockfile.h"
|
||||
#include "exec_cmd.h"
|
||||
#include "strbuf.h"
|
||||
@ -218,8 +219,6 @@ static int include_by_gitdir(const struct config_options *opts,
|
||||
|
||||
if (opts->git_dir)
|
||||
git_dir = opts->git_dir;
|
||||
else if (have_git_dir())
|
||||
git_dir = get_git_dir();
|
||||
else
|
||||
goto done;
|
||||
|
||||
@ -604,7 +603,8 @@ static int get_value(config_fn_t fn, void *data, struct strbuf *name)
|
||||
*/
|
||||
cf->linenr--;
|
||||
ret = fn(name->buf, value, data);
|
||||
cf->linenr++;
|
||||
if (ret >= 0)
|
||||
cf->linenr++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1545,10 +1545,8 @@ static int do_git_config_sequence(const struct config_options *opts,
|
||||
char *user_config = expand_user_path("~/.gitconfig", 0);
|
||||
char *repo_config;
|
||||
|
||||
if (opts->git_dir)
|
||||
repo_config = mkpathdup("%s/config", opts->git_dir);
|
||||
else if (have_git_dir())
|
||||
repo_config = git_pathdup("config");
|
||||
if (opts->commondir)
|
||||
repo_config = mkpathdup("%s/config", opts->commondir);
|
||||
else
|
||||
repo_config = NULL;
|
||||
|
||||
@ -1579,9 +1577,9 @@ static int do_git_config_sequence(const struct config_options *opts,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int git_config_with_options(config_fn_t fn, void *data,
|
||||
struct git_config_source *config_source,
|
||||
const struct config_options *opts)
|
||||
int config_with_options(config_fn_t fn, void *data,
|
||||
struct git_config_source *config_source,
|
||||
const struct config_options *opts)
|
||||
{
|
||||
struct config_include_data inc = CONFIG_INCLUDE_INIT;
|
||||
|
||||
@ -1612,9 +1610,14 @@ static void git_config_raw(config_fn_t fn, void *data)
|
||||
struct config_options opts = {0};
|
||||
|
||||
opts.respect_includes = 1;
|
||||
if (git_config_with_options(fn, data, NULL, &opts) < 0)
|
||||
if (have_git_dir()) {
|
||||
opts.commondir = get_git_common_dir();
|
||||
opts.git_dir = get_git_dir();
|
||||
}
|
||||
|
||||
if (config_with_options(fn, data, NULL, &opts) < 0)
|
||||
/*
|
||||
* git_config_with_options() normally returns only
|
||||
* config_with_options() normally returns only
|
||||
* zero, as most errors are fatal, and
|
||||
* non-fatal potential errors are guarded by "if"
|
||||
* statements that are entered only when no error is
|
||||
@ -1653,11 +1656,13 @@ static void configset_iter(struct config_set *cs, config_fn_t fn, void *data)
|
||||
void read_early_config(config_fn_t cb, void *data)
|
||||
{
|
||||
struct config_options opts = {0};
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
struct strbuf commondir = STRBUF_INIT;
|
||||
struct strbuf gitdir = STRBUF_INIT;
|
||||
|
||||
opts.respect_includes = 1;
|
||||
|
||||
if (have_git_dir())
|
||||
if (have_git_dir()) {
|
||||
opts.commondir = get_git_common_dir();
|
||||
opts.git_dir = get_git_dir();
|
||||
/*
|
||||
* When setup_git_directory() was not yet asked to discover the
|
||||
@ -1667,12 +1672,15 @@ void read_early_config(config_fn_t cb, void *data)
|
||||
* notably, the current working directory is still the same after the
|
||||
* call).
|
||||
*/
|
||||
else if (discover_git_directory(&buf))
|
||||
opts.git_dir = buf.buf;
|
||||
} else if (!discover_git_directory(&commondir, &gitdir)) {
|
||||
opts.commondir = commondir.buf;
|
||||
opts.git_dir = gitdir.buf;
|
||||
}
|
||||
|
||||
git_config_with_options(cb, data, NULL, &opts);
|
||||
config_with_options(cb, data, NULL, &opts);
|
||||
|
||||
strbuf_release(&buf);
|
||||
strbuf_release(&commondir);
|
||||
strbuf_release(&gitdir);
|
||||
}
|
||||
|
||||
static void git_config_check_init(void);
|
||||
|
194
config.h
Normal file
194
config.h
Normal file
@ -0,0 +1,194 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
/* git_config_parse_key() returns these negated: */
|
||||
#define CONFIG_INVALID_KEY 1
|
||||
#define CONFIG_NO_SECTION_OR_NAME 2
|
||||
/* git_config_set_gently(), git_config_set_multivar_gently() return the above or these: */
|
||||
#define CONFIG_NO_LOCK -1
|
||||
#define CONFIG_INVALID_FILE 3
|
||||
#define CONFIG_NO_WRITE 4
|
||||
#define CONFIG_NOTHING_SET 5
|
||||
#define CONFIG_INVALID_PATTERN 6
|
||||
#define CONFIG_GENERIC_ERROR 7
|
||||
|
||||
#define CONFIG_REGEX_NONE ((void *)1)
|
||||
|
||||
struct git_config_source {
|
||||
unsigned int use_stdin:1;
|
||||
const char *file;
|
||||
const char *blob;
|
||||
};
|
||||
|
||||
enum config_origin_type {
|
||||
CONFIG_ORIGIN_BLOB,
|
||||
CONFIG_ORIGIN_FILE,
|
||||
CONFIG_ORIGIN_STDIN,
|
||||
CONFIG_ORIGIN_SUBMODULE_BLOB,
|
||||
CONFIG_ORIGIN_CMDLINE
|
||||
};
|
||||
|
||||
struct config_options {
|
||||
unsigned int respect_includes : 1;
|
||||
const char *commondir;
|
||||
const char *git_dir;
|
||||
};
|
||||
|
||||
typedef int (*config_fn_t)(const char *, const char *, void *);
|
||||
extern int git_default_config(const char *, const char *, void *);
|
||||
extern int git_config_from_file(config_fn_t fn, const char *, void *);
|
||||
extern int git_config_from_mem(config_fn_t fn, const enum config_origin_type,
|
||||
const char *name, const char *buf, size_t len, void *data);
|
||||
extern int git_config_from_blob_sha1(config_fn_t fn, const char *name,
|
||||
const unsigned char *sha1, void *data);
|
||||
extern void git_config_push_parameter(const char *text);
|
||||
extern int git_config_from_parameters(config_fn_t fn, void *data);
|
||||
extern void read_early_config(config_fn_t cb, void *data);
|
||||
extern void git_config(config_fn_t fn, void *);
|
||||
extern int config_with_options(config_fn_t fn, void *,
|
||||
struct git_config_source *config_source,
|
||||
const struct config_options *opts);
|
||||
extern int git_parse_ulong(const char *, unsigned long *);
|
||||
extern int git_parse_maybe_bool(const char *);
|
||||
extern int git_config_int(const char *, const char *);
|
||||
extern int64_t git_config_int64(const char *, const char *);
|
||||
extern unsigned long git_config_ulong(const char *, const char *);
|
||||
extern ssize_t git_config_ssize_t(const char *, const char *);
|
||||
extern int git_config_bool_or_int(const char *, const char *, int *);
|
||||
extern int git_config_bool(const char *, const char *);
|
||||
extern int git_config_maybe_bool(const char *, const char *);
|
||||
extern int git_config_string(const char **, const char *, const char *);
|
||||
extern int git_config_pathname(const char **, const char *, const char *);
|
||||
extern int git_config_set_in_file_gently(const char *, const char *, const char *);
|
||||
extern void git_config_set_in_file(const char *, const char *, const char *);
|
||||
extern int git_config_set_gently(const char *, const char *);
|
||||
extern void git_config_set(const char *, const char *);
|
||||
extern int git_config_parse_key(const char *, char **, int *);
|
||||
extern int git_config_key_is_valid(const char *key);
|
||||
extern int git_config_set_multivar_gently(const char *, const char *, const char *, int);
|
||||
extern void git_config_set_multivar(const char *, const char *, const char *, int);
|
||||
extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int);
|
||||
extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);
|
||||
extern int git_config_rename_section(const char *, const char *);
|
||||
extern int git_config_rename_section_in_file(const char *, const char *, const char *);
|
||||
extern const char *git_etc_gitconfig(void);
|
||||
extern int git_env_bool(const char *, int);
|
||||
extern unsigned long git_env_ulong(const char *, unsigned long);
|
||||
extern int git_config_system(void);
|
||||
extern int config_error_nonbool(const char *);
|
||||
#if defined(__GNUC__)
|
||||
#define config_error_nonbool(s) (config_error_nonbool(s), const_error())
|
||||
#endif
|
||||
|
||||
extern int git_config_parse_parameter(const char *, config_fn_t fn, void *data);
|
||||
|
||||
enum config_scope {
|
||||
CONFIG_SCOPE_UNKNOWN = 0,
|
||||
CONFIG_SCOPE_SYSTEM,
|
||||
CONFIG_SCOPE_GLOBAL,
|
||||
CONFIG_SCOPE_REPO,
|
||||
CONFIG_SCOPE_CMDLINE,
|
||||
};
|
||||
|
||||
extern enum config_scope current_config_scope(void);
|
||||
extern const char *current_config_origin_type(void);
|
||||
extern const char *current_config_name(void);
|
||||
|
||||
struct config_include_data {
|
||||
int depth;
|
||||
config_fn_t fn;
|
||||
void *data;
|
||||
const struct config_options *opts;
|
||||
};
|
||||
#define CONFIG_INCLUDE_INIT { 0 }
|
||||
extern int git_config_include(const char *name, const char *value, void *data);
|
||||
|
||||
/*
|
||||
* Match and parse a config key of the form:
|
||||
*
|
||||
* section.(subsection.)?key
|
||||
*
|
||||
* (i.e., what gets handed to a config_fn_t). The caller provides the section;
|
||||
* we return -1 if it does not match, 0 otherwise. The subsection and key
|
||||
* out-parameters are filled by the function (and *subsection is NULL if it is
|
||||
* missing).
|
||||
*
|
||||
* If the subsection pointer-to-pointer passed in is NULL, returns 0 only if
|
||||
* there is no subsection at all.
|
||||
*/
|
||||
extern int parse_config_key(const char *var,
|
||||
const char *section,
|
||||
const char **subsection, int *subsection_len,
|
||||
const char **key);
|
||||
|
||||
struct config_set_element {
|
||||
struct hashmap_entry ent;
|
||||
char *key;
|
||||
struct string_list value_list;
|
||||
};
|
||||
|
||||
struct configset_list_item {
|
||||
struct config_set_element *e;
|
||||
int value_index;
|
||||
};
|
||||
|
||||
/*
|
||||
* the contents of the list are ordered according to their
|
||||
* position in the config files and order of parsing the files.
|
||||
* (i.e. key-value pair at the last position of .git/config will
|
||||
* be at the last item of the list)
|
||||
*/
|
||||
struct configset_list {
|
||||
struct configset_list_item *items;
|
||||
unsigned int nr, alloc;
|
||||
};
|
||||
|
||||
struct config_set {
|
||||
struct hashmap config_hash;
|
||||
int hash_initialized;
|
||||
struct configset_list list;
|
||||
};
|
||||
|
||||
extern void git_configset_init(struct config_set *cs);
|
||||
extern int git_configset_add_file(struct config_set *cs, const char *filename);
|
||||
extern int git_configset_get_value(struct config_set *cs, const char *key, const char **value);
|
||||
extern const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key);
|
||||
extern void git_configset_clear(struct config_set *cs);
|
||||
extern int git_configset_get_string_const(struct config_set *cs, const char *key, const char **dest);
|
||||
extern int git_configset_get_string(struct config_set *cs, const char *key, char **dest);
|
||||
extern int git_configset_get_int(struct config_set *cs, const char *key, int *dest);
|
||||
extern int git_configset_get_ulong(struct config_set *cs, const char *key, unsigned long *dest);
|
||||
extern int git_configset_get_bool(struct config_set *cs, const char *key, int *dest);
|
||||
extern int git_configset_get_bool_or_int(struct config_set *cs, const char *key, int *is_bool, int *dest);
|
||||
extern int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *dest);
|
||||
extern int git_configset_get_pathname(struct config_set *cs, const char *key, const char **dest);
|
||||
|
||||
extern int git_config_get_value(const char *key, const char **value);
|
||||
extern const struct string_list *git_config_get_value_multi(const char *key);
|
||||
extern void git_config_clear(void);
|
||||
extern int git_config_get_string_const(const char *key, const char **dest);
|
||||
extern int git_config_get_string(const char *key, char **dest);
|
||||
extern int git_config_get_int(const char *key, int *dest);
|
||||
extern int git_config_get_ulong(const char *key, unsigned long *dest);
|
||||
extern int git_config_get_bool(const char *key, int *dest);
|
||||
extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest);
|
||||
extern int git_config_get_maybe_bool(const char *key, int *dest);
|
||||
extern int git_config_get_pathname(const char *key, const char **dest);
|
||||
extern int git_config_get_untracked_cache(void);
|
||||
extern int git_config_get_split_index(void);
|
||||
extern int git_config_get_max_percent_split_change(void);
|
||||
|
||||
/* This dies if the configured or default date is in the future */
|
||||
extern int git_config_get_expiry(const char *key, const char **output);
|
||||
|
||||
struct key_value_info {
|
||||
const char *filename;
|
||||
int linenr;
|
||||
enum config_origin_type origin_type;
|
||||
enum config_scope scope;
|
||||
};
|
||||
|
||||
extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3)));
|
||||
extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr);
|
||||
|
||||
#endif /* CONFIG_H */
|
@ -1,5 +1,6 @@
|
||||
#include "git-compat-util.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "pkt-line.h"
|
||||
#include "quote.h"
|
||||
#include "refs.h"
|
||||
|
32
convert.c
32
convert.c
@ -1,4 +1,6 @@
|
||||
#define NO_THE_INDEX_COMPATIBILITY_MACROS
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "attr.h"
|
||||
#include "run-command.h"
|
||||
#include "quote.h"
|
||||
@ -134,11 +136,12 @@ static const char *gather_convert_stats_ascii(const char *data, unsigned long si
|
||||
}
|
||||
}
|
||||
|
||||
const char *get_cached_convert_stats_ascii(const char *path)
|
||||
const char *get_cached_convert_stats_ascii(const struct index_state *istate,
|
||||
const char *path)
|
||||
{
|
||||
const char *ret;
|
||||
unsigned long sz;
|
||||
void *data = read_blob_data_from_cache(path, &sz);
|
||||
void *data = read_blob_data_from_index(istate, path, &sz);
|
||||
ret = gather_convert_stats_ascii(data, sz);
|
||||
free(data);
|
||||
return ret;
|
||||
@ -217,13 +220,13 @@ static void check_safe_crlf(const char *path, enum crlf_action crlf_action,
|
||||
}
|
||||
}
|
||||
|
||||
static int has_cr_in_index(const char *path)
|
||||
static int has_cr_in_index(const struct index_state *istate, const char *path)
|
||||
{
|
||||
unsigned long sz;
|
||||
void *data;
|
||||
int has_cr;
|
||||
|
||||
data = read_blob_data_from_cache(path, &sz);
|
||||
data = read_blob_data_from_index(istate, path, &sz);
|
||||
if (!data)
|
||||
return 0;
|
||||
has_cr = memchr(data, '\r', sz) != NULL;
|
||||
@ -253,7 +256,8 @@ static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats,
|
||||
|
||||
}
|
||||
|
||||
static int crlf_to_git(const char *path, const char *src, size_t len,
|
||||
static int crlf_to_git(const struct index_state *istate,
|
||||
const char *path, const char *src, size_t len,
|
||||
struct strbuf *buf,
|
||||
enum crlf_action crlf_action, enum safe_crlf checksafe)
|
||||
{
|
||||
@ -285,7 +289,8 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
|
||||
* unless we want to renormalize in a merge or
|
||||
* cherry-pick.
|
||||
*/
|
||||
if ((checksafe != SAFE_CRLF_RENORMALIZE) && has_cr_in_index(path))
|
||||
if ((checksafe != SAFE_CRLF_RENORMALIZE) &&
|
||||
has_cr_in_index(istate, path))
|
||||
convert_crlf_into_lf = 0;
|
||||
}
|
||||
if ((checksafe == SAFE_CRLF_WARN ||
|
||||
@ -1081,7 +1086,8 @@ const char *get_convert_attr_ascii(const char *path)
|
||||
return "";
|
||||
}
|
||||
|
||||
int convert_to_git(const char *path, const char *src, size_t len,
|
||||
int convert_to_git(const struct index_state *istate,
|
||||
const char *path, const char *src, size_t len,
|
||||
struct strbuf *dst, enum safe_crlf checksafe)
|
||||
{
|
||||
int ret = 0;
|
||||
@ -1097,7 +1103,7 @@ int convert_to_git(const char *path, const char *src, size_t len,
|
||||
src = dst->buf;
|
||||
len = dst->len;
|
||||
}
|
||||
ret |= crlf_to_git(path, src, len, dst, ca.crlf_action, checksafe);
|
||||
ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, checksafe);
|
||||
if (ret && dst) {
|
||||
src = dst->buf;
|
||||
len = dst->len;
|
||||
@ -1105,7 +1111,8 @@ int convert_to_git(const char *path, const char *src, size_t len,
|
||||
return ret | ident_to_git(path, src, len, dst, ca.ident);
|
||||
}
|
||||
|
||||
void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,
|
||||
void convert_to_git_filter_fd(const struct index_state *istate,
|
||||
const char *path, int fd, struct strbuf *dst,
|
||||
enum safe_crlf checksafe)
|
||||
{
|
||||
struct conv_attrs ca;
|
||||
@ -1117,7 +1124,7 @@ void convert_to_git_filter_fd(const char *path, int fd, struct strbuf *dst,
|
||||
if (!apply_filter(path, NULL, 0, fd, dst, ca.drv, CAP_CLEAN))
|
||||
die("%s: clean filter '%s' failed", path, ca.drv->name);
|
||||
|
||||
crlf_to_git(path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);
|
||||
crlf_to_git(istate, path, dst->buf, dst->len, dst, ca.crlf_action, checksafe);
|
||||
ident_to_git(path, dst->buf, dst->len, dst, ca.ident);
|
||||
}
|
||||
|
||||
@ -1160,14 +1167,15 @@ int convert_to_working_tree(const char *path, const char *src, size_t len, struc
|
||||
return convert_to_working_tree_internal(path, src, len, dst, 0);
|
||||
}
|
||||
|
||||
int renormalize_buffer(const char *path, const char *src, size_t len, struct strbuf *dst)
|
||||
int renormalize_buffer(const struct index_state *istate, const char *path,
|
||||
const char *src, size_t len, struct strbuf *dst)
|
||||
{
|
||||
int ret = convert_to_working_tree_internal(path, src, len, dst, 1);
|
||||
if (ret) {
|
||||
src = dst->buf;
|
||||
len = dst->len;
|
||||
}
|
||||
return ret | convert_to_git(path, src, len, dst, SAFE_CRLF_RENORMALIZE);
|
||||
return ret | convert_to_git(istate, path, src, len, dst, SAFE_CRLF_RENORMALIZE);
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
|
19
convert.h
19
convert.h
@ -4,6 +4,8 @@
|
||||
#ifndef CONVERT_H
|
||||
#define CONVERT_H
|
||||
|
||||
struct index_state;
|
||||
|
||||
enum safe_crlf {
|
||||
SAFE_CRLF_FALSE = 0,
|
||||
SAFE_CRLF_FAIL = 1,
|
||||
@ -33,23 +35,28 @@ enum eol {
|
||||
};
|
||||
|
||||
extern enum eol core_eol;
|
||||
extern const char *get_cached_convert_stats_ascii(const char *path);
|
||||
extern const char *get_cached_convert_stats_ascii(const struct index_state *istate,
|
||||
const char *path);
|
||||
extern const char *get_wt_convert_stats_ascii(const char *path);
|
||||
extern const char *get_convert_attr_ascii(const char *path);
|
||||
|
||||
/* returns 1 if *dst was used */
|
||||
extern int convert_to_git(const char *path, const char *src, size_t len,
|
||||
extern int convert_to_git(const struct index_state *istate,
|
||||
const char *path, const char *src, size_t len,
|
||||
struct strbuf *dst, enum safe_crlf checksafe);
|
||||
extern int convert_to_working_tree(const char *path, const char *src,
|
||||
size_t len, struct strbuf *dst);
|
||||
extern int renormalize_buffer(const char *path, const char *src, size_t len,
|
||||
extern int renormalize_buffer(const struct index_state *istate,
|
||||
const char *path, const char *src, size_t len,
|
||||
struct strbuf *dst);
|
||||
static inline int would_convert_to_git(const char *path)
|
||||
static inline int would_convert_to_git(const struct index_state *istate,
|
||||
const char *path)
|
||||
{
|
||||
return convert_to_git(path, NULL, 0, NULL, 0);
|
||||
return convert_to_git(istate, path, NULL, 0, NULL, 0);
|
||||
}
|
||||
/* Precondition: would_convert_to_git_filter_fd(path) == true */
|
||||
extern void convert_to_git_filter_fd(const char *path, int fd,
|
||||
extern void convert_to_git_filter_fd(const struct index_state *istate,
|
||||
const char *path, int fd,
|
||||
struct strbuf *dst,
|
||||
enum safe_crlf checksafe);
|
||||
extern int would_convert_to_git_filter_fd(const char *path);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "tempfile.h"
|
||||
#include "credential.h"
|
||||
#include "unix-socket.h"
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "credential.h"
|
||||
#include "string-list.h"
|
||||
#include "run-command.h"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user