Commit b50cabdf52fb94fec7e3d01b074c4dc3f144b372

Stefan Sperling 2019-07-12T16:36:21

skip out-of-dateness check during rebase for faster commits

diff --git a/lib/worktree.c b/lib/worktree.c
index 9ac24a5..a62e681 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -3260,13 +3260,6 @@ commit_worktree(struct got_object_id **new_commit_id,
 	if (err)
 		goto done;
 
-	TAILQ_FOREACH(pe, commitable_paths, entry) {
-		struct got_commitable *ct = pe->data;
-		err = check_ct_out_of_date(ct, repo, head_commit_id);
-		if (err)
-			goto done;
-	}
-
 	err = got_object_open_as_tree(&head_tree, repo, head_commit->tree_id);
 	if (err)
 		goto done;
@@ -3424,6 +3417,13 @@ got_worktree_commit(struct got_object_id **new_commit_id,
 		goto done;
 	}
 
+	TAILQ_FOREACH(pe, &commitable_paths, entry) {
+		struct got_commitable *ct = pe->data;
+		err = check_ct_out_of_date(ct, repo, head_commit_id);
+		if (err)
+			goto done;
+	}
+
 	err = commit_worktree(new_commit_id, &commitable_paths,
 	    head_commit_id, worktree, ondisk_path, author, committer,
 	    commit_msg_cb, commit_arg, status_cb, status_arg, repo);
@@ -3787,7 +3787,6 @@ got_worktree_rebase_commit(struct got_object_id **new_commit_id,
 	const struct got_error *err, *sync_err;
 	struct got_pathlist_head commitable_paths;
 	struct collect_commitables_arg cc_arg;
-	struct bump_base_commit_id_arg bbc_arg;
 	struct got_fileindex *fileindex = NULL;
 	char *fileindex_path = NULL, *commit_ref_name = NULL;
 	struct got_reference *head_ref = NULL;
@@ -3860,21 +3859,9 @@ got_worktree_rebase_commit(struct got_object_id **new_commit_id,
 
 	err = update_fileindex_after_commit(&commitable_paths, *new_commit_id,
 	    fileindex);
-	if (err == NULL) {
-		/* Prevent out-of-date error when rebasing more commits. */
-		bbc_arg.base_commit_id = *new_commit_id;
-		bbc_arg.entry_name = NULL;
-		bbc_arg.path = "";
-		bbc_arg.path_len = 0;
-		bbc_arg.progress_cb = NULL;
-		bbc_arg.progress_arg = NULL;
-		err = got_fileindex_for_each_entry_safe(fileindex,
-		    bump_base_commit_id, &bbc_arg);
-	}
 	sync_err = sync_fileindex(fileindex, fileindex_path);
 	if (sync_err && err == NULL)
 		err = sync_err;
-
 done:
 	if (fileindex)
 		got_fileindex_free(fileindex);