Skip to content

Commit 1e5f31d

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bdf4276 commit 1e5f31d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

transport.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,17 @@ char *transport_anonymize_url(const char *url)
13251325
return xstrdup(url);
13261326
}
13271327

1328+
static void fill_alternate_refs_command(struct child_process *cmd,
1329+
const char *repo_path)
1330+
{
1331+
cmd->git_cmd = 1;
1332+
argv_array_pushf(&cmd->args, "--git-dir=%s", repo_path);
1333+
argv_array_push(&cmd->args, "for-each-ref");
1334+
argv_array_push(&cmd->args, "--format=%(objectname)");
1335+
cmd->env = local_repo_env;
1336+
cmd->out = -1;
1337+
}
1338+
13281339
static void read_alternate_refs(const char *path,
13291340
alternate_ref_fn *cb,
13301341
void *data)
@@ -1333,12 +1344,7 @@ static void read_alternate_refs(const char *path,
13331344
struct strbuf line = STRBUF_INIT;
13341345
FILE *fh;
13351346

1336-
cmd.git_cmd = 1;
1337-
argv_array_pushf(&cmd.args, "--git-dir=%s", path);
1338-
argv_array_push(&cmd.args, "for-each-ref");
1339-
argv_array_push(&cmd.args, "--format=%(objectname)");
1340-
cmd.env = local_repo_env;
1341-
cmd.out = -1;
1347+
fill_alternate_refs_command(&cmd, path);
13421348

13431349
if (start_command(&cmd))
13441350
return;

0 commit comments

Comments
 (0)