Skip to content

Commit 614db3e

Browse files
pcloudsgitster
authored andcommitted
connected.c: add new variant that runs with --shallow-file
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 069c053 commit 614db3e

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

connected.c

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ int check_everything_connected(sha1_iterate_fn fn, int quiet, void *cb_data)
1919
*
2020
* Returns 0 if everything is connected, non-zero otherwise.
2121
*/
22-
int check_everything_connected_with_transport(sha1_iterate_fn fn,
23-
int quiet,
24-
void *cb_data,
25-
struct transport *transport)
22+
static int check_everything_connected_real(sha1_iterate_fn fn,
23+
int quiet,
24+
void *cb_data,
25+
struct transport *transport,
26+
const char *shallow_file)
2627
{
2728
struct child_process rev_list;
28-
const char *argv[] = {"rev-list", "--objects",
29-
"--stdin", "--not", "--all", NULL, NULL};
29+
const char *argv[9];
3030
char commit[41];
3131
unsigned char sha1[20];
32-
int err = 0;
32+
int err = 0, ac = 0;
3333
struct packed_git *new_pack = NULL;
3434

3535
if (fn(cb_data, sha1))
@@ -47,8 +47,18 @@ int check_everything_connected_with_transport(sha1_iterate_fn fn,
4747
strbuf_release(&idx_file);
4848
}
4949

50+
if (shallow_file) {
51+
argv[ac++] = "--shallow-file";
52+
argv[ac++] = shallow_file;
53+
}
54+
argv[ac++] = "rev-list";
55+
argv[ac++] = "--objects";
56+
argv[ac++] = "--stdin";
57+
argv[ac++] = "--not";
58+
argv[ac++] = "--all";
5059
if (quiet)
51-
argv[5] = "--quiet";
60+
argv[ac++] = "--quiet";
61+
argv[ac] = NULL;
5262

5363
memset(&rev_list, 0, sizeof(rev_list));
5464
rev_list.argv = argv;
@@ -92,3 +102,19 @@ int check_everything_connected_with_transport(sha1_iterate_fn fn,
92102
sigchain_pop(SIGPIPE);
93103
return finish_command(&rev_list) || err;
94104
}
105+
106+
int check_everything_connected_with_transport(sha1_iterate_fn fn,
107+
int quiet,
108+
void *cb_data,
109+
struct transport *transport)
110+
{
111+
return check_everything_connected_real(fn, quiet, cb_data,
112+
transport, NULL);
113+
}
114+
115+
int check_shallow_connected(sha1_iterate_fn fn, int quiet, void *cb_data,
116+
const char *shallow_file)
117+
{
118+
return check_everything_connected_real(fn, quiet, cb_data,
119+
NULL, shallow_file);
120+
}

connected.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ typedef int (*sha1_iterate_fn)(void *, unsigned char [20]);
1818
* Return 0 if Ok, non zero otherwise (i.e. some missing objects)
1919
*/
2020
extern int check_everything_connected(sha1_iterate_fn, int quiet, void *cb_data);
21+
extern int check_shallow_connected(sha1_iterate_fn, int quiet, void *cb_data,
22+
const char *shallow_file);
2123
extern int check_everything_connected_with_transport(sha1_iterate_fn, int quiet,
2224
void *cb_data,
2325
struct transport *transport);

0 commit comments

Comments
 (0)