summaryrefslogtreecommitdiff
path: root/remote.h
diff options
context:
space:
mode:
Diffstat (limited to 'remote.h')
-rw-r--r--remote.h117
1 files changed, 106 insertions, 11 deletions
diff --git a/remote.h b/remote.h
index eb62a47..dfd4837 100644
--- a/remote.h
+++ b/remote.h
@@ -1,11 +1,13 @@
#ifndef REMOTE_H
#define REMOTE_H
-#include "cache.h"
-#include "parse-options.h"
+#include "hash-ll.h"
#include "hashmap.h"
#include "refspec.h"
+struct option;
+struct transport_ls_refs_options;
+
/**
* The API gives access to the configuration related to remotes. It handles
* all three configuration mechanisms historically and currently used by Git,
@@ -21,6 +23,40 @@ enum {
REMOTE_BRANCHES
};
+struct rewrite {
+ const char *base;
+ size_t baselen;
+ struct counted_string *instead_of;
+ int instead_of_nr;
+ int instead_of_alloc;
+};
+
+struct rewrites {
+ struct rewrite **rewrite;
+ int rewrite_alloc;
+ int rewrite_nr;
+};
+
+struct remote_state {
+ struct remote **remotes;
+ int remotes_alloc;
+ int remotes_nr;
+ struct hashmap remotes_hash;
+
+ struct hashmap branches_hash;
+
+ struct branch *current_branch;
+ const char *pushremote_name;
+
+ struct rewrites rewrites;
+ struct rewrites rewrites_push;
+
+ int initialized;
+};
+
+void remote_state_clear(struct remote_state *remote_state);
+struct remote_state *remote_state_new(void);
+
struct remote {
struct hashmap_entry ent;
@@ -82,6 +118,7 @@ struct remote {
* and configuration.
*/
struct remote *remote_get(const char *name);
+struct remote *remote_get_early(const char *name);
struct remote *pushremote_get(const char *name);
int remote_is_configured(struct remote *remote, int in_repo);
@@ -107,12 +144,20 @@ struct ref {
struct object_id new_oid;
struct object_id old_oid_expect; /* used by expect-old */
char *symref;
+ char *tracking_ref;
unsigned int
force:1,
forced_update:1,
expect_old_sha1:1,
exact_oid:1,
- deletion:1;
+ deletion:1,
+ /* Need to check if local reflog reaches the remote tip. */
+ check_reachable:1,
+ /*
+ * Store the result of the check enabled by "check_reachable";
+ * implies the local reflog does not reach the remote tip.
+ */
+ unreachable:1;
enum {
REF_NOT_MATCHED = 0, /* initial value */
@@ -126,7 +171,7 @@ struct ref {
* should be 0, so that xcalloc'd structures get it
* by default.
*/
- enum {
+ enum fetch_head_status {
FETCH_HEAD_MERGE = -1,
FETCH_HEAD_NOT_FOR_MERGE = 0,
FETCH_HEAD_IGNORE = 1
@@ -142,6 +187,7 @@ struct ref {
REF_STATUS_REJECT_NEEDS_FORCE,
REF_STATUS_REJECT_STALE,
REF_STATUS_REJECT_SHALLOW,
+ REF_STATUS_REJECT_REMOTE_UPDATED,
REF_STATUS_UPTODATE,
REF_STATUS_REMOTE_REJECT,
REF_STATUS_EXPECTING_REPORT,
@@ -162,9 +208,7 @@ struct ref *find_ref_by_name(const struct ref *list, 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 sort_ref_list(struct ref **, int (*cmp)(const void *, const void *));
int count_refspec_match(const char *, struct ref *refs, struct ref **matched_ref);
-int ref_compare_name(const void *, const void *);
int check_ref_type(const struct ref *ref, int flags);
@@ -187,10 +231,15 @@ struct ref **get_remote_heads(struct packet_reader *reader,
/* Used for protocol v2 in order to retrieve refs from a remote */
struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
struct ref **list, int for_push,
- const struct strvec *ref_prefixes,
+ struct transport_ls_refs_options *transport_options,
const struct string_list *server_options,
int stateless_rpc);
+/* Used for protocol v2 in order to retrieve refs from a remote */
+struct bundle_list;
+int get_remote_bundle_uri(int fd_out, struct packet_reader *reader,
+ struct bundle_list *bundles, int stateless_rpc);
+
int resolve_remote_symref(struct ref *ref, struct ref *list);
/*
@@ -202,6 +251,18 @@ int resolve_remote_symref(struct ref *ref, struct ref *list);
*/
struct ref *ref_remove_duplicates(struct ref *ref_map);
+/*
+ * Check whether a name matches any negative refspec in rs. Returns 1 if the
+ * name matches at least one negative refspec, and 0 otherwise.
+ */
+int omit_name_by_refspec(const char *name, struct refspec *rs);
+
+/*
+ * Remove all entries in the input list which match any negative refspec in
+ * the refspec list.
+ */
+struct ref *apply_negative_refspecs(struct ref *ref_map, struct refspec *rs);
+
int query_refspecs(struct refspec *rs, struct refspec_item *query);
char *apply_refspecs(struct refspec *rs, const char *name);
@@ -214,7 +275,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
/*
* Given a list of the remote refs and the specification of things to
* fetch, makes a (separate) list of the refs to fetch and the local
- * refs to store into.
+ * refs to store into. Note that negative refspecs are ignored here, and
+ * should be handled separately.
*
* *tail is the pointer to the tail pointer of the list of results
* beforehand, and will be set to the tail pointer of the list of
@@ -238,6 +300,7 @@ int remote_find_tracking(struct remote *remote, struct refspec_item *refspec);
* branch_get(name) for "refs/heads/{name}", or with branch_get(NULL) for HEAD.
*/
struct branch {
+ struct hashmap_entry ent;
/* The short name of the branch. */
const char *name;
@@ -318,7 +381,8 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs,
const char **upstream_name, int for_push,
enum ahead_behind_flags abf);
int format_tracking_info(struct branch *branch, struct strbuf *sb,
- enum ahead_behind_flags abf);
+ enum ahead_behind_flags abf,
+ int show_divergence_advice);
struct ref *get_local_heads(void);
/*
@@ -337,10 +401,9 @@ struct ref *get_stale_heads(struct refspec *rs, struct ref *fetch_map);
/*
* Compare-and-swap
*/
-#define CAS_OPT_NAME "force-with-lease"
-
struct push_cas_option {
unsigned use_tracking_for_rest:1;
+ unsigned use_force_if_includes:1;
struct push_cas {
struct object_id expect;
unsigned use_tracking:1;
@@ -355,4 +418,36 @@ int parseopt_push_cas_option(const struct option *, const char *arg, int unset);
int is_empty_cas(const struct push_cas_option *);
void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
+/*
+ * The `url` argument is the URL that navigates to the submodule origin
+ * repo. When relative, this URL is relative to the superproject origin
+ * URL repo. The `up_path` argument, if specified, is the relative
+ * path that navigates from the submodule working tree to the superproject
+ * working tree. Returns the origin URL of the submodule.
+ *
+ * Return either an absolute URL or filesystem path (if the superproject
+ * origin URL is an absolute URL or filesystem path, respectively) or a
+ * relative file system path (if the superproject origin URL is a relative
+ * file system path).
+ *
+ * When the output is a relative file system path, the path is either
+ * relative to the submodule working tree, if up_path is specified, or to
+ * the superproject working tree otherwise.
+ *
+ * NEEDSWORK: This works incorrectly on the domain and protocol part.
+ * remote_url url outcome expectation
+ * http://a.com/b ../c http://a.com/c as is
+ * http://a.com/b/ ../c http://a.com/c same as previous line, but
+ * ignore trailing slash in url
+ * http://a.com/b ../../c http://c error out
+ * http://a.com/b ../../../c http:/c error out
+ * http://a.com/b ../../../../c http:c error out
+ * http://a.com/b ../../../../../c .:c error out
+ * http://a.com/b http://d.org/e http://d.org/e as is
+ * NEEDSWORK: Given how chop_last_dir() works, this function is broken
+ * when a local part has a colon in its path component, too.
+ */
+char *relative_url(const char *remote_url, const char *url,
+ const char *up_path);
+
#endif