fix(commit): make object hashes branch aware and thus dont error status out
This commit is contained in:
parent
42b8858558
commit
fae8489871
5 changed files with 45 additions and 15 deletions
12
src/object.c
12
src/object.c
|
|
@ -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) {
|
||||
int save_diff(ActionList* diff, char* path, char* root, size_t diff_id, char* basefile_hash, char* branch) {
|
||||
size_t buffer_size = 41;
|
||||
|
||||
buffer_size += 1 + snprintf(NULL, 0, "%d", diff->len);
|
||||
|
|
@ -204,10 +204,16 @@ 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);
|
||||
size_t id_len = snprintf(NULL, 0, "%s %zu %s", path, diff_id, branch) + 1;
|
||||
char* id = calloc(id_len, sizeof(char));
|
||||
if (!id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
snprintf(id, id_len, "%s %zu %s", path, diff_id, branch);
|
||||
char hash[41];
|
||||
object_hash(FileDiffObject, id, hash);
|
||||
free(id);
|
||||
|
||||
char dir_path[PATH_MAX];
|
||||
char file_path[PATH_MAX];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue