refactor(tree): removed everything relating to tree diffs
This commit is contained in:
parent
d07c67c35e
commit
afbcd5d338
5 changed files with 22 additions and 337 deletions
31
src/object.c
31
src/object.c
|
|
@ -17,7 +17,7 @@ char* get_object(char* hash, size_t* size_out) {
|
|||
free(compressed_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t idx = 0;
|
||||
while (idx < compressed_size && IS_DIGIT(compressed_data[idx])) {
|
||||
|
|
@ -152,7 +152,7 @@ static int mkdir_recursive(const char *path, mode_t mode) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int save_diff(ActionList* diff, char* path, char* root, size_t diff_id, char* basefile_hash, File* modified_file, int tree) {
|
||||
int save_diff(ActionList* diff, char* path, char* root, size_t diff_id, char* basefile_hash) {
|
||||
size_t buffer_size = 41;
|
||||
|
||||
buffer_size += 1 + snprintf(NULL, 0, "%d", diff->len);
|
||||
|
|
@ -186,20 +186,20 @@ int save_diff(ActionList* diff, char* path, char* root, size_t diff_id, char* ba
|
|||
size_t remaining = sizeof(tmp) - offset;
|
||||
|
||||
if (action.type == DELETE) {
|
||||
offset += snprintf(tmp + offset,
|
||||
remaining,
|
||||
"0 %zu %zu ",
|
||||
action.line_original,
|
||||
offset += snprintf(tmp + offset,
|
||||
remaining,
|
||||
"0 %zu %zu ",
|
||||
action.line_original,
|
||||
action.line_changed
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
offset += snprintf(tmp + offset, remaining,
|
||||
"1 %zu %zu %zu %s ",
|
||||
action.line_original,
|
||||
action.line_changed,
|
||||
strlen(action.content),
|
||||
offset += snprintf(tmp + offset, remaining,
|
||||
"1 %zu %zu %zu %s ",
|
||||
action.line_original,
|
||||
action.line_changed,
|
||||
strlen(action.content),
|
||||
action.content
|
||||
);
|
||||
}
|
||||
|
|
@ -207,8 +207,7 @@ int save_diff(ActionList* diff, char* path, char* root, size_t diff_id, char* ba
|
|||
char id[2+snprintf(NULL, 0, "%d", diff_id)+strlen(path)];
|
||||
snprintf(id, sizeof(id), "%s %d", path, diff_id);
|
||||
char hash[41];
|
||||
if (tree) object_hash(TreeDiffObject, id, hash);
|
||||
else object_hash(FileDiffObject, id, hash);
|
||||
object_hash(FileDiffObject, id, hash);
|
||||
|
||||
char dir_path[PATH_MAX];
|
||||
char file_path[PATH_MAX];
|
||||
|
|
@ -287,7 +286,7 @@ int read_diff(char* content, char* basefile_hash, ActionList* diff_out) {
|
|||
|
||||
char* end;
|
||||
long actions = strtol(number_of_actions, &end, 10);
|
||||
|
||||
|
||||
if (end == number_of_actions || *end != '\0' || actions < 0) {
|
||||
perror("ERROR: invalid number of actions in read_diff!");
|
||||
free(number_of_actions);
|
||||
|
|
@ -375,7 +374,7 @@ int read_diff(char* content, char* basefile_hash, ActionList* diff_out) {
|
|||
}
|
||||
|
||||
int save_file_diff(char* path, char* root, size_t diff_id, char* basefile_hash, ActionList* diff) {
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -419,4 +418,4 @@ File* apply_diff(File* basefile, ActionList* diff) {
|
|||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue