fix(cli): tree doesnt try to strdup NULL out of the flat map
This commit is contained in:
parent
afbcd5d338
commit
a2805c1a3f
1 changed files with 3 additions and 2 deletions
|
|
@ -415,6 +415,7 @@ static int commit(int argc, char** argv) {
|
|||
for (size_t idx = 0; idx < files->len; idx++) {
|
||||
BaseFileInfo* base_file = base_file_buffer_search(base_files, files->items[idx]);
|
||||
if (!base_file) {
|
||||
printf("this is a basefile as it should be\n");
|
||||
BaseFileInfo info = (BaseFileInfo){.base_num = 0, .diff_num = 0, .name = strdup(files->items[idx])};
|
||||
base_file_buffer_push(base_files, info);
|
||||
// Compress the files content and put it into the object database
|
||||
|
|
@ -604,8 +605,8 @@ static int commit(int argc, char** argv) {
|
|||
}
|
||||
|
||||
for (size_t idx = 0; idx < tree->len; idx++) {
|
||||
((FileInfo*)tree->items + idx)->hash = strdup(flat_map_get(file_hash_map, ((FileInfo*)tree->items + idx)->name));
|
||||
printf("%s: %s\n", ((FileInfo*)tree->items + idx)->name, ((FileInfo*)tree->items + idx)->hash);
|
||||
char* hash = flat_map_get(file_hash_map, ((FileInfo*)tree->items + idx)->name);
|
||||
if (hash) ((FileInfo*)tree->items + idx)->hash = strdup(hash);
|
||||
}
|
||||
|
||||
char tree_hash[41];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue