git/remote.c

#define USE_THE_REPOSITORY_VARIABLE

#include "git-compat-util.h"
#include "abspath.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "remote.h"
#include "urlmatch.h"
#include "refs.h"
#include "refspec.h"
#include "object-name.h"
#include "object-store-ll.h"
#include "path.h"
#include "commit.h"
#include "diff.h"
#include "revision.h"
#include "dir.h"
#include "setup.h"
#include "string-list.h"
#include "strvec.h"
#include "commit-reach.h"
#include "advice.h"
#include "connect.h"
#include "parse-options.h"
#include "transport.h"

enum map_direction {};

struct counted_string {};

static int valid_remote(const struct remote *remote)
{}

static char *alias_url(const char *url, struct rewrites *r)
{}

static void add_url(struct remote *remote, const char *url)
{}

static void add_pushurl(struct remote *remote, const char *pushurl)
{}

static void add_pushurl_alias(struct remote_state *remote_state,
			      struct remote *remote, const char *url)
{}

static void add_url_alias(struct remote_state *remote_state,
			  struct remote *remote, const char *url)
{}

struct remotes_hash_key {};

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

static struct remote *make_remote(struct remote_state *remote_state,
				  const char *name, int len)
{}

static void remote_clear(struct remote *remote)
{}

static void add_merge(struct branch *branch, const char *name)
{}

struct branches_hash_key {};

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

static struct branch *find_branch(struct remote_state *remote_state,
				  const char *name, size_t len)
{}

static void die_on_missing_branch(struct repository *repo,
				  struct branch *branch)
{}

static struct branch *make_branch(struct remote_state *remote_state,
				  const char *name, size_t len)
{}

static void branch_release(struct branch *branch)
{}

static struct rewrite *make_rewrite(struct rewrites *r,
				    const char *base, size_t len)
{}

static void rewrites_release(struct rewrites *r)
{}

static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
{}

static const char *skip_spaces(const char *s)
{}

static void read_remotes_file(struct remote_state *remote_state,
			      struct remote *remote)
{}

static void read_branches_file(struct remote_state *remote_state,
			       struct remote *remote)
{}

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

static void alias_all_urls(struct remote_state *remote_state)
{}

static void read_config(struct repository *repo, int early)
{}

static int valid_remote_nick(const char *name)
{}

static const char *remotes_remote_for_branch(struct remote_state *remote_state,
					     struct branch *branch,
					     int *explicit)
{}

const char *remote_for_branch(struct branch *branch, int *explicit)
{}

static const char *
remotes_pushremote_for_branch(struct remote_state *remote_state,
			      struct branch *branch, int *explicit)
{}

const char *pushremote_for_branch(struct branch *branch, int *explicit)
{}

static struct remote *remotes_remote_get(struct remote_state *remote_state,
					 const char *name);

char *remote_ref_for_branch(struct branch *branch, int for_push)
{}

static void validate_remote_url(struct remote *remote)
{}

static struct remote *
remotes_remote_get_1(struct remote_state *remote_state, const char *name,
		     const char *(*get_default)(struct remote_state *,
						struct branch *, int *))
{}

static inline struct remote *
remotes_remote_get(struct remote_state *remote_state, const char *name)
{}

struct remote *remote_get(const char *name)
{}

struct remote *remote_get_early(const char *name)
{}

static inline struct remote *
remotes_pushremote_get(struct remote_state *remote_state, const char *name)
{}

struct remote *pushremote_get(const char *name)
{}

int remote_is_configured(struct remote *remote, int in_repo)
{}

int for_each_remote(each_remote_fn fn, void *priv)
{}

static void handle_duplicate(struct ref *ref1, struct ref *ref2)
{}

struct ref *ref_remove_duplicates(struct ref *ref_map)
{}

int remote_has_url(struct remote *remote, const char *url)
{}

struct strvec *push_url_of_remote(struct remote *remote)
{}

void ref_push_report_free(struct ref_push_report *report)
{}

static int match_name_with_pattern(const char *key, const char *name,
				   const char *value, char **result)
{}

static int refspec_match(const struct refspec_item *refspec,
			 const char *name)
{}

int omit_name_by_refspec(const char *name, struct refspec *rs)
{}

struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs)
{}

static int query_matches_negative_refspec(struct refspec *rs, struct refspec_item *query)
{}

static void query_refspecs_multiple(struct refspec *rs,
				    struct refspec_item *query,
				    struct string_list *results)
{}

int query_refspecs(struct refspec *rs, struct refspec_item *query)
{}

char *apply_refspecs(struct refspec *rs, const char *name)
{}

int remote_find_tracking(struct remote *remote, struct refspec_item *refspec)
{}

static struct ref *alloc_ref_with_prefix(const char *prefix, size_t prefixlen,
		const char *name)
{}

struct ref *alloc_ref(const char *name)
{}

struct ref *copy_ref(const struct ref *ref)
{}

struct ref *copy_ref_list(const struct ref *ref)
{}

void free_one_ref(struct ref *ref)
{}

void free_refs(struct ref *ref)
{}

int count_refspec_match(const char *pattern,
			struct ref *refs,
			struct ref **matched_ref)
{}

static void tail_link_ref(struct ref *ref, struct ref ***tail)
{}

static struct ref *alloc_delete_ref(void)
{}

static int try_explicit_object_name(const char *name,
				    struct ref **match)
{}

static struct ref *make_linked_ref(const char *name, struct ref ***tail)
{}

static char *guess_ref(const char *name, struct ref *peer)
{}

static int match_explicit_lhs(struct ref *src,
			      struct refspec_item *rs,
			      struct ref **match,
			      int *allocated_match)
{}

static void show_push_unqualified_ref_name_error(const char *dst_value,
						 const char *matched_src_name)
{}

static int match_explicit(struct ref *src, struct ref *dst,
			  struct ref ***dst_tail,
			  struct refspec_item *rs)
{}

static int match_explicit_refs(struct ref *src, struct ref *dst,
			       struct ref ***dst_tail, struct refspec *rs)
{}

static char *get_ref_match(const struct refspec *rs, const struct ref *ref,
			   int send_mirror, int direction,
			   const struct refspec_item **ret_pat)
{}

static struct ref **tail_ref(struct ref **head)
{}

struct tips {};

static void add_to_tips(struct tips *tips, const struct object_id *oid)
{}

static void add_missing_tags(struct ref *src, struct ref **dst, struct ref ***dst_tail)
{}

struct ref *find_ref_by_name(const struct ref *list, const char *name)
{}

static void prepare_ref_index(struct string_list *ref_index, struct ref *ref)
{}

/*
 * Given only the set of local refs, sanity-check the set of push
 * refspecs. We can't catch all errors that match_push_refs would,
 * but we can catch some errors early before even talking to the
 * remote side.
 */
int check_push_refs(struct ref *src, struct refspec *rs)
{}

/*
 * Given the set of refs the local repository has, the set of refs the
 * remote repository has, and the refspec used for push, determine
 * what remote refs we will update and with what value by setting
 * peer_ref (which object is being pushed) and force (if the push is
 * forced) in elements of "dst". The function may add new elements to
 * dst (e.g. pushing to a new branch, done in match_explicit_refs).
 */
int match_push_refs(struct ref *src, struct ref **dst,
		    struct refspec *rs, int flags)
{}

void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
			     int force_update)
{}

static void set_merge(struct remote_state *remote_state, struct branch *ret)
{}

struct branch *branch_get(const char *name)
{}

int branch_has_merge_config(struct branch *branch)
{}

int branch_merge_matches(struct branch *branch,
		                 int i,
		                 const char *refname)
{}

__attribute__((format (printf,2,3)))
static const char *error_buf(struct strbuf *err, const char *fmt, ...)
{}

const char *branch_get_upstream(struct branch *branch, struct strbuf *err)
{}

static const char *tracking_for_push_dest(struct remote *remote,
					  const char *refname,
					  struct strbuf *err)
{}

static const char *branch_get_push_1(struct remote_state *remote_state,
				     struct branch *branch, struct strbuf *err)
{}

const char *branch_get_push(struct branch *branch, struct strbuf *err)
{}

static int ignore_symref_update(const char *refname, struct strbuf *scratch)
{}

/*
 * Create and return a list of (struct ref) consisting of copies of
 * each remote_ref that matches refspec.  refspec must be a pattern.
 * Fill in the copies' peer_ref to describe the local tracking refs to
 * which they map.  Omit any references that would map to an existing
 * local symbolic ref.
 */
static struct ref *get_expanded_map(const struct ref *remote_refs,
				    const struct refspec_item *refspec)
{}

static const struct ref *find_ref_by_name_abbrev(const struct ref *refs, const char *name)
{}

struct ref *get_remote_ref(const struct ref *remote_refs, const char *name)
{}

static struct ref *get_local_ref(const char *name)
{}

int get_fetch_map(const struct ref *remote_refs,
		  const struct refspec_item *refspec,
		  struct ref ***tail,
		  int missing_ok)
{}

int resolve_remote_symref(struct ref *ref, struct ref *list)
{}

/*
 * Compute the commit ahead/behind values for the pair branch_name, base.
 *
 * If abf is AHEAD_BEHIND_FULL, compute the full ahead/behind and return the
 * counts in *num_ours and *num_theirs.  If abf is AHEAD_BEHIND_QUICK, skip
 * the (potentially expensive) a/b computation (*num_ours and *num_theirs are
 * set to zero).
 *
 * Returns -1 if num_ours and num_theirs could not be filled in (e.g., ref
 * does not exist).  Returns 0 if the commits are identical.  Returns 1 if
 * commits are different.
 */

static int stat_branch_pair(const char *branch_name, const char *base,
			     int *num_ours, int *num_theirs,
			     enum ahead_behind_flags abf)
{}

/*
 * Lookup the tracking branch for the given branch and if present, optionally
 * compute the commit ahead/behind values for the pair.
 *
 * If for_push is true, the tracking branch refers to the push branch,
 * otherwise it refers to the upstream branch.
 *
 * The name of the tracking branch (or NULL if it is not defined) is
 * returned via *tracking_name, if it is not itself NULL.
 *
 * If abf is AHEAD_BEHIND_FULL, compute the full ahead/behind and return the
 * counts in *num_ours and *num_theirs.  If abf is AHEAD_BEHIND_QUICK, skip
 * the (potentially expensive) a/b computation (*num_ours and *num_theirs are
 * set to zero).
 *
 * Returns -1 if num_ours and num_theirs could not be filled in (e.g., no
 * upstream defined, or ref does not exist).  Returns 0 if the commits are
 * identical.  Returns 1 if commits are different.
 */
int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
		       const char **tracking_name, int for_push,
		       enum ahead_behind_flags abf)
{}

/*
 * Return true when there is anything to report, otherwise false.
 */
int format_tracking_info(struct branch *branch, struct strbuf *sb,
			 enum ahead_behind_flags abf,
			 int show_divergence_advice)
{}

static int one_local_ref(const char *refname, const char *referent UNUSED, const struct object_id *oid,
			 int flag UNUSED,
			 void *cb_data)
{}

struct ref *get_local_heads(void)
{}

struct ref *guess_remote_head(const struct ref *head,
			      const struct ref *refs,
			      int all)
{}

struct stale_heads_info {};

static int get_stale_heads_cb(const char *refname, const char *referent UNUSED, const struct object_id *oid,
			      int flags, void *cb_data)
{}

struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map)
{}

/*
 * Compare-and-swap
 */
void clear_cas_option(struct push_cas_option *cas)
{}

static struct push_cas *add_cas_entry(struct push_cas_option *cas,
				      const char *refname,
				      size_t refnamelen)
{}

static int parse_push_cas_option(struct push_cas_option *cas, const char *arg, int unset)
{}

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

int is_empty_cas(const struct push_cas_option *cas)
{}

/*
 * Look at remote.fetch refspec and see if we have a remote
 * tracking branch for the refname there. Fill the name of
 * the remote-tracking branch in *dst_refname, and the name
 * of the commit object at its tip in oid[].
 * If we cannot do so, return negative to signal an error.
 */
static int remote_tracking(struct remote *remote, const char *refname,
			   struct object_id *oid, char **dst_refname)
{}

/*
 * The struct "reflog_commit_array" and related helper functions
 * are used for collecting commits into an array during reflog
 * traversals in "check_and_collect_until()".
 */
struct reflog_commit_array {};

#define REFLOG_COMMIT_ARRAY_INIT

/* Append a commit to the array. */
static void append_commit(struct reflog_commit_array *arr,
			  struct commit *commit)
{}

/* Free and reset the array. */
static void free_commit_array(struct reflog_commit_array *arr)
{}

struct check_and_collect_until_cb_data {};

/* Get the timestamp of the latest entry. */
static int peek_reflog(struct object_id *o_oid UNUSED,
		       struct object_id *n_oid UNUSED,
		       const char *ident UNUSED,
		       timestamp_t timestamp, int tz UNUSED,
		       const char *message UNUSED, void *cb_data)
{}

static int check_and_collect_until(struct object_id *o_oid UNUSED,
				   struct object_id *n_oid,
				   const char *ident UNUSED,
				   timestamp_t timestamp, int tz UNUSED,
				   const char *message UNUSED, void *cb_data)
{}

#define MERGE_BASES_BATCH_SIZE

/*
 * Iterate through the reflog of the local ref to check if there is an entry
 * for the given remote-tracking ref; runs until the timestamp of an entry is
 * older than latest timestamp of remote-tracking ref's reflog. Any commits
 * are that seen along the way are collected into an array to check if the
 * remote-tracking ref is reachable from any of them.
 */
static int is_reachable_in_reflog(const char *local, const struct ref *remote)
{}

/*
 * Check for reachability of a remote-tracking
 * ref in the reflog entries of its local ref.
 */
static void check_if_includes_upstream(struct ref *remote)
{}

static void apply_cas(struct push_cas_option *cas,
		      struct remote *remote,
		      struct ref *ref)
{}

void apply_push_cas(struct push_cas_option *cas,
		    struct remote *remote,
		    struct ref *remote_refs)
{}

struct remote_state *remote_state_new(void)
{}

void remote_state_clear(struct remote_state *remote_state)
{}

/*
 * Returns 1 if it was the last chop before ':'.
 */
static int chop_last_dir(char **remoteurl, int is_relative)
{}

char *relative_url(const char *remote_url, const char *url,
		   const char *up_path)
{}