Merge branch 'mh/fetch-pack-constness'
Tighten constness of some local variables in a callchain. By Michael Haggerty * mh/fetch-pack-constness: cmd_fetch_pack(): respect constness of argv parameter cmd_fetch_pack(): combine the loop termination conditions cmd_fetch_pack(): handle non-option arguments outside of the loop cmd_fetch_pack(): declare dest to be const
This commit is contained in:
commit
4dbfaee0c7
@ -899,9 +899,11 @@ static void fetch_pack_setup(void)
|
|||||||
|
|
||||||
int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
|
int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
int i, ret, nr_heads;
|
int i, ret;
|
||||||
struct ref *ref = NULL;
|
struct ref *ref = NULL;
|
||||||
char *dest = NULL, **heads;
|
const char *dest = NULL;
|
||||||
|
int alloc_heads = 0, nr_heads = 0;
|
||||||
|
char **heads = NULL;
|
||||||
int fd[2];
|
int fd[2];
|
||||||
char *pack_lockfile = NULL;
|
char *pack_lockfile = NULL;
|
||||||
char **pack_lockfile_ptr = NULL;
|
char **pack_lockfile_ptr = NULL;
|
||||||
@ -909,12 +911,9 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
packet_trace_identity("fetch-pack");
|
packet_trace_identity("fetch-pack");
|
||||||
|
|
||||||
nr_heads = 0;
|
for (i = 1; i < argc && *argv[i] == '-'; i++) {
|
||||||
heads = NULL;
|
|
||||||
for (i = 1; i < argc; i++) {
|
|
||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
|
|
||||||
if (*arg == '-') {
|
|
||||||
if (!prefixcmp(arg, "--upload-pack=")) {
|
if (!prefixcmp(arg, "--upload-pack=")) {
|
||||||
args.uploadpack = arg + 14;
|
args.uploadpack = arg + 14;
|
||||||
continue;
|
continue;
|
||||||
@ -971,22 +970,20 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
usage(fetch_pack_usage);
|
usage(fetch_pack_usage);
|
||||||
}
|
}
|
||||||
dest = (char *)arg;
|
|
||||||
heads = (char **)(argv + i + 1);
|
if (i < argc)
|
||||||
nr_heads = argc - i - 1;
|
dest = argv[i++];
|
||||||
break;
|
else
|
||||||
}
|
|
||||||
if (!dest)
|
|
||||||
usage(fetch_pack_usage);
|
usage(fetch_pack_usage);
|
||||||
|
|
||||||
if (args.stdin_refs) {
|
|
||||||
/*
|
/*
|
||||||
* Copy refs from cmdline to new growable list, then
|
* Copy refs from cmdline to growable list, then append any
|
||||||
* append the refs from the standard input.
|
* refs from the standard input:
|
||||||
*/
|
*/
|
||||||
int alloc_heads = nr_heads;
|
ALLOC_GROW(heads, argc - i, alloc_heads);
|
||||||
int size = nr_heads * sizeof(*heads);
|
for (; i < argc; i++)
|
||||||
heads = memcpy(xmalloc(size), heads, size);
|
heads[nr_heads++] = xstrdup(argv[i]);
|
||||||
|
if (args.stdin_refs) {
|
||||||
if (args.stateless_rpc) {
|
if (args.stateless_rpc) {
|
||||||
/* in stateless RPC mode we use pkt-line to read
|
/* in stateless RPC mode we use pkt-line to read
|
||||||
* from stdin, until we get a flush packet
|
* from stdin, until we get a flush packet
|
||||||
@ -1018,7 +1015,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
|
|||||||
fd[0] = 0;
|
fd[0] = 0;
|
||||||
fd[1] = 1;
|
fd[1] = 1;
|
||||||
} else {
|
} else {
|
||||||
conn = git_connect(fd, (char *)dest, args.uploadpack,
|
conn = git_connect(fd, dest, args.uploadpack,
|
||||||
args.verbose ? CONNECT_VERBOSE : 0);
|
args.verbose ? CONNECT_VERBOSE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user