From 9b288516ee63cea91dd9d102edcdf112caea4c75 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 10 Sep 2007 23:03:04 -0400 Subject: Push code for transport library This moves the code to call push backends into a library that can be extended to make matching fetch and push decisions based on the URL it gets, and which could be changed to have built-in implementations instead of calling external programs. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 transport.h (limited to 'transport.h') diff --git a/transport.h b/transport.h new file mode 100644 index 000000000..5c2eb959b --- /dev/null +++ b/transport.h @@ -0,0 +1,61 @@ +#ifndef TRANSPORT_H +#define TRANSPORT_H + +#include "cache.h" +#include "remote.h" + +struct transport { + unsigned verbose : 1; + unsigned fetch : 1; + struct remote *remote; + const char *url; + + void *data; + + struct ref *remote_refs; + + const struct transport_ops *ops; +}; + +#define TRANSPORT_PUSH_ALL 1 +#define TRANSPORT_PUSH_FORCE 2 + +struct transport_ops { + /** + * Returns 0 if successful, positive if the option is not + * recognized or is inapplicable, and negative if the option + * is applicable but the value is invalid. + **/ + int (*set_option)(struct transport *connection, const char *name, + const char *value); + + int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); + + int (*disconnect)(struct transport *connection); +}; + +/* Returns a transport suitable for the url */ +struct transport *transport_get(struct remote *remote, const char *url, + int fetch); + +/* Transport options which apply to git:// and scp-style URLs */ + +/* The program to use on the remote side to receive a pack */ +#define TRANS_OPT_RECEIVEPACK "receivepack" + +/* Transfer the data as a thin pack if not null */ +#define TRANS_OPT_THIN "thin" + +/** + * Returns 0 if the option was used, non-zero otherwise. Prints a + * message to stderr if the option is not used. + **/ +int transport_set_option(struct transport *transport, const char *name, + const char *value); + +int transport_push(struct transport *connection, + int refspec_nr, const char **refspec, int flags); + +int transport_disconnect(struct transport *transport); + +#endif -- cgit v1.2.1 From c29727d5241be0fee2265fbbe65d1b275b01dc1c Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 10 Sep 2007 23:03:11 -0400 Subject: Add fetch methods to transport library. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 5c2eb959b..5b0a6b065 100644 --- a/transport.h +++ b/transport.h @@ -29,6 +29,11 @@ struct transport_ops { int (*set_option)(struct transport *connection, const char *name, const char *value); + struct ref *(*get_refs_list)(const struct transport *transport); + int (*fetch_refs)(const struct transport *transport, + int nr_refs, char **refs); + int (*fetch_objs)(const struct transport *transport, + int nr_objs, char **objs); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); int (*disconnect)(struct transport *connection); @@ -40,12 +45,24 @@ struct transport *transport_get(struct remote *remote, const char *url, /* Transport options which apply to git:// and scp-style URLs */ +/* The program to use on the remote side to send a pack */ +#define TRANS_OPT_UPLOADPACK "uploadpack" + /* The program to use on the remote side to receive a pack */ #define TRANS_OPT_RECEIVEPACK "receivepack" /* Transfer the data as a thin pack if not null */ #define TRANS_OPT_THIN "thin" +/* Keep the pack that was transferred if not null */ +#define TRANS_OPT_KEEP "keep" + +/* Unpack the objects if fewer than this number of objects are fetched */ +#define TRANS_OPT_UNPACKLIMIT "unpacklimit" + +/* Limit the depth of the fetch if not null */ +#define TRANS_OPT_DEPTH "depth" + /** * Returns 0 if the option was used, non-zero otherwise. Prints a * message to stderr if the option is not used. @@ -56,6 +73,10 @@ int transport_set_option(struct transport *transport, const char *name, int transport_push(struct transport *connection, int refspec_nr, const char **refspec, int flags); +struct ref *transport_get_remote_refs(struct transport *transport); + +int transport_fetch_refs(struct transport *transport, struct ref *refs); + int transport_disconnect(struct transport *transport); #endif -- cgit v1.2.1 From 425b1393139d99d89c7a95906686d9b041f2ee3d Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 14 Sep 2007 03:31:21 -0400 Subject: Simplify fetch transport API to just one function Commit walkers need to know the SHA-1 name of any objects they have been asked to fetch while the native pack transport only wants to know the names of the remote refs as the remote side must do the name->SHA-1 translation. Since we only have three fetch implementations and one of them (bundle) doesn't even need the name information we can reduce the code required to perform a fetch by having just one function and passing of the filtered list of refs to be fetched. Each transport can then obtain the information it needs from that ref array to construct its own internal operation state. Signed-off-by: Shawn O. Pearce Conflicts: transport.c Signed-off-by: Junio C Hamano --- transport.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 5b0a6b065..b354a8fd1 100644 --- a/transport.h +++ b/transport.h @@ -30,10 +30,7 @@ struct transport_ops { const char *value); struct ref *(*get_refs_list)(const struct transport *transport); - int (*fetch_refs)(const struct transport *transport, - int nr_refs, char **refs); - int (*fetch_objs)(const struct transport *transport, - int nr_objs, char **objs); + int (*fetch)(const struct transport *transport, int refs_nr, struct ref **refs); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); int (*disconnect)(struct transport *connection); -- cgit v1.2.1 From 1788c39cd0742439b9bedc28bc10bc4d105b6c0f Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 14 Sep 2007 03:31:23 -0400 Subject: Remove pack.keep after ref updates in git-fetch If we are using a native packfile to perform a git-fetch invocation and the received packfile contained more than the configured limits of fetch.unpackLimit/transfer.unpackLimit then index-pack will output a single line saying "keep\t$sha1\n" to stdout. This line needs to be captured and retained so we can delete the corresponding .keep file ("$GIT_DIR/objects/pack/pack-$sha1.keep") once all refs have been safely updated. This trick has long been in use with git-fetch.sh and its lower level helper git-fetch--tool as a way to allow index-pack to save the new packfile before the refs have been updated and yet avoid a race with any concurrently running git-repack process. It was unfortunately lost when git-fetch.sh was converted to pure C and fetch--tool was no longer being invoked. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- transport.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index b354a8fd1..f2bbdf778 100644 --- a/transport.h +++ b/transport.h @@ -15,6 +15,7 @@ struct transport { struct ref *remote_refs; const struct transport_ops *ops; + char *pack_lockfile; }; #define TRANSPORT_PUSH_ALL 1 @@ -30,7 +31,7 @@ struct transport_ops { const char *value); struct ref *(*get_refs_list)(const struct transport *transport); - int (*fetch)(const struct transport *transport, int refs_nr, struct ref **refs); + int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); int (*disconnect)(struct transport *connection); @@ -73,7 +74,7 @@ int transport_push(struct transport *connection, struct ref *transport_get_remote_refs(struct transport *transport); int transport_fetch_refs(struct transport *transport, struct ref *refs); - +void transport_unlock_pack(struct transport *transport); int transport_disconnect(struct transport *transport); #endif -- cgit v1.2.1 From e5f4e214636f9c9bd36c2897634108d5ad5587a1 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 15 Sep 2007 03:23:14 -0400 Subject: Remove unnecessary 'fetch' argument from transport_get API We don't actually need to know at the time of transport_get if the caller wants to fetch, push, or do both on the returned object. It is easier to just delay the initialization of the HTTP walker until we know we will need it by providing a CURL specific fetch function in the curl_transport that makes sure the walker instance is initialized before use. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- transport.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index f2bbdf778..6a95d6605 100644 --- a/transport.h +++ b/transport.h @@ -6,7 +6,6 @@ struct transport { unsigned verbose : 1; - unsigned fetch : 1; struct remote *remote; const char *url; @@ -38,8 +37,7 @@ struct transport_ops { }; /* Returns a transport suitable for the url */ -struct transport *transport_get(struct remote *remote, const char *url, - int fetch); +struct transport *transport_get(struct remote *, const char *); /* Transport options which apply to git:// and scp-style URLs */ -- cgit v1.2.1 From 824d5776c3f275c644c71b8c7e254bd2d7b08071 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 19 Sep 2007 00:49:31 -0400 Subject: Refactor struct transport_ops inlined into struct transport Aside from reducing the code by 20 lines this refactoring removes a level of indirection when trying to access the operations of a given transport "instance", making the code clearer and easier to follow. It also has the nice effect of giving us the benefits of C99 style struct initialization (namely ".fetch = X") without requiring that level of language support from our compiler. We don't need to worry about new operation methods being added as they will now be NULL'd out automatically by the xcalloc() we use to create the new struct transport we supply to the caller. This pattern already exists in struct walker, so we already have a precedent for it in Git. We also don't really need to worry about any sort of performance decreases that may occur as a result of filling out 4-8 op pointers when we make a "struct transport". The extra few CPU cycles this requires over filling in the "struct transport_ops" is killed by the time it will take Git to actually *use* one of those functions, as most transport operations are going over the wire or will be copying object data locally between two directories. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- transport.h | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 6a95d6605..3e332ff53 100644 --- a/transport.h +++ b/transport.h @@ -5,22 +5,11 @@ #include "remote.h" struct transport { - unsigned verbose : 1; struct remote *remote; const char *url; - void *data; - struct ref *remote_refs; - const struct transport_ops *ops; - char *pack_lockfile; -}; - -#define TRANSPORT_PUSH_ALL 1 -#define TRANSPORT_PUSH_FORCE 2 - -struct transport_ops { /** * Returns 0 if successful, positive if the option is not * recognized or is inapplicable, and negative if the option @@ -34,8 +23,13 @@ struct transport_ops { int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); int (*disconnect)(struct transport *connection); + char *pack_lockfile; + unsigned verbose : 1; }; +#define TRANSPORT_PUSH_ALL 1 +#define TRANSPORT_PUSH_FORCE 2 + /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); -- cgit v1.2.1 From 50ab5fd3fc16fbe01170059977533fa2c7c4d448 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Wed, 19 Sep 2007 00:49:39 -0400 Subject: Ensure builtin-fetch honors {fetch,transfer}.unpackLimit The only way to configure the unpacking limit is currently through the .git/config (or ~/.gitconfig) mechanism as we have no existing command line option interface to control this threshold on a per invocation basis. This was intentional by design as the storage policy of the repository should be a repository-wide decision and should not be subject to variations made on individual command executions. Earlier builtin-fetch was bypassing the unpacking limit chosen by the user through the configuration file as it did not reread the configuration options through fetch_pack_config if we called the internal fetch_pack() API directly. We now ensure we always run the config file through fetch_pack_config at least once in this process, thereby setting our unpackLimit properly. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- transport.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 3e332ff53..6e318e4e8 100644 --- a/transport.h +++ b/transport.h @@ -47,9 +47,6 @@ struct transport *transport_get(struct remote *, const char *); /* Keep the pack that was transferred if not null */ #define TRANS_OPT_KEEP "keep" -/* Unpack the objects if fewer than this number of objects are fetched */ -#define TRANS_OPT_UNPACKLIMIT "unpacklimit" - /* Limit the depth of the fetch if not null */ #define TRANS_OPT_DEPTH "depth" -- cgit v1.2.1 From 2b5a06edca8f7237aad6464b349b79772024d2a2 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Tue, 2 Oct 2007 22:49:15 -0400 Subject: Restore default verbosity for http fetches. This adds a verbosity level below 0 for suppressing default messages with --quiet, and makes the default for http be verbose instead of quiet. This matches the behavior of the shell script version of git-fetch. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 6e318e4e8..4bb51d7b7 100644 --- a/transport.h +++ b/transport.h @@ -24,7 +24,7 @@ struct transport { int (*disconnect)(struct transport *connection); char *pack_lockfile; - unsigned verbose : 1; + signed verbose : 2; }; #define TRANSPORT_PUSH_ALL 1 -- cgit v1.2.1 From 4577370e9bfeca8652880b99b8499f76d18865ba Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Mon, 29 Oct 2007 21:05:40 -0400 Subject: Miscellaneous const changes and utilities The list of remote refs in struct transport should be const, because builtin-fetch will get confused if it changes. The url in git_connect should be const (and work on a copy) instead of requiring the caller to copy it. match_refs doesn't modify the refspecs it gets. get_fetch_map and get_remote_ref don't change the list they get. Allow transport get_refs_list methods to modify the struct transport. Add a function to copy a list of refs, when a function needs a mutable copy of a const list. Add a function to check the type of a ref, as per the code in connect.c Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index df12ea742..d27f5629d 100644 --- a/transport.h +++ b/transport.h @@ -8,7 +8,7 @@ struct transport { struct remote *remote; const char *url; void *data; - struct ref *remote_refs; + const struct ref *remote_refs; /** * Returns 0 if successful, positive if the option is not @@ -18,7 +18,7 @@ struct transport { int (*set_option)(struct transport *connection, const char *name, const char *value); - struct ref *(*get_refs_list)(const struct transport *transport); + struct ref *(*get_refs_list)(struct transport *transport); int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); @@ -61,7 +61,7 @@ int transport_set_option(struct transport *transport, const char *name, int transport_push(struct transport *connection, int refspec_nr, const char **refspec, int flags); -struct ref *transport_get_remote_refs(struct transport *transport); +const struct ref *transport_get_remote_refs(struct transport *transport); int transport_fetch_refs(struct transport *transport, struct ref *refs); void transport_unlock_pack(struct transport *transport); -- cgit v1.2.1 From 94c89ba662e964c544fdb171dc8dd33f95b97942 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Fri, 9 Nov 2007 23:32:25 +0000 Subject: git-push: plumb in --mirror mode Plumb in the --mirror mode for git-push. Signed-off-by: Andy Whitcroft Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index d27f5629d..7f337d2f0 100644 --- a/transport.h +++ b/transport.h @@ -30,6 +30,7 @@ struct transport { #define TRANSPORT_PUSH_ALL 1 #define TRANSPORT_PUSH_FORCE 2 #define TRANSPORT_PUSH_DRY_RUN 4 +#define TRANSPORT_PUSH_MIRROR 8 /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); -- cgit v1.2.1 From 1b2486d73789aaed0671e8d5cc60f5624d8e7ce5 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sun, 11 Nov 2007 15:01:44 +0100 Subject: push: teach push to pass --verbose option to transport layer A --verbose option to push should also be passed to the transport layer, i.e. git-send-pack, git-http-push. git push is modified to do so. Signed-off-by: Steffen Prohaska Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index df12ea742..2f80ab4b0 100644 --- a/transport.h +++ b/transport.h @@ -30,6 +30,7 @@ struct transport { #define TRANSPORT_PUSH_ALL 1 #define TRANSPORT_PUSH_FORCE 2 #define TRANSPORT_PUSH_DRY_RUN 4 +#define TRANSPORT_PUSH_VERBOSE 8 /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); -- cgit v1.2.1 From 41fa7d2eaeace0c5c23fc75a3d5cc9efbad467a5 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 3 Mar 2008 22:27:40 -0500 Subject: Teach git-fetch to exploit server side automatic tag following If the remote peer upload-pack process supports the include-tag protocol extension then we can avoid running a second fetch cycle on the client side by letting the server send us the annotated tags along with the objects it is packing for us. In the following graph we can now fetch both "tag1" and "tag2" on the same connection that we fetched "master" from the remote when we only have L available on the local side: T - tag1 S - tag2 / / L - o ------ o ------ B \ \ \ \ origin/master master The objects for "tag1" are implicitly downloaded without our direct knowledge. The existing "quickfetch" optimization within git-fetch discovers that tag1 is complete after the first connection and does not open a second connection. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- transport.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 6fb4526cd..8abfc0ae6 100644 --- a/transport.h +++ b/transport.h @@ -53,6 +53,9 @@ struct transport *transport_get(struct remote *, const char *); /* Limit the depth of the fetch if not null */ #define TRANS_OPT_DEPTH "depth" +/* Aggressively fetch annotated tags if possible */ +#define TRANS_OPT_FOLLOWTAGS "followtags" + /** * Returns 0 if the option was used, non-zero otherwise. Prints a * message to stderr if the option is not used. -- cgit v1.2.1 From 2d5c298f91b4b76a8b51b9b66283ef5a872736a0 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Thu, 17 Apr 2008 19:32:22 -0400 Subject: Mark the list of refs to fetch as const Fetching the objects doesn't actually modify the list in any of the code paths, so this will allow code that fetches the entire (const) list of available refs to just pass the list in directly. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 8abfc0ae6..d0b52053f 100644 --- a/transport.h +++ b/transport.h @@ -19,7 +19,7 @@ struct transport { const char *value); struct ref *(*get_refs_list)(struct transport *transport); - int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs); + int (*fetch)(struct transport *transport, int refs_nr, const struct ref **refs); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); int (*disconnect)(struct transport *connection); @@ -68,7 +68,7 @@ int transport_push(struct transport *connection, const struct ref *transport_get_remote_refs(struct transport *transport); -int transport_fetch_refs(struct transport *transport, struct ref *refs); +int transport_fetch_refs(struct transport *transport, const struct ref *refs); void transport_unlock_pack(struct transport *transport); int transport_disconnect(struct transport *transport); -- cgit v1.2.1 From 21188b1eafd3741fda0f7905dc997279a17b50ba Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 9 Oct 2008 01:40:32 +0200 Subject: Implement git clone -v The new -v option forces the progressbar, even in case the output is not a terminal. This can be useful if the caller is an IDE or wrapper which wants to scrape the progressbar from stderr and show its information in a different format. Signed-off-by: Miklos Vajna Signed-off-by: Shawn O. Pearce --- transport.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index d0b52053f..6bbc1a826 100644 --- a/transport.h +++ b/transport.h @@ -25,6 +25,8 @@ struct transport { int (*disconnect)(struct transport *connection); char *pack_lockfile; signed verbose : 2; + /* Force progress even if the output is not a tty */ + unsigned progress : 1; }; #define TRANSPORT_PUSH_ALL 1 -- cgit v1.2.1 From 64fcef2daa03f6093b480142c6ab2a4173b0b43e Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Sun, 8 Mar 2009 21:06:07 -0400 Subject: Move push matching and reporting logic into transport.c For native-protocol pushes (and other protocols as they are converted to the new method), this moves the refspec match, tracking update, and report message out of send-pack() and into transport_push(), where it can be shared completely with other protocols. This also makes fetch and push more similar in terms of what code is in what file. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 6bbc1a826..b1c225276 100644 --- a/transport.h +++ b/transport.h @@ -18,8 +18,9 @@ struct transport { int (*set_option)(struct transport *connection, const char *name, const char *value); - struct ref *(*get_refs_list)(struct transport *transport); + struct ref *(*get_refs_list)(struct transport *transport, int for_push); int (*fetch)(struct transport *transport, int refs_nr, const struct ref **refs); + int (*push_refs)(struct transport *transport, struct ref *refs, int flags); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); int (*disconnect)(struct transport *connection); -- cgit v1.2.1 From 47abd85ba06ed7209d1caa3e5ac7cc6b232bece4 Mon Sep 17 00:00:00 2001 From: Andreas Ericsson Date: Fri, 17 Apr 2009 10:20:11 +0200 Subject: fetch: Strip usernames from url's before storing them When pulling from a remote, the full URL including username is by default added to the commit message. Since it adds very little value but could be used by malicious people to glean valid usernames (with matching hostnames), we're far better off just stripping the username before storing the remote URL locally. Note that this patch has no lasting visible effect when "git pull" does not create a merge commit. It simply alters what gets written to .git/FETCH_HEAD, which is used by "git merge" to automagically create its messages. Signed-off-by: Andreas Ericsson Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index b1c225276..27bfc528a 100644 --- a/transport.h +++ b/transport.h @@ -74,5 +74,6 @@ const struct ref *transport_get_remote_refs(struct transport *transport); int transport_fetch_refs(struct transport *transport, const struct ref *refs); void transport_unlock_pack(struct transport *transport); int transport_disconnect(struct transport *transport); +char *transport_anonymize_url(const char *url); #endif -- cgit v1.2.1 From 1965ff744a7e4cdefcc467991182b779f3c9d0e8 Mon Sep 17 00:00:00 2001 From: Larry D'Anna Date: Mon, 22 Jun 2009 21:10:01 -0400 Subject: add --porcelain option to git-push If --porcelain is used git-push will produce machine-readable output. The output status line for each ref will be tab-separated and sent to stdout instead of stderr. The full symbolic names of the refs will be given. For example $ git push --dry-run --porcelain master :foobar 2>/dev/null \ | perl -pe 's/\t/ TAB /g' = TAB refs/heads/master:refs/heads/master TAB [up to date] - TAB :refs/heads/foobar TAB [deleted] Signed-off-by: Larry D'Anna Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 27bfc528a..51b539778 100644 --- a/transport.h +++ b/transport.h @@ -35,6 +35,7 @@ struct transport { #define TRANSPORT_PUSH_DRY_RUN 4 #define TRANSPORT_PUSH_MIRROR 8 #define TRANSPORT_PUSH_VERBOSE 16 +#define TRANSPORT_PUSH_PORCELAIN 32 /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); -- cgit v1.2.1 From 6eb996b5707b6d14cf9875a9231f4e909a443665 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Wed, 5 Aug 2009 01:01:53 -0400 Subject: Add support for external programs for handling native fetches transport_get() can call transport_native_helper_init() to have list and fetch-ref operations handled by running a separate program as: git remote- [] This program then accepts, on its stdin, "list" and "fetch " commands; the former prints out a list of available refs and either their hashes or what they are symrefs to, while the latter fetches them into the local object database and prints a newline when done. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 51b539778..df8726463 100644 --- a/transport.h +++ b/transport.h @@ -77,4 +77,7 @@ void transport_unlock_pack(struct transport *transport); int transport_disconnect(struct transport *transport); char *transport_anonymize_url(const char *url); +/* Transport methods defined outside transport.c */ +int transport_helper_init(struct transport *transport); + #endif -- cgit v1.2.1 From afdeeb00eec471d86c9d421781ba8cb545be849c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 5 Aug 2009 16:22:19 -0400 Subject: push: add --quiet flag Some transports produce output even without "--verbose" turned on. This provides a way to tell them to be more quiet (whereas simply redirecting might lose error messages). Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 51b539778..f1d3ebf67 100644 --- a/transport.h +++ b/transport.h @@ -36,6 +36,7 @@ struct transport { #define TRANSPORT_PUSH_MIRROR 8 #define TRANSPORT_PUSH_VERBOSE 16 #define TRANSPORT_PUSH_PORCELAIN 32 +#define TRANSPORT_PUSH_QUIET 64 /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); -- cgit v1.2.1 From 07436e43daf1a97d3d702090d6289f745bd5ad90 Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Sat, 8 Aug 2009 09:51:08 +0200 Subject: push: point to 'git pull' and 'git push --force' in case of non-fast forward 'git push' failing because of non-fast forward is a very common situation, and a beginner does not necessarily understand "fast forward" immediately. Add a new section to the git-push documentation and refer them to it. Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano Signed-off-by: Nanako Shiraishi Signed-off-by: Junio C Hamano --- transport.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 51b539778..639f13dcf 100644 --- a/transport.h +++ b/transport.h @@ -68,7 +68,8 @@ int transport_set_option(struct transport *transport, const char *name, const char *value); int transport_push(struct transport *connection, - int refspec_nr, const char **refspec, int flags); + int refspec_nr, const char **refspec, int flags, + int * nonfastforward); const struct ref *transport_get_remote_refs(struct transport *transport); -- cgit v1.2.1 From c9e388bb48bdafdf19574add915ab0ce33a1907d Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Thu, 3 Sep 2009 22:13:49 -0400 Subject: Make the "traditionally-supported" URLs a special case Instead of trying to make http://, https://, and ftp:// URLs indicative of some sort of pattern of transport helper usage, make them a special case which runs the "curl" helper, and leave the mechanism by which arbitrary helpers will be chosen entirely to future work. Signed-off-by: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index df8726463..b49c10f57 100644 --- a/transport.h +++ b/transport.h @@ -78,6 +78,6 @@ int transport_disconnect(struct transport *transport); char *transport_anonymize_url(const char *url); /* Transport methods defined outside transport.c */ -int transport_helper_init(struct transport *transport); +int transport_helper_init(struct transport *transport, const char *name); #endif -- cgit v1.2.1 From cff7123c11aa2b1a849a46028d60b4bc0ab54c51 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 30 Oct 2009 17:47:27 -0700 Subject: fetch: Allow transport -v -v -v to set verbosity to 3 Helpers might want a higher level of verbosity than just +1 (the porcelain default setting) and +2 (-v -v). Expand the field to allow verbosity in the range -1..3. Signed-off-by: Shawn O. Pearce CC: Daniel Barkalow Signed-off-by: Junio C Hamano --- transport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index c14da6f1e..e4e6177e2 100644 --- a/transport.h +++ b/transport.h @@ -25,7 +25,7 @@ struct transport { int (*disconnect)(struct transport *connection); char *pack_lockfile; - signed verbose : 2; + signed verbose : 3; /* Force progress even if the output is not a tty */ unsigned progress : 1; }; -- cgit v1.2.1 From 3714831189b32591ffe33c08e209a9a61c25a2f6 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Wed, 18 Nov 2009 02:42:24 +0100 Subject: Allow fetch to modify refs This allows the transport to use the null sha1 for a ref reported to be present in the remote repository to indicate that a ref exists but its actual value is presently unknown and will be set if the objects are fetched. Also adds documentation to the API to specify exactly what the methods should do and how they should interpret arguments. Signed-off-by: Daniel Barkalow Signed-off-by: Sverre Rabbelier Signed-off-by: Junio C Hamano --- transport.h | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index c14da6f1e..503db1170 100644 --- a/transport.h +++ b/transport.h @@ -18,11 +18,48 @@ struct transport { int (*set_option)(struct transport *connection, const char *name, const char *value); + /** + * Returns a list of the remote side's refs. In order to allow + * the transport to try to share connections, for_push is a + * hint as to whether the ultimate operation is a push or a fetch. + * + * If the transport is able to determine the remote hash for + * the ref without a huge amount of effort, it should store it + * in the ref's old_sha1 field; otherwise it should be all 0. + **/ struct ref *(*get_refs_list)(struct transport *transport, int for_push); - int (*fetch)(struct transport *transport, int refs_nr, const struct ref **refs); + + /** + * Fetch the objects for the given refs. Note that this gets + * an array, and should ignore the list structure. + * + * If the transport did not get hashes for refs in + * get_refs_list(), it should set the old_sha1 fields in the + * provided refs now. + **/ + int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs); + + /** + * Push the objects and refs. Send the necessary objects, and + * then, for any refs where peer_ref is set and + * peer_ref->new_sha1 is different from old_sha1, tell the + * remote side to update each ref in the list from old_sha1 to + * peer_ref->new_sha1. + * + * Where possible, set the status for each ref appropriately. + * + * The transport must modify new_sha1 in the ref to the new + * value if the remote accepted the change. Note that this + * could be a different value from peer_ref->new_sha1 if the + * process involved generating new commits. + **/ int (*push_refs)(struct transport *transport, struct ref *refs, int flags); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); + /** get_refs_list(), fetch(), and push_refs() can keep + * resources (such as a connection) reserved for futher + * use. disconnect() releases these resources. + **/ int (*disconnect)(struct transport *connection); char *pack_lockfile; signed verbose : 2; @@ -74,7 +111,7 @@ int transport_push(struct transport *connection, const struct ref *transport_get_remote_refs(struct transport *transport); -int transport_fetch_refs(struct transport *transport, const struct ref *refs); +int transport_fetch_refs(struct transport *transport, struct ref *refs); void transport_unlock_pack(struct transport *transport); int transport_disconnect(struct transport *transport); char *transport_anonymize_url(const char *url); -- cgit v1.2.1 From aa5af9749f53f7e44bef36c5c40918295430fb03 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 9 Dec 2009 17:26:30 +0200 Subject: Refactor git transport options parsing Refactor the transport options parsing so that protocols that aren't directly smart transports (file://, git://, ssh:// & co) can record the smart transport options for the case if it turns that transport can actually be smart. Signed-off-by: Ilari Liusvaara Signed-off-by: Junio C Hamano --- transport.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 9e74406fa..e90c285bb 100644 --- a/transport.h +++ b/transport.h @@ -4,6 +4,15 @@ #include "cache.h" #include "remote.h" +struct git_transport_options { + unsigned thin : 1; + unsigned keep : 1; + unsigned followtags : 1; + int depth; + const char *uploadpack; + const char *receivepack; +}; + struct transport { struct remote *remote; const char *url; @@ -65,6 +74,12 @@ struct transport { signed verbose : 3; /* Force progress even if the output is not a tty */ unsigned progress : 1; + /* + * If transport is at least potentially smart, this points to + * git_transport_options structure to use in case transport + * actually turns out to be smart. + */ + struct git_transport_options *smart_options; }; #define TRANSPORT_PUSH_ALL 1 -- cgit v1.2.1 From 61b075bd3e69cbdc9010a7f817b2017455dd36a7 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 9 Dec 2009 17:26:31 +0200 Subject: Support taking over transports Add support for taking over transports that turn out to be smart. Signed-off-by: Ilari Liusvaara Signed-off-by: Junio C Hamano --- transport.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index e90c285bb..781db2ec8 100644 --- a/transport.h +++ b/transport.h @@ -130,6 +130,8 @@ int transport_fetch_refs(struct transport *transport, struct ref *refs); void transport_unlock_pack(struct transport *transport); int transport_disconnect(struct transport *transport); char *transport_anonymize_url(const char *url); +void transport_take_over(struct transport *transport, + struct child_process *child); /* Transport methods defined outside transport.c */ int transport_helper_init(struct transport *transport, const char *name); -- cgit v1.2.1 From b236752a8722c77b5a9b4ed488a992ee05252843 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Wed, 9 Dec 2009 17:26:33 +0200 Subject: Support remote archive from all smart transports Previously, remote archive required internal (non remote-helper) smart transport. Extend the remote archive to also support smart transports implemented by remote helpers. Signed-off-by: Ilari Liusvaara Signed-off-by: Junio C Hamano --- transport.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 781db2ec8..97ba2519d 100644 --- a/transport.h +++ b/transport.h @@ -64,6 +64,8 @@ struct transport { **/ int (*push_refs)(struct transport *transport, struct ref *refs, int flags); int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags); + int (*connect)(struct transport *connection, const char *name, + const char *executable, int fd[2]); /** get_refs_list(), fetch(), and push_refs() can keep * resources (such as a connection) reserved for futher @@ -133,6 +135,9 @@ char *transport_anonymize_url(const char *url); void transport_take_over(struct transport *transport, struct child_process *child); +int transport_connect(struct transport *transport, const char *name, + const char *exec, int fd[2]); + /* Transport methods defined outside transport.c */ int transport_helper_init(struct transport *transport, const char *name); -- cgit v1.2.1 From 486a3d716427ac81594fe63d4e9cae64703dbc56 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Sat, 26 Dec 2009 01:12:03 +0800 Subject: check stderr with isatty() instead of stdout when deciding to show progress Make transport code (viz. transport.c::fetch_refs_via_pack() and transport-helper.c::standard_options()) that decides to show progress check if stderr is a terminal, instead of stdout. After all, progress reports (via the API in progress.[ch]) are sent to stderr. Update the documentation for git-clone to say "standard error" as well. Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- transport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index e4e6177e2..98bb623c4 100644 --- a/transport.h +++ b/transport.h @@ -26,7 +26,7 @@ struct transport { int (*disconnect)(struct transport *connection); char *pack_lockfile; signed verbose : 3; - /* Force progress even if the output is not a tty */ + /* Force progress even if stderr is not a tty */ unsigned progress : 1; }; -- cgit v1.2.1 From e9fcd1e2121100d43d2d212eb6c6f1fc82aade1d Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Sat, 16 Jan 2010 23:45:31 +0200 Subject: Add push --set-upstream Frequent complaint is lack of easy way to set up upstream (tracking) references for git pull to work as part of push command. So add switch --set-upstream (-u) to do just that. Signed-off-by: Jeff King Signed-off-by: Ilari Liusvaara Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 97ba2519d..c4314dd59 100644 --- a/transport.h +++ b/transport.h @@ -91,6 +91,7 @@ struct transport { #define TRANSPORT_PUSH_VERBOSE 16 #define TRANSPORT_PUSH_PORCELAIN 32 #define TRANSPORT_PUSH_QUIET 64 +#define TRANSPORT_PUSH_SET_UPSTREAM 128 /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); -- cgit v1.2.1 From b0d66e156c5b312d468344569202d8ca4094f67f Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Tue, 16 Feb 2010 15:18:21 +0800 Subject: transport: add got_remote_refs flag transport_get_remote_refs() in tranport.c checks transport->remote_refs to determine whether transport->get_refs_list() should be invoked. The logic is "if it is NULL, we haven't run ls-remote to find out yet". However, transport->remote_refs could still be NULL while cloning from an empty repository. This causes get_refs_list() to be run unnecessarily. Introduce a flag, transport->got_remote_refs, to more explicitly record if we have run transport->get_refs_list() already. Signed-off-by: Tay Ray Chuan Acked-by: Jeff King Signed-off-by: Junio C Hamano --- transport.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 7cea5cc72..6dd9ae182 100644 --- a/transport.h +++ b/transport.h @@ -19,6 +19,12 @@ struct transport { void *data; const struct ref *remote_refs; + /** + * Indicates whether we already called get_refs_list(); set by + * transport.c::transport_get_remote_refs(). + */ + unsigned got_remote_refs : 1; + /** * Returns 0 if successful, positive if the option is not * recognized or is inapplicable, and negative if the option -- cgit v1.2.1 From f1863d0d16b9a5288671e17b7fa2eba8244ead2f Mon Sep 17 00:00:00 2001 From: Michael Lukashov Date: Tue, 16 Feb 2010 23:42:52 +0000 Subject: refactor duplicated code in builtin-send-pack.c and transport.c The following functions are (almost) identical: verify_remote_names update_tracking_ref refs_pushed print_push_status Move common versions of these functions to transport.c and rename them, as suggested by Jeff King and Junio C Hamano. These functions have been removed entirely from builtin-send-pack.c, since they are only used internally by print_push_status(): print_ref_status status_abbrev print_ok_ref_status print_one_push_status Also, move #define SUMMARY_WIDTH to transport.h and rename it TRANSPORT_SUMMARY_WIDTH as it is used in builtin-fetch.c and transport.c Signed-off-by: Michael Lukashov Acked-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- transport.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 7cea5cc72..7a9bb57d9 100644 --- a/transport.h +++ b/transport.h @@ -92,6 +92,7 @@ struct transport { #define TRANSPORT_PUSH_PORCELAIN 32 #define TRANSPORT_PUSH_QUIET 64 #define TRANSPORT_PUSH_SET_UPSTREAM 128 +#define TRANSPORT_SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3) /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); @@ -142,4 +143,14 @@ int transport_connect(struct transport *transport, const char *name, /* Transport methods defined outside transport.c */ int transport_helper_init(struct transport *transport, const char *name); +/* common methods used by transport.c and builtin-send-pack.c */ +void transport_verify_remote_names(int nr_heads, const char **heads); + +void transport_update_tracking_ref(struct remote *remote, struct ref *ref, int verbose); + +int transport_refs_pushed(struct ref *ref); + +void transport_print_push_status(const char *dest, struct ref *refs, + int verbose, int porcelain, int *nonfastforward); + #endif -- cgit v1.2.1 From bde873c52914b40377a12764cab926ee974c3f32 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Wed, 24 Feb 2010 20:50:23 +0800 Subject: fetch: refactor verbosity option handling into transport.[ch] transport_set_verbosity() is now provided to transport users. Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 7cea5cc72..7d1a0b6b3 100644 --- a/transport.h +++ b/transport.h @@ -122,6 +122,7 @@ struct transport *transport_get(struct remote *, const char *); **/ int transport_set_option(struct transport *transport, const char *name, const char *value); +void transport_set_verbosity(struct transport *transport, int verbosity); int transport_push(struct transport *connection, int refspec_nr, const char **refspec, int flags, -- cgit v1.2.1 From 8afd8dc065c54d3c8d8e0397506aa99261703414 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Wed, 24 Feb 2010 20:50:24 +0800 Subject: push: support multiple levels of verbosity Remove the flags TRANSPORT_PUSH_QUIET and TRANSPORT_PUSH_VERBOSE; use transport->verbose instead to determine verbosity for pushing. Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- transport.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 7d1a0b6b3..c0743b108 100644 --- a/transport.h +++ b/transport.h @@ -88,9 +88,7 @@ struct transport { #define TRANSPORT_PUSH_FORCE 2 #define TRANSPORT_PUSH_DRY_RUN 4 #define TRANSPORT_PUSH_MIRROR 8 -#define TRANSPORT_PUSH_VERBOSE 16 #define TRANSPORT_PUSH_PORCELAIN 32 -#define TRANSPORT_PUSH_QUIET 64 #define TRANSPORT_PUSH_SET_UPSTREAM 128 /* Returns a transport suitable for the url */ -- cgit v1.2.1 From d01b3c02e8a066054c308ee2ce521a2ea44738d3 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Wed, 24 Feb 2010 20:50:26 +0800 Subject: transport->progress: use flag authoritatively Set transport->progress in transport.c::transport_set_verbosity() after checking for the appropriate conditions (eg. --progress, isatty(2)), and thereafter use it without having to check again. The rules used are as follows (processing aborts when a rule is satisfied): 1. Report progress, if force_progress is 1 (ie. --progress). 2. Don't report progress, if verbosity < 0 (ie. -q/--quiet). 3. Report progress if isatty(2) is 1. This changes progress reporting behaviour such that if both --progress and --quiet are specified, progress is reported. In two areas, the logic to determine whether to *not* show progress is changed to simply use the negation of transport->progress. This changes behaviour in some ways (see previous paragraph for details). Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- transport.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index c0743b108..de2745a6e 100644 --- a/transport.h +++ b/transport.h @@ -74,7 +74,12 @@ struct transport { int (*disconnect)(struct transport *connection); char *pack_lockfile; signed verbose : 3; - /* Force progress even if stderr is not a tty */ + /** + * Transports should not set this directly, and should use this + * value without having to check isatty(2), -q/--quiet + * (transport->verbose < 0), etc. - checking has already been done + * in transport_set_verbosity(). + **/ unsigned progress : 1; /* * If transport is at least potentially smart, this points to @@ -120,7 +125,8 @@ struct transport *transport_get(struct remote *, const char *); **/ int transport_set_option(struct transport *transport, const char *name, const char *value); -void transport_set_verbosity(struct transport *transport, int verbosity); +void transport_set_verbosity(struct transport *transport, int verbosity, + int force_progress); int transport_push(struct transport *connection, int refspec_nr, const char **refspec, int flags, -- cgit v1.2.1 From 212cfe157effe53537ec42f156fbf7415441efd0 Mon Sep 17 00:00:00 2001 From: Tay Ray Chuan Date: Wed, 24 Feb 2010 20:50:29 +0800 Subject: transport: update flags to be in running order Signed-off-by: Tay Ray Chuan Signed-off-by: Junio C Hamano --- transport.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index de2745a6e..d9bbabba0 100644 --- a/transport.h +++ b/transport.h @@ -93,8 +93,8 @@ struct transport { #define TRANSPORT_PUSH_FORCE 2 #define TRANSPORT_PUSH_DRY_RUN 4 #define TRANSPORT_PUSH_MIRROR 8 -#define TRANSPORT_PUSH_PORCELAIN 32 -#define TRANSPORT_PUSH_SET_UPSTREAM 128 +#define TRANSPORT_PUSH_PORCELAIN 16 +#define TRANSPORT_PUSH_SET_UPSTREAM 32 /* Returns a transport suitable for the url */ struct transport *transport_get(struct remote *, const char *); -- cgit v1.2.1 From 419f37db4d1e2fe3c394c869c5375e545b3e364d Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Tue, 12 Oct 2010 19:39:41 +0300 Subject: Add bidirectional_transfer_loop() This helper function copies bidirectional stream of data between stdin/stdout and specified file descriptors. Signed-off-by: Ilari Liusvaara Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index c59d97388..e803c0e7b 100644 --- a/transport.h +++ b/transport.h @@ -154,6 +154,7 @@ int transport_connect(struct transport *transport, const char *name, /* Transport methods defined outside transport.c */ int transport_helper_init(struct transport *transport, const char *name); +int bidirectional_transfer_loop(int input, int output); /* common methods used by transport.c and builtin-send-pack.c */ void transport_verify_remote_names(int nr_heads, const char **heads); -- cgit v1.2.1 From 36cfda15527d4eb50c84256307e3cb46578f975e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 11 Mar 2011 11:32:53 -0800 Subject: refs_from_alternate: helper to use refs from alternates The receiving end of "git push" advertises the objects that the repository itself does not use, but are at the tips of refs in other repositories whose object databases are used as alternates for it. This helps it avoid having to receive (and the pusher having to send) objects that are already available to the receiving repository via the alternates mechanism. Tweak the helper function that implements this feature, and move it to transport.[ch] for future reuse by other programs. The additional test demonstrates how this optimization is helping "git push", and "git fetch" is ignorant about it. Signed-off-by: Junio C Hamano Acked-by: Shawn O. Pearce --- transport.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index e803c0e7b..efb196886 100644 --- a/transport.h +++ b/transport.h @@ -166,4 +166,7 @@ int transport_refs_pushed(struct ref *ref); void transport_print_push_status(const char *dest, struct ref *refs, int verbose, int porcelain, int *nonfastforward); +typedef void alternate_ref_fn(const struct ref *, void *); +extern int refs_from_alternate_cb(struct alternate_object_database *e, void *cb); + #endif -- cgit v1.2.1 From 114a6a889f5d21c26800c395a97cdd400073a9e8 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 19 May 2011 17:33:17 -0400 Subject: refactor refs_from_alternate_cb to allow passing extra data The foreach_alt_odb function triggers a callback for each alternate object db we have, with room for a single void pointer as data. Currently, we always call refs_from_alternate_cb as the callback function, and then pass another callback (to receive each ref individually) as the void pointer. This has two problems: 1. C technically forbids stuffing a function pointer into a "void *". In practice, this probably doesn't matter on any architectures git runs on, but it never hurts to follow the letter of the law. 2. There is no room for an extra data pointer. Indeed, the alternate_ref_fn that refs_from_alternate_cb calls takes a void* for data, but we always pass it NULL. Instead, let's properly stuff our function pointer into a data struct, which also leaves room for an extra caller-supplied data pointer. And to keep things simple for existing callers, let's make a for_each_alternate_ref function that takes care of creating the extra struct. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- transport.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'transport.h') diff --git a/transport.h b/transport.h index efb196886..161d724bb 100644 --- a/transport.h +++ b/transport.h @@ -167,6 +167,6 @@ void transport_print_push_status(const char *dest, struct ref *refs, int verbose, int porcelain, int *nonfastforward); typedef void alternate_ref_fn(const struct ref *, void *); -extern int refs_from_alternate_cb(struct alternate_object_database *e, void *cb); +extern void for_each_alternate_ref(alternate_ref_fn, void *); #endif -- cgit v1.2.1 From d2b17b3220cbd75b1c8e2aa6cfdc5c121749c97d Mon Sep 17 00:00:00 2001 From: Fredrik Gustafsson Date: Sat, 20 Aug 2011 00:08:47 +0200 Subject: push: Don't push a repository with unpushed submodules When working with submodules it is easy to forget to push a submodule to the server but pushing a super-project that contains a commit for that submodule. The result is that the superproject points at a submodule commit that is not available on the server. This adds the option --recurse-submodules=check to push. When using this option git will check that all submodule commits that are about to be pushed are present on a remote of the submodule. To be able to use a combined diff, disabling a diff callback has been removed from combined-diff.c. Signed-off-by: Fredrik Gustafsson Mentored-by: Jens Lehmann Mentored-by: Heiko Voigt Signed-off-by: Junio C Hamano --- transport.h | 1 + 1 file changed, 1 insertion(+) (limited to 'transport.h') diff --git a/transport.h b/transport.h index 161d724bb..059b3303e 100644 --- a/transport.h +++ b/transport.h @@ -101,6 +101,7 @@ struct transport { #define TRANSPORT_PUSH_MIRROR 8 #define TRANSPORT_PUSH_PORCELAIN 16 #define TRANSPORT_PUSH_SET_UPSTREAM 32 +#define TRANSPORT_RECURSE_SUBMODULES_CHECK 64 #define TRANSPORT_SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3) -- cgit v1.2.1