commit a16d97bdc65b49050d622450d50642fa98eb3cc1 from: Stefan Sperling date: Thu Sep 02 19:19:49 2021 UTC remove ancestry sanity checks from 'got cherrypick' and 'got backout' While these checks might catch usage mistakes the performance overhead of scanning the entire history of the current branch is not worth it. Measurements provided by naddy, cherrypicking 5 commits of OpenBSD's src repository in usr.bin/rsync: Before: 5m50.33s real 4m02.36s user 2m04.41s system After: 1m04.92s real 0m28.24s user 0m36.54s system Further performance improvements could be needed but this is a first step. commit - 243a13f59c19fd9761211d200b68b77f99f6aded commit + a16d97bdc65b49050d622450d50642fa98eb3cc1 blob - 02e13d54951c31a8f0e635a8f07be977d6861681 blob + 15441d50109add43dd64b4368c57680ec2884d50 --- 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 blob + 320079e76201a596af50df73a73eb2d48c3c729d --- 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; @@ -7964,22 +7963,7 @@ cmd_cherrypick(int argc, char *argv[]) } error = got_object_id_str(&commit_id_str, commit_id); 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) @@ -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) {