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

Function resolve_undo_read

resolve-undo.c:58–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58struct string_list *resolve_undo_read(const char *data, unsigned long size,
59 const struct git_hash_algo *algop)
60{
61 struct string_list *resolve_undo;
62 size_t len;
63 char *endptr;
64 int i;
65 const unsigned rawsz = algop->rawsz;
66
67 CALLOC_ARRAY(resolve_undo, 1);
68 resolve_undo->strdup_strings = 1;
69
70 while (size) {
71 struct string_list_item *lost;
72 struct resolve_undo_info *ui;
73
74 len = strlen(data) + 1;
75 if (size <= len)
76 goto error;
77 lost = string_list_insert(resolve_undo, data);
78 if (!lost->util)
79 lost->util = xcalloc(1, sizeof(*ui));
80 ui = lost->util;
81 size -= len;
82 data += len;
83
84 for (i = 0; i < 3; i++) {
85 ui->mode[i] = strtoul(data, &endptr, 8);
86 if (!endptr || endptr == data || *endptr)
87 goto error;
88 len = (endptr + 1) - (char*)data;
89 if (size <= len)
90 goto error;
91 size -= len;
92 data += len;
93 }
94
95 for (i = 0; i < 3; i++) {
96 if (!ui->mode[i])
97 continue;
98 if (size < rawsz)
99 goto error;
100 oidread(&ui->oid[i], (const unsigned char *)data, algop);
101 size -= rawsz;
102 data += rawsz;
103 }
104 }
105 return resolve_undo;
106
107error:
108 string_list_clear(resolve_undo, 1);
109 error("Index records invalid resolve-undo information");
110 return NULL;
111}
112
113void resolve_undo_clear_index(struct index_state *istate)
114{

Callers 1

read_index_extensionFunction · 0.85

Calls 5

string_list_insertFunction · 0.85
xcallocFunction · 0.85
oidreadFunction · 0.85
string_list_clearFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected