MCPcopy Create free account
hub / github.com/git/git / parse_data

Function parse_data

builtin/fast-import.c:1919–1964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1917}
1918
1919static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)
1920{
1921 const char *data;
1922 strbuf_reset(sb);
1923
1924 if (!skip_prefix(command_buf.buf, "data ", &data))
1925 die(_("expected 'data n' command, found: %s"), command_buf.buf);
1926
1927 if (skip_prefix(data, "<<", &data)) {
1928 char *term = xstrdup(data);
1929 size_t term_len = command_buf.len - (data - command_buf.buf);
1930
1931 for (;;) {
1932 if (strbuf_getline_lf(&command_buf, stdin) == EOF)
1933 die(_("EOF in data (terminator '%s' not found)"), term);
1934 if (term_len == command_buf.len
1935 && !strcmp(term, command_buf.buf))
1936 break;
1937 strbuf_addbuf(sb, &command_buf);
1938 strbuf_addch(sb, '\n');
1939 }
1940 free(term);
1941 }
1942 else {
1943 uintmax_t len = strtoumax(data, NULL, 10);
1944 size_t n = 0, length = (size_t)len;
1945
1946 if (limit && limit < len) {
1947 *len_res = len;
1948 return 0;
1949 }
1950 if (length < len)
1951 die(_("data is too large to use in this context"));
1952
1953 while (n < length) {
1954 size_t s = strbuf_fread(sb, length - n, stdin);
1955 if (!s && feof(stdin))
1956 die(_("EOF in data (%lu bytes remaining)"),
1957 (unsigned long)(length - n));
1958 n += s;
1959 }
1960 }
1961
1962 skip_optional_lf();
1963 return 1;
1964}
1965
1966static int validate_raw_date(const char *src, struct strbuf *result, int strict)
1967{

Callers 5

parse_and_store_blobFunction · 0.85
parse_one_signatureFunction · 0.85
discard_one_signatureFunction · 0.85
parse_new_commitFunction · 0.85
parse_new_tagFunction · 0.85

Calls 7

xstrdupFunction · 0.85
strbuf_getline_lfFunction · 0.85
strbuf_addbufFunction · 0.85
strbuf_addchFunction · 0.85
strbuf_freadFunction · 0.85
skip_optional_lfFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected