mirror of
https://github.com/git/git.git
synced 2026-03-29 01:50:08 +01:00
Configure ignore option for submodule name instead of path
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
committed by
Johannes Schindelin
parent
f7b1e98a0d
commit
4c0ebae3b5
45
submodule.c
45
submodule.c
@@ -8,7 +8,8 @@
|
||||
#include "diffcore.h"
|
||||
#include "string-list.h"
|
||||
|
||||
struct string_list config_ignore;
|
||||
struct string_list config_name_for_path;
|
||||
struct string_list config_ignore_for_name;
|
||||
|
||||
static int add_submodule_odb(const char *path)
|
||||
{
|
||||
@@ -52,10 +53,13 @@ done:
|
||||
void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
|
||||
const char *path)
|
||||
{
|
||||
struct string_list_item *ignore_option;
|
||||
ignore_option = unsorted_string_list_lookup(&config_ignore, path);
|
||||
if (ignore_option)
|
||||
handle_ignore_submodules_arg(diffopt, ignore_option->util);
|
||||
struct string_list_item *path_option, *ignore_option;
|
||||
path_option = unsorted_string_list_lookup(&config_name_for_path, path);
|
||||
if (path_option) {
|
||||
ignore_option = unsorted_string_list_lookup(&config_ignore_for_name, path_option->util);
|
||||
if (ignore_option)
|
||||
handle_ignore_submodules_arg(diffopt, ignore_option->util);
|
||||
}
|
||||
}
|
||||
|
||||
static int submodule_config(const char *var, const char *value, void *cb)
|
||||
@@ -80,28 +84,37 @@ void gitmodules_config()
|
||||
int parse_submodule_config_option(const char *var, const char *value)
|
||||
{
|
||||
int len;
|
||||
struct string_list_item *ignore_option;
|
||||
struct strbuf path = STRBUF_INIT;
|
||||
struct string_list_item *config;
|
||||
struct strbuf submodname = STRBUF_INIT;
|
||||
|
||||
var += 10; /* Skip "submodule." */
|
||||
|
||||
len = strlen(var);
|
||||
if ((len > 7) && !strcmp(var + len - 7, ".ignore")) {
|
||||
if ((len > 5) && !strcmp(var + len - 5, ".path")) {
|
||||
strbuf_add(&submodname, var, len - 5);
|
||||
config = unsorted_string_list_lookup(&config_name_for_path, value);
|
||||
if (config)
|
||||
free(config->util);
|
||||
else
|
||||
config = string_list_append(&config_name_for_path, xstrdup(value));
|
||||
config->util = strbuf_detach(&submodname, NULL);
|
||||
strbuf_release(&submodname);
|
||||
} else if ((len > 7) && !strcmp(var + len - 7, ".ignore")) {
|
||||
if (strcmp(value, "untracked") && strcmp(value, "dirty") &&
|
||||
strcmp(value, "all") && strcmp(value, "none")) {
|
||||
warning("Invalid parameter \"%s\" for config option \"submodule.%s.ignore\"", value, var);
|
||||
return 0;
|
||||
}
|
||||
|
||||
strbuf_add(&path, var, len - 7);
|
||||
ignore_option = unsorted_string_list_lookup(&config_ignore, path.buf);
|
||||
if (ignore_option)
|
||||
free(ignore_option->util);
|
||||
strbuf_add(&submodname, var, len - 7);
|
||||
config = unsorted_string_list_lookup(&config_ignore_for_name, submodname.buf);
|
||||
if (config)
|
||||
free(config->util);
|
||||
else
|
||||
ignore_option = string_list_append(&config_ignore,
|
||||
strbuf_detach(&path, NULL));
|
||||
strbuf_release(&path);
|
||||
ignore_option->util = xstrdup(value);
|
||||
config = string_list_append(&config_ignore_for_name,
|
||||
strbuf_detach(&submodname, NULL));
|
||||
strbuf_release(&submodname);
|
||||
config->util = xstrdup(value);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user