summaryrefslogtreecommitdiff
path: root/transport.c
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2018-10-08 18:09:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-09 05:30:03 (GMT)
commit1e5f31d444436cfab1b1aef3026ffbd925f5a818 (patch)
tree868a7d47976a5c259569a502d5ce6084ed540345 /transport.c
parentbdf4276c91623cf57efefd2ada7fb3e0709e2230 (diff)
downloadgit-1e5f31d444436cfab1b1aef3026ffbd925f5a818.zip
git-1e5f31d444436cfab1b1aef3026ffbd925f5a818.tar.gz
git-1e5f31d444436cfab1b1aef3026ffbd925f5a818.tar.bz2
transport.c: extract 'fill_alternate_refs_command'
To list alternate references, 'read_alternate_refs' creates a child process running 'git for-each-ref' in the alternate's Git directory. Prepare to run other commands besides 'git for-each-ref' by introducing and moving the relevant code from 'read_alternate_refs' to 'fill_alternate_refs_command'. Signed-off-by: Taylor Blau <me@ttaylorr.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'transport.c')
-rw-r--r--transport.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/transport.c b/transport.c
index 1ae2973..25d8ea7 100644
--- a/transport.c
+++ b/transport.c
@@ -1325,6 +1325,17 @@ literal_copy:
return xstrdup(url);
}
+static void fill_alternate_refs_command(struct child_process *cmd,
+ const char *repo_path)
+{
+ cmd->git_cmd = 1;
+ argv_array_pushf(&cmd->args, "--git-dir=%s", repo_path);
+ argv_array_push(&cmd->args, "for-each-ref");
+ argv_array_push(&cmd->args, "--format=%(objectname)");
+ cmd->env = local_repo_env;
+ cmd->out = -1;
+}
+
static void read_alternate_refs(const char *path,
alternate_ref_fn *cb,
void *data)
@@ -1333,12 +1344,7 @@ static void read_alternate_refs(const char *path,
struct strbuf line = STRBUF_INIT;
FILE *fh;
- cmd.git_cmd = 1;
- argv_array_pushf(&cmd.args, "--git-dir=%s", path);
- argv_array_push(&cmd.args, "for-each-ref");
- argv_array_push(&cmd.args, "--format=%(objectname)");
- cmd.env = local_repo_env;
- cmd.out = -1;
+ fill_alternate_refs_command(&cmd, path);
if (start_command(&cmd))
return;