From: Stefan Sperling Subject: Re: Some random whining To: Christian Weisgerber , gameoftrees@openbsd.org Date: Wed, 1 Sep 2021 17:29:18 +0200 On Wed, Sep 01, 2021 at 05:27:26PM +0200, Stefan Sperling wrote: > On Wed, Sep 01, 2021 at 05:09:06PM +0200, Stefan Sperling wrote: > > On Wed, Sep 01, 2021 at 01:39:47PM +0200, Christian Weisgerber wrote: > > > I'll just whine about some random things I noticed while using got: > > > > > > * "got cherrypick" is slow in a large tree like OpenBSD ports. > > > > This is mostly because of pre-condition checks that run before the actual > > cherrypick operation. It is the cost of running 'got log' on the branch. > > > > I'm aware of this and already tried to find another way to do this but > > could not find any way. The downside of removing the checks would be > > that cherrypick could be used in non-sensical ways between branches > > that aren't related (or against a branch itself). > > On the other hand, experienced users will know how to use it as intended. > > So perhaps the checks could be dropped if the performance benefit > > outweighs the potential usability issues created when someone attempts > > using this command in a non-sensical way. > > Try this patch. > > I'd be fine with this if people prefer performance over sanity checks. Update: We should then also drop the head_ref variable. diff 0e33f8e0becf732ab33b3ce78c026790a651a5f9 /home/stsp/src/got blob - 02e13d54951c31a8f0e635a8f07be977d6861681 file + got/got.1 --- got/got.1 +++ got/got.1 @@ -1582,7 +1582,7 @@ Merge changes from a single into the work tree. The specified .Ar commit -must be on a different branch than the work tree's base commit. +should be on a different branch than the work tree's base commit. The expected argument is a reference or a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. @@ -1626,7 +1626,7 @@ Reverse-merge changes from a single into the work tree. The specified .Ar commit -must be on the same branch as the work tree's base commit. +should be on the same branch as the work tree's base commit. The expected argument is a reference or a commit ID SHA1 hash. An abbreviated hash argument will be expanded to a full SHA1 hash automatically, provided the abbreviation is unique. blob - 51bedeed3942da484d0dfe4614307f848dcbd5ed file + got/got.c --- got/got.c +++ got/got.c @@ -7902,7 +7902,6 @@ cmd_cherrypick(int argc, char *argv[]) struct got_object_id *commit_id = NULL; struct got_commit_object *commit = NULL; struct got_object_qid *pid; - struct got_reference *head_ref = NULL; int ch; struct got_update_progress_arg upa; @@ -7966,21 +7965,6 @@ cmd_cherrypick(int argc, char *argv[]) if (error) goto done; - error = got_ref_open(&head_ref, repo, - got_worktree_get_head_ref_name(worktree), 0); - if (error != NULL) - goto done; - - error = check_same_branch(commit_id, head_ref, NULL, repo); - if (error) { - if (error->code != GOT_ERR_ANCESTRY) - goto done; - error = NULL; - } else { - error = got_error(GOT_ERR_SAME_BRANCH); - goto done; - } - error = got_object_open_as_commit(&commit, repo, commit_id); if (error) goto done; @@ -7999,8 +7983,6 @@ done: if (commit) got_object_commit_close(commit); free(commit_id_str); - if (head_ref) - got_ref_close(head_ref); if (worktree) got_worktree_close(worktree); if (repo) { @@ -8028,7 +8010,6 @@ cmd_backout(int argc, char *argv[]) struct got_object_id *commit_id = NULL; struct got_commit_object *commit = NULL; struct got_object_qid *pid; - struct got_reference *head_ref = NULL; int ch; struct got_update_progress_arg upa; @@ -8091,15 +8072,6 @@ cmd_backout(int argc, char *argv[]) if (error) goto done; - error = got_ref_open(&head_ref, repo, - got_worktree_get_head_ref_name(worktree), 0); - if (error != NULL) - goto done; - - error = check_same_branch(commit_id, head_ref, NULL, repo); - if (error) - goto done; - error = got_object_open_as_commit(&commit, repo, commit_id); if (error) goto done; @@ -8122,8 +8094,6 @@ done: if (commit) got_object_commit_close(commit); free(commit_id_str); - if (head_ref) - got_ref_close(head_ref); if (worktree) got_worktree_close(worktree); if (repo) {