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

Function parse_binary

apply.c:2131–2180  ·  view source on GitHub ↗

* Returns: * -1 in case of error, * the length of the parsed binary patch otherwise */

Source from the content-addressed store, hash-verified

2129 * the length of the parsed binary patch otherwise
2130 */
2131static int parse_binary(struct apply_state *state,
2132 char *buffer,
2133 unsigned long size,
2134 struct patch *patch)
2135{
2136 /*
2137 * We have read "GIT binary patch\n"; what follows is a line
2138 * that says the patch method (currently, either "literal" or
2139 * "delta") and the length of data before deflating; a
2140 * sequence of 'length-byte' followed by base-85 encoded data
2141 * follows.
2142 *
2143 * When a binary patch is reversible, there is another binary
2144 * hunk in the same format, starting with patch method (either
2145 * "literal" or "delta") with the length of data, and a sequence
2146 * of length-byte + base-85 encoded data, terminated with another
2147 * empty line. This data, when applied to the postimage, produces
2148 * the preimage.
2149 */
2150 struct fragment *forward;
2151 struct fragment *reverse;
2152 int status;
2153 int used, used_1;
2154
2155 forward = parse_binary_hunk(state, &buffer, &size, &status, &used);
2156 if (!forward && !status)
2157 /* there has to be one hunk (forward hunk) */
2158 return error(_("unrecognized binary patch at %s:%d"),
2159 state->patch_input_file, state->linenr-1);
2160 if (status)
2161 /* otherwise we already gave an error message */
2162 return status;
2163
2164 reverse = parse_binary_hunk(state, &buffer, &size, &status, &used_1);
2165 if (reverse)
2166 used += used_1;
2167 else if (status) {
2168 /*
2169 * Not having reverse hunk is not an error, but having
2170 * a corrupt reverse hunk is.
2171 */
2172 free((void*) forward->patch);
2173 free(forward);
2174 return status;
2175 }
2176 forward->next = reverse;
2177 patch->fragments = forward;
2178 patch->is_binary = 1;
2179 return used;
2180}
2181
2182static void prefix_one(struct apply_state *state, char **name)
2183{

Callers 1

parse_chunkFunction · 0.85

Calls 2

parse_binary_hunkFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected