Commit 0ff8d236625b5d8329e10e9b812cbdef76917ba6

Stefan Sperling 2021-09-28T06:59:08

show commit progress output when 'got merge -c' is used Otherwise no progress output is shown at all with this command. Commit progress output will also display any additional changes which resulted from conflict resolution. ok millert@

diff --git a/got/got.c b/got/got.c
index 2ffb450..f7b2014 100644
--- a/got/got.c
+++ b/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);
diff --git a/include/got_worktree.h b/include/got_worktree.h
index 0dcba98..2402196 100644
--- a/include/got_worktree.h
+++ b/include/got_worktree.h
@@ -456,7 +456,8 @@ got_worktree_merge_commit(struct got_object_id **new_commit_id,
     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.
diff --git a/lib/worktree.c b/lib/worktree.c
index 0c6b89c..2fab187 100644
--- a/lib/worktree.c
+++ b/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 *commitable_paths, char **logmsg,
 	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_commit_id,
     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_commit_id,
 	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;
 
diff --git a/regress/cmdline/merge.sh b/regress/cmdline/merge.sh
index 38220a8..d4e0cb2 100755
--- a/regress/cmdline/merge.sh
+++ b/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