If this is over git protocol, the flags is appended as the next
parameter after host=. If it's ssh, a new argument is appended to the
command line.

None of the callers use this now though.

[sb: originally by pclouds, rebased as jk implemented 1823bea10,
(git_connect: use argv_array), so any error is mine]

Signed-off-by: Stefan Beller <sbel...@google.com>
---
 builtin/fetch-pack.c |  2 +-
 builtin/send-pack.c  |  2 +-
 connect.c            | 18 ++++++++++++------
 connect.h            |  2 +-
 transport.c          |  3 ++-
 5 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 4a6b340..7e5b5fd 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -171,7 +171,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char 
*prefix)
                if (args.diag_url)
                        flags |= CONNECT_DIAG_URL;
                conn = git_connect(fd, dest, args.uploadpack,
-                                  flags);
+                                  NULL, flags);
                if (!conn)
                        return args.diag_url ? 0 : 1;
        }
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index b961e5a..c2a066a 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -261,7 +261,7 @@ int cmd_send_pack(int argc, const char **argv, const char 
*prefix)
                fd[0] = 0;
                fd[1] = 1;
        } else {
-               conn = git_connect(fd, dest, receivepack,
+               conn = git_connect(fd, dest, receivepack, NULL,
                        args.verbose ? CONNECT_VERBOSE : 0);
        }
 
diff --git a/connect.c b/connect.c
index 062e133..7b6b241 100644
--- a/connect.c
+++ b/connect.c
@@ -650,7 +650,9 @@ static struct child_process no_fork = CHILD_PROCESS_INIT;
  * the connection failed).
  */
 struct child_process *git_connect(int fd[2], const char *url,
-                                 const char *prog, int flags)
+                                 const char *prog,
+                                 const char *service_flags,
+                                 int flags)
 {
        char *hostandport, *path;
        struct child_process *conn = &no_fork;
@@ -685,10 +687,13 @@ struct child_process *git_connect(int fd[2], const char 
*url,
                 * Note: Do not add any other headers here!  Doing so
                 * will cause older git-daemon servers to crash.
                 */
-               packet_write(fd[1],
-                            "%s %s%chost=%s%c",
-                            prog, path, 0,
-                            target_host, 0);
+               if (!service_flags)
+                       packet_write(fd[1], "%s %s%chost=%s%c",
+                                    prog, path, 0, target_host, 0);
+               else
+                       packet_write(fd[1], "%s %s%chost=%s%c%s%c",
+                                    prog, path, 0, target_host, 0,
+                                    service_flags, 0);
                free(target_host);
        } else {
                conn = xmalloc(sizeof(*conn));
@@ -733,7 +738,8 @@ struct child_process *git_connect(int fd[2], const char 
*url,
                        conn->use_shell = 1;
                }
                argv_array_push(&conn->args, cmd.buf);
-
+               if (service_flags)
+                       argv_array_push(&conn->args, service_flags);
                if (start_command(conn))
                        die("unable to fork");
 
diff --git a/connect.h b/connect.h
index c41a685..c4fa8a1 100644
--- a/connect.h
+++ b/connect.h
@@ -3,7 +3,7 @@
 
 #define CONNECT_VERBOSE       (1u << 0)
 #define CONNECT_DIAG_URL      (1u << 1)
-extern struct child_process *git_connect(int fd[2], const char *url, const 
char *prog, int flags);
+extern struct child_process *git_connect(int fd[2], const char *url, const 
char *prog, const char *service_flags, int flags);
 extern int finish_connect(struct child_process *conn);
 extern int git_connection_is_socket(struct child_process *conn);
 extern int server_supports(const char *feature);
diff --git a/transport.c b/transport.c
index 0694a7c..626fd92 100644
--- a/transport.c
+++ b/transport.c
@@ -495,6 +495,7 @@ static int connect_setup(struct transport *transport, int 
for_push, int verbose)
        data->conn = git_connect(data->fd, transport->url,
                                 for_push ? data->options.receivepack :
                                 data->options.uploadpack,
+                                NULL,
                                 verbose ? CONNECT_VERBOSE : 0);
 
        return 0;
@@ -850,7 +851,7 @@ static int connect_git(struct transport *transport, const 
char *name,
 {
        struct git_transport_data *data = transport->data;
        data->conn = git_connect(data->fd, transport->url,
-                                executable, 0);
+                                executable, NULL, 0);
        fd[0] = data->fd[0];
        fd[1] = data->fd[1];
        return 0;
-- 
2.3.0.81.gc37f363

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to