git/submodule-config.c

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "path.h"
#include "repository.h"
#include "config.h"
#include "submodule-config.h"
#include "submodule.h"
#include "strbuf.h"
#include "object-name.h"
#include "object-store-ll.h"
#include "parse-options.h"
#include "thread-utils.h"
#include "tree-walk.h"
#include "url.h"
#include "urlmatch.h"

/*
 * submodule cache lookup structure
 * There is one shared set of 'struct submodule' entries which can be
 * looked up by their sha1 blob id of the .gitmodules file and either
 * using path or name as key.
 * for_path stores submodule entries with path as key
 * for_name stores submodule entries with name as key
 */
struct submodule_cache {};

/*
 * thin wrapper struct needed to insert 'struct submodule' entries to
 * the hashmap
 */
struct submodule_entry {};

enum lookup_type {};

static int config_path_cmp(const void *cmp_data UNUSED,
			   const struct hashmap_entry *eptr,
			   const struct hashmap_entry *entry_or_key,
			   const void *keydata UNUSED)
{}

static int config_name_cmp(const void *cmp_data UNUSED,
			   const struct hashmap_entry *eptr,
			   const struct hashmap_entry *entry_or_key,
			   const void *keydata UNUSED)
{}

static struct submodule_cache *submodule_cache_alloc(void)
{}

static void submodule_cache_init(struct submodule_cache *cache)
{}

static void free_one_config(struct submodule_entry *entry)
{}

static void submodule_cache_clear(struct submodule_cache *cache)
{}

void submodule_cache_free(struct submodule_cache *cache)
{}

static unsigned int hash_oid_string(const struct object_id *oid,
				    const char *string)
{}

static void cache_put_path(struct submodule_cache *cache,
			   struct submodule *submodule)
{}

static void cache_remove_path(struct submodule_cache *cache,
			      struct submodule *submodule)
{}

static void cache_add(struct submodule_cache *cache,
		      struct submodule *submodule)
{}

static const struct submodule *cache_lookup_path(struct submodule_cache *cache,
		const struct object_id *gitmodules_oid, const char *path)
{}

static struct submodule *cache_lookup_name(struct submodule_cache *cache,
		const struct object_id *gitmodules_oid, const char *name)
{}

int check_submodule_name(const char *name)
{}

static int starts_with_dot_slash(const char *const path)
{}

static int starts_with_dot_dot_slash(const char *const path)
{}

static int submodule_url_is_relative(const char *url)
{}

/*
 * Count directory components that a relative submodule URL should chop
 * from the remote_url it is to be resolved against.
 *
 * In other words, this counts "../" components at the start of a
 * submodule URL.
 *
 * Returns the number of directory components to chop and writes a
 * pointer to the next character of url after all leading "./" and
 * "../" components to out.
 */
static int count_leading_dotdots(const char *url, const char **out)
{}
/*
 * Check whether a transport is implemented by git-remote-curl.
 *
 * If it is, returns 1 and writes the URL that would be passed to
 * git-remote-curl to the "out" parameter.
 *
 * Otherwise, returns 0 and leaves "out" untouched.
 *
 * Examples:
 *   http::https://example.com/repo.git -> 1, https://example.com/repo.git
 *   https://example.com/repo.git -> 1, https://example.com/repo.git
 *   git://example.com/repo.git -> 0
 *
 * This is for use in checking for previously exploitable bugs that
 * required a submodule URL to be passed to git-remote-curl.
 */
static int url_to_curl_url(const char *url, const char **out)
{}

int check_submodule_url(const char *url)
{}

static int name_and_item_from_var(const char *var, struct strbuf *name,
				  struct strbuf *item)
{}

static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
		const struct object_id *gitmodules_oid, const char *name)
{}

static int parse_fetch_recurse(const char *opt, const char *arg,
			       int die_on_error)
{}

int parse_submodule_fetchjobs(const char *var, const char *value,
			      const struct key_value_info *kvi)
{}

int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
{}

int option_fetch_parse_recurse_submodules(const struct option *opt,
					  const char *arg, int unset)
{}

static int parse_update_recurse(const char *opt, const char *arg,
				int die_on_error)
{}

int parse_update_recurse_submodules_arg(const char *opt, const char *arg)
{}

static int parse_push_recurse(const char *opt, const char *arg,
			       int die_on_error)
{}

int parse_push_recurse_submodules_arg(const char *opt, const char *arg)
{}

static void warn_multiple_config(const struct object_id *treeish_name,
				 const char *name, const char *option)
{}

static void warn_command_line_option(const char *var, const char *value)
{}

struct parse_config_parameter {};

/*
 * Parse a config item from .gitmodules.
 *
 * This does not handle submodule-related configuration from the main
 * config store (.git/config, etc).  Callers are responsible for
 * checking for overrides in the main config store when appropriate.
 */
static int parse_config(const char *var, const char *value,
			const struct config_context *ctx UNUSED, void *data)
{}

static int gitmodule_oid_from_commit(const struct object_id *treeish_name,
				     struct object_id *gitmodules_oid,
				     struct strbuf *rev)
{}

/* This does a lookup of a submodule configuration by name or by path
 * (key) with on-demand reading of the appropriate .gitmodules from
 * revisions.
 */
static const struct submodule *config_from(struct submodule_cache *cache,
		const struct object_id *treeish_name, const char *key,
		enum lookup_type lookup_type)
{}

static void submodule_cache_check_init(struct repository *repo)
{}

/*
 * Note: This function is private for a reason, the '.gitmodules' file should
 * not be used as a mechanism to retrieve arbitrary configuration stored in
 * the repository.
 *
 * Runs the provided config function on the '.gitmodules' file found in the
 * working directory.
 */
static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void *data)
{}

static int gitmodules_cb(const char *var, const char *value,
			 const struct config_context *ctx, void *data)
{}

void repo_read_gitmodules(struct repository *repo, int skip_if_read)
{}

void gitmodules_config_oid(const struct object_id *commit_oid)
{}

const struct submodule *submodule_from_name(struct repository *r,
					    const struct object_id *treeish_name,
		const char *name)
{}

const struct submodule *submodule_from_path(struct repository *r,
					    const struct object_id *treeish_name,
		const char *path)
{}

/**
 * Used internally by submodules_of_tree(). Recurses into 'treeish_name'
 * and appends submodule entries to 'out'. The submodule_cache expects
 * a root-level treeish_name and paths, so keep track of these values
 * with 'root_tree' and 'prefix'.
 */
static void traverse_tree_submodules(struct repository *r,
				     const struct object_id *root_tree,
				     char *prefix,
				     const struct object_id *treeish_name,
				     struct submodule_entry_list *out)
{}

void submodules_of_tree(struct repository *r,
			const struct object_id *treeish_name,
			struct submodule_entry_list *out)
{}

void submodule_entry_list_release(struct submodule_entry_list *list)
{}

void submodule_free(struct repository *r)
{}

static int config_print_callback(const char *var, const char *value,
				 const struct config_context *ctx UNUSED,
				 void *cb_data)
{}

int print_config_from_gitmodules(struct repository *repo, const char *key)
{}

int config_set_in_gitmodules_file_gently(const char *key, const char *value)
{}

struct fetch_config {};

static int gitmodules_fetch_config(const char *var, const char *value,
				   const struct config_context *ctx,
				   void *cb)
{}

void fetch_config_from_gitmodules(int *max_children, int *recurse_submodules)
{}

static int gitmodules_update_clone_config(const char *var, const char *value,
					  const struct config_context *ctx,
					  void *cb)
{}

void update_clone_config_from_gitmodules(int *max_jobs)
{}