From: Stefan Sperling Subject: got merge -c commit progress output To: gameoftrees@openbsd.org Date: Mon, 27 Sep 2021 13:30:51 +0200 Commits performed by 'got merge' do not display progress output because this will usually be redundant output shown for changes merged into the work tree. Consider: $ got merge G alpha Merged refs/heads/newbranch into refs/heads/main: adcde1234... $ The above shows progress for the merge step only. If itr also showed progress output for the commit step, the line 'M alpha' would be added: $ got merge G alpha M alpha Merged refs/heads/newbranch into refs/heads/main: adcde1234... $ Which looks unusual and potentially confusing. However, when a merge is interrupted and continued with merge -c, no more file merges will be performed. The merge -c step only commits changes to the repository. It currently always looks like this: $ got merge -c Merged refs/heads/newbranch into refs/heads/main: adcde1234... $ With the change below, got merge -c displays commit progress output: $ got merge -c M alpha Merged refs/heads/newbranch into refs/heads/main: adcde1234... $ This looks better, and any further changes which resulted from conflict resolution (such as newly added files, or files deleted after the initial merge step) will be displayed in the output, too. ok? diff 088449d31db27c8682d5e9dc737d92d05df6605e /home/stsp/src/got blob - 2ffb4504134f26df40668893df73c7dd07c67e93 file + got/got.c --- got/got.c +++ got/got.c @@ -10814,7 +10814,8 @@ cmd_merge(int argc, char *argv[]) goto done; } else { error = got_worktree_merge_commit(&merge_commit_id, worktree, - fileindex, author, NULL, 1, branch_tip, branch_name, repo); + fileindex, author, NULL, 1, branch_tip, branch_name, + repo, continue_merge ? print_status : NULL, NULL); if (error) goto done; error = got_worktree_merge_complete(worktree, fileindex, repo); blob - 0dcba98cb99b5350473eff9a91f3600e24b7ff91 file + include/got_worktree.h --- include/got_worktree.h +++ include/got_worktree.h @@ -456,7 +456,8 @@ got_worktree_merge_commit(struct got_object_id **new_c struct got_worktree *worktree, struct got_fileindex *fileindex, const char *author, const char *committer, int allow_bad_symlinks, struct got_object_id *branch_tip, const char *branch_name, - struct got_repository *repo); + struct got_repository *repo, + got_worktree_status_cb status_cb, void *status_arg); /* * Complete the merge operation. blob - 0c6b89ce6d761d53511099314379119479ee725e file + lib/worktree.c --- lib/worktree.c +++ lib/worktree.c @@ -5221,6 +5221,9 @@ report_ct_status(struct got_commitable *ct, const char *ct_path = ct->path; unsigned char status; + if (status_cb == NULL) /* no commit progress output desired */ + return NULL; + while (ct_path[0] == '/') ct_path++; @@ -7500,14 +7503,6 @@ merge_commit_msg_cb(struct got_pathlist_head *commitab return NULL; } -static const struct got_error * -merge_status_cb(void *arg, unsigned char status, unsigned char staged_status, - const char *path, struct got_object_id *blob_id, - struct got_object_id *staged_blob_id, struct got_object_id *commit_id, - int dirfd, const char *de_name) -{ - return NULL; -} const struct got_error * got_worktree_merge_branch(struct got_worktree *worktree, @@ -7542,7 +7537,9 @@ got_worktree_merge_commit(struct got_object_id **new_c struct got_worktree *worktree, struct got_fileindex *fileindex, const char *author, const char *committer, int allow_bad_symlinks, struct got_object_id *branch_tip, const char *branch_name, - struct got_repository *repo) + struct got_repository *repo, + got_worktree_status_cb status_cb, void *status_arg) + { const struct got_error *err = NULL, *sync_err; struct got_pathlist_head commitable_paths; @@ -7614,7 +7611,7 @@ got_worktree_merge_commit(struct got_object_id **new_c mcm_arg.branch_name = branch_name; err = commit_worktree(new_commit_id, &commitable_paths, head_commit_id, branch_tip, worktree, author, committer, - merge_commit_msg_cb, &mcm_arg, merge_status_cb, NULL, repo); + merge_commit_msg_cb, &mcm_arg, status_cb, status_arg, repo); if (err) goto done; blob - 38220a83f2af8fc1c889f9271a2cd263cbed1dad file + regress/cmdline/merge.sh --- regress/cmdline/merge.sh +++ regress/cmdline/merge.sh @@ -492,8 +492,12 @@ test_merge_continue() { local merge_commit=`git_show_head $testroot/repo` + echo "M alpha" > $testroot/stdout.expected + echo "D beta" >> $testroot/stdout.expected + echo "A epsilon/new" >> $testroot/stdout.expected + echo "M gamma/delta" >> $testroot/stdout.expected echo -n "Merged refs/heads/newbranch into refs/heads/master: " \ - > $testroot/stdout.expected + >> $testroot/stdout.expected echo $merge_commit >> $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout @@ -1324,8 +1328,9 @@ test_merge_interrupt() { local merge_commit=`git_show_head $testroot/repo` + echo "M alpha" > $testroot/stdout.expected echo -n "Merged refs/heads/newbranch into refs/heads/master: " \ - > $testroot/stdout.expected + >> $testroot/stdout.expected echo $merge_commit >> $testroot/stdout.expected cmp -s $testroot/stdout.expected $testroot/stdout