commit 3969253a0514c1e4c685eb413d74cd89f40ecaf0 from: Stefan Sperling date: Sat Mar 07 18:01:44 2020 UTC remove implicit entry update from got_fileindex_entry_alloc(); just alloc commit - ef6337de1aa046d1d1aac4bea349644ba9a0f649 commit + 3969253a0514c1e4c685eb413d74cd89f40ecaf0 blob - 40c3a03eea51d58e838ce146b52aa4381263ec07 blob + 61af7dd7264c91833efaded48290d683fc4500cc --- lib/fileindex.c +++ lib/fileindex.c @@ -125,8 +125,7 @@ got_fileindex_entry_mark_deleted_from_disk(struct got_ const struct got_error * got_fileindex_entry_alloc(struct got_fileindex_entry **ie, - const char *ondisk_path, const char *relpath, uint8_t *blob_sha1, - uint8_t *commit_sha1) + const char *relpath) { size_t len; @@ -147,8 +146,7 @@ got_fileindex_entry_alloc(struct got_fileindex_entry * len = GOT_FILEIDX_F_PATH_LEN; (*ie)->flags |= len; - return got_fileindex_entry_update(*ie, ondisk_path, blob_sha1, - commit_sha1, 1); + return NULL; } void blob - 1291a03d512d49e1f0169f4e72fcb7eface50d89 blob + 88f07eccfa3c94fd5c1e4b81985cf5b7558c9ef2 --- lib/got_lib_fileindex.h +++ lib/got_lib_fileindex.h @@ -105,7 +105,7 @@ mode_t got_fileindex_perms_to_st(struct got_fileindex_ const struct got_error *got_fileindex_entry_update(struct got_fileindex_entry *, const char *, uint8_t *, uint8_t *, int); const struct got_error *got_fileindex_entry_alloc(struct got_fileindex_entry **, - const char *, const char *, uint8_t *, uint8_t *); + const char *); void got_fileindex_entry_free(struct got_fileindex_entry *); struct got_fileindex *got_fileindex_alloc(void); blob - 9f9917254ace14896c27a0a7fc4e35e35c42eb71 blob + 34717c9e490a24f071ea53b060842a699b03a543 --- lib/worktree.c +++ lib/worktree.c @@ -910,10 +910,18 @@ update_blob_fileindex_entry(struct got_worktree *workt update_timestamps); else { struct got_fileindex_entry *new_ie; - err = got_fileindex_entry_alloc(&new_ie, ondisk_path, - path, blob->id.sha1, worktree->base_commit_id->sha1); - if (!err) - err = got_fileindex_entry_add(fileindex, new_ie); + err = got_fileindex_entry_alloc(&new_ie, path); + if (err) + return err; + err = got_fileindex_entry_update(new_ie, ondisk_path, + blob->id.sha1, worktree->base_commit_id->sha1, 1); + if (err) { + got_fileindex_entry_free(new_ie); + return err; + } + err = got_fileindex_entry_add(fileindex, new_ie); + if (err) + got_fileindex_entry_free(new_ie); } return err; } @@ -2198,10 +2206,15 @@ merge_file_cb(void *arg, struct got_blob_object *blob1 a->progress_cb, a->progress_arg); if (err) goto done; - err = got_fileindex_entry_alloc(&ie, - ondisk_path, path2, NULL, NULL); + err = got_fileindex_entry_alloc(&ie, path2); if (err) goto done; + err = got_fileindex_entry_update(ie, ondisk_path, + NULL, NULL, 1); + if (err) { + got_fileindex_entry_free(ie); + goto done; + } err = got_fileindex_entry_add(a->fileindex, ie); if (err) { got_fileindex_entry_free(ie); @@ -2909,10 +2922,14 @@ schedule_addition(void *arg, unsigned char status, uns goto done; } - err = got_fileindex_entry_alloc(&ie, ondisk_path, relpath, NULL, NULL); + err = got_fileindex_entry_alloc(&ie, relpath); if (err) goto done; - + err = got_fileindex_entry_update(ie, ondisk_path, NULL, NULL, 1); + if (err) { + got_fileindex_entry_free(ie); + goto done; + } err = got_fileindex_entry_add(a->fileindex, ie); if (err) { got_fileindex_entry_free(ie); @@ -4291,14 +4308,20 @@ update_fileindex_after_commit(struct got_pathlist_head new_base_commit_id->sha1, !have_staged_files); } else { - err = got_fileindex_entry_alloc(&ie, - ct->ondisk_path, pe->path, ct->blob_id->sha1, - new_base_commit_id->sha1); + err = got_fileindex_entry_alloc(&ie, pe->path); if (err) break; - err = got_fileindex_entry_add(fileindex, ie); - if (err) + err = got_fileindex_entry_update(ie, ct->ondisk_path, + ct->blob_id->sha1, new_base_commit_id->sha1, 1); + if (err) { + got_fileindex_entry_free(ie); + break; + } + err = got_fileindex_entry_add(fileindex, ie); + if (err) { + got_fileindex_entry_free(ie); break; + } } } return err;