MCPcopy Index your code
hub / github.com/git/git / read_bundle_header_fd

Function read_bundle_header_fd

bundle.c:77–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77int read_bundle_header_fd(int fd, struct bundle_header *header,
78 const char *report_path)
79{
80 struct strbuf buf = STRBUF_INIT;
81 int status = 0;
82
83 /* The bundle header begins with the signature */
84 if (strbuf_getwholeline_fd(&buf, fd, '\n') ||
85 parse_bundle_signature(header, buf.buf)) {
86 if (report_path)
87 error(_("'%s' does not look like a v2 or v3 bundle file"),
88 report_path);
89 status = -1;
90 goto abort;
91 }
92
93 /*
94 * The default hash format for bundles is SHA1, unless told otherwise
95 * by an "object-format=" capability, which is being handled in
96 * `parse_capability()`.
97 */
98 header->hash_algo = &hash_algos[GIT_HASH_SHA1_LEGACY];
99
100 /* The bundle header ends with an empty line */
101 while (!strbuf_getwholeline_fd(&buf, fd, '\n') &&
102 buf.len && buf.buf[0] != '\n') {
103 struct object_id oid;
104 int is_prereq = 0;
105 const char *p;
106
107 strbuf_rtrim(&buf);
108
109 if (header->version == 3 && *buf.buf == '@') {
110 if (parse_capability(header, buf.buf + 1)) {
111 status = -1;
112 break;
113 }
114 continue;
115 }
116
117 if (*buf.buf == '-') {
118 is_prereq = 1;
119 strbuf_remove(&buf, 0, 1);
120 }
121
122 /*
123 * Tip lines have object name, SP, and refname.
124 * Prerequisites have object name that is optionally
125 * followed by SP and subject line.
126 */
127 if (parse_oid_hex_algop(buf.buf, &oid, &p, header->hash_algo) ||
128 (*p && !isspace(*p)) ||
129 (!is_prereq && !*p)) {
130 if (report_path)
131 error(_("unrecognized header: %s%s (%d)"),
132 (is_prereq ? "-" : ""), buf.buf, (int)buf.len);
133 status = -1;
134 break;

Callers 3

read_bundle_headerFunction · 0.85
is_bundleFunction · 0.85
open_bundleFunction · 0.85

Calls 9

strbuf_getwholeline_fdFunction · 0.85
parse_bundle_signatureFunction · 0.85
errorFunction · 0.85
strbuf_rtrimFunction · 0.85
strbuf_removeFunction · 0.85
oiddupFunction · 0.85
strbuf_releaseFunction · 0.85
parse_capabilityFunction · 0.70
string_list_appendFunction · 0.70

Tested by

no test coverage detected