forked from gitster/git
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnected.c
More file actions
Latest commit
62 lines (54 loc) · 1.5 KB
/
Copy pathconnected.c
File metadata and controls
62 lines (54 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include"cache.h"
#include"run-command.h"
#include"sigchain.h"
#include"connected.h"
/*
* If we feed all the commits we want to verify to this command
*
* $ git rev-list --verify-objects --stdin --not --all
*
* and if it does not error out, that means everything reachable from
* these commits locally exists and is connected to some of our
* existing refs.
*
* Returns 0 if everything is connected, non-zero otherwise.
*/
intcheck_everything_connected(sha1_iterate_fnfn, intquiet, void*cb_data)
{
structchild_processrev_list;
constchar*argv[] = {"rev-list", "--verify-objects",
"--stdin", "--not", "--all", NULL, NULL};
charcommit[41];
unsigned charsha1[20];
interr=0;
if (fn(cb_data, sha1))
returnerr;
if (quiet)
argv[5] ="--quiet";
memset(&rev_list, 0, sizeof(rev_list));
rev_list.argv=argv;
rev_list.git_cmd=1;
rev_list.in=-1;
rev_list.no_stdout=1;
rev_list.no_stderr=quiet;
if (start_command(&rev_list))
returnerror(_("Could not run 'git rev-list'"));
sigchain_push(SIGPIPE, SIG_IGN);
commit[40] ='\n';
do {
memcpy(commit, sha1_to_hex(sha1), 40);
if (write_in_full(rev_list.in, commit, 41) <0) {
if (errno!=EPIPE&&errno!=EINVAL)
error(_("failed write to rev-list: %s"),
strerror(errno));
err=-1;
break;
}
} while (!fn(cb_data, sha1));
if (close(rev_list.in)) {
error(_("failed to close rev-list's stdin: %s"), strerror(errno));
err=-1;
}
sigchain_pop(SIGPIPE);
returnfinish_command(&rev_list) ||err;
}