show merged commit ID + logmsg upon merge conflict during rebase and histedit This makes it more apparent which commit contained the conflicting change. The new output looks like this: C sys/dev/pci/if_iwm.c 8a98d848a1a5 -> merge conflict: properly modify station queues got: conflicts must be resolved before rebasing can continue
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
diff --git a/got/got.c b/got/got.c
index bae230a..021418d 100644
--- a/got/got.c
+++ b/got/got.c
@@ -5139,6 +5139,35 @@ done:
}
static const struct got_error *
+show_rebase_merge_conflict(struct got_object_id *id, struct got_repository *repo)
+{
+ const struct got_error *err;
+ struct got_commit_object *commit = NULL;
+ char *id_str = NULL, *logmsg = NULL;
+
+ err = got_object_open_as_commit(&commit, repo, id);
+ if (err)
+ return err;
+
+ err = got_object_id_str(&id_str, id);
+ if (err)
+ goto done;
+
+ id_str[12] = '\0';
+
+ err = get_short_logmsg(&logmsg, 42, commit);
+ if (err)
+ goto done;
+
+ printf("%s -> merge conflict: %s\n", id_str, logmsg);
+done:
+ free(id_str);
+ got_object_commit_close(commit);
+ free(logmsg);
+ return err;
+}
+
+static const struct got_error *
show_rebase_progress(struct got_commit_object *commit,
struct got_object_id *old_id, struct got_object_id *new_id)
{
@@ -5586,6 +5615,9 @@ cmd_rebase(int argc, char *argv[])
goto done;
if (rebase_status == GOT_STATUS_CONFLICT) {
+ error = show_rebase_merge_conflict(qid->id, repo);
+ if (error)
+ goto done;
got_worktree_rebase_pathlist_free(&merged_paths);
break;
}
@@ -6761,6 +6793,10 @@ cmd_histedit(int argc, char *argv[])
commit = NULL;
if (rebase_status == GOT_STATUS_CONFLICT) {
+ error = show_rebase_merge_conflict(hle->commit_id,
+ repo);
+ if (error)
+ goto done;
got_worktree_rebase_pathlist_free(&merged_paths);
break;
}
diff --git a/regress/cmdline/rebase.sh b/regress/cmdline/rebase.sh
index 0537513..262922a 100755
--- a/regress/cmdline/rebase.sh
+++ b/regress/cmdline/rebase.sh
@@ -182,6 +182,7 @@ function test_rebase_continue {
echo "modified alpha on branch" > $testroot/repo/alpha
git_commit $testroot/repo -m "committing to alpha on newbranch"
local orig_commit1=`git_show_head $testroot/repo`
+ local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
(cd $testroot/repo && git checkout -q master)
echo "modified alpha on master" > $testroot/repo/alpha
@@ -199,6 +200,9 @@ function test_rebase_continue {
2> $testroot/stderr)
echo "C alpha" > $testroot/stdout.expected
+ echo -n "$short_orig_commit1 -> merge conflict" \
+ >> $testroot/stdout.expected
+ echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
@@ -276,8 +280,6 @@ function test_rebase_continue {
(cd $testroot/repo && git checkout -q newbranch)
local new_commit1=`git_show_head $testroot/repo`
-
- local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
local short_new_commit1=`trim_obj_id 28 $new_commit1`
echo -n "$short_orig_commit1 -> $short_new_commit1" \
@@ -315,6 +317,7 @@ function test_rebase_abort {
echo "modified alpha on branch" > $testroot/repo/alpha
git_commit $testroot/repo -m "committing to alpha on newbranch"
local orig_commit1=`git_show_head $testroot/repo`
+ local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
(cd $testroot/repo && git checkout -q master)
echo "modified alpha on master" > $testroot/repo/alpha
@@ -332,6 +335,9 @@ function test_rebase_abort {
2> $testroot/stderr)
echo "C alpha" > $testroot/stdout.expected
+ echo -n "$short_orig_commit1 -> merge conflict" \
+ >> $testroot/stdout.expected
+ echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
@@ -427,6 +433,7 @@ function test_rebase_no_op_change {
echo "modified alpha on branch" > $testroot/repo/alpha
git_commit $testroot/repo -m "committing to alpha on newbranch"
local orig_commit1=`git_show_head $testroot/repo`
+ local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
(cd $testroot/repo && git checkout -q master)
echo "modified alpha on master" > $testroot/repo/alpha
@@ -444,6 +451,9 @@ function test_rebase_no_op_change {
2> $testroot/stderr)
echo "C alpha" > $testroot/stdout.expected
+ echo -n "$short_orig_commit1 -> merge conflict" \
+ >> $testroot/stdout.expected
+ echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
@@ -499,8 +509,6 @@ function test_rebase_no_op_change {
(cd $testroot/repo && git checkout -q newbranch)
local new_commit1=`git_show_head $testroot/repo`
- local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
-
echo -n "$short_orig_commit1 -> no-op change" \
> $testroot/stdout.expected
echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
@@ -536,6 +544,7 @@ function test_rebase_in_progress {
echo "modified alpha on branch" > $testroot/repo/alpha
git_commit $testroot/repo -m "committing to alpha on newbranch"
local orig_commit1=`git_show_head $testroot/repo`
+ local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
(cd $testroot/repo && git checkout -q master)
echo "modified alpha on master" > $testroot/repo/alpha
@@ -553,6 +562,9 @@ function test_rebase_in_progress {
2> $testroot/stderr)
echo "C alpha" > $testroot/stdout.expected
+ echo -n "$short_orig_commit1 -> merge conflict" \
+ >> $testroot/stdout.expected
+ echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then