Commit 3969253a0514c1e4c685eb413d74cd89f40ecaf0

Stefan Sperling 2020-03-07T19:01:44

remove implicit entry update from got_fileindex_entry_alloc(); just alloc

diff --git a/lib/fileindex.c b/lib/fileindex.c
index 40c3a03..61af7dd 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -125,8 +125,7 @@ got_fileindex_entry_mark_deleted_from_disk(struct got_fileindex_entry *ie)
 
 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 **ie,
 		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
diff --git a/lib/got_lib_fileindex.h b/lib/got_lib_fileindex.h
index 1291a03..88f07ec 100644
--- a/lib/got_lib_fileindex.h
+++ b/lib/got_lib_fileindex.h
@@ -105,7 +105,7 @@ mode_t got_fileindex_perms_to_st(struct got_fileindex_entry *);
 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);
diff --git a/lib/worktree.c b/lib/worktree.c
index 9f99172..34717c9 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -910,10 +910,18 @@ update_blob_fileindex_entry(struct got_worktree *worktree,
 		    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, unsigned char staged_status,
 		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 *commitable_paths,
 				    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_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)
+			if (err) {
+				got_fileindex_entry_free(ie);
 				break;
+			}
 		}
 	}
 	return err;
diff --git a/regress/cmdline/histedit.sh b/regress/cmdline/histedit.sh
old mode 100744
new mode 100755
diff --git a/regress/cmdline/ref.sh b/regress/cmdline/ref.sh
old mode 100744
new mode 100755