got patch: use status G for merged files (and document it) Suggested by stsp@. This makes possible to tell if 'got patch' used a merge-base from the repository for the 3-way merge or did a simple search/replace operation. While here update the tests to look for the 'G' status and the manpage, which was also missing the documentation for the 'C' status in got patch. ok stsp@
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
diff --git a/got/got.1 b/got/got.1
index 9d65d8a..6e54669 100644
--- a/got/got.1
+++ b/got/got.1
@@ -1333,6 +1333,8 @@ contains multiple patches, then attempt to apply each of them in sequence.
Show the status of each affected file, using the following status codes:
.Bl -column XYZ description
.It M Ta file was modified
+.It G Ta file was merged using a merge-base found in the repository
+.It C Ta file was merged and conflicts occurred during merge
.It D Ta file was deleted
.It A Ta file was added
.It # Ta failed to patch the file
diff --git a/lib/patch.c b/lib/patch.c
index 1fc82c6..965f860 100644
--- a/lib/patch.c
+++ b/lib/patch.c
@@ -777,6 +777,8 @@ apply_patch(int *overlapcnt, struct got_worktree *worktree,
unlink(newpath);
} else if (*overlapcnt != 0)
err = report_progress(pa, old, new, GOT_STATUS_CONFLICT, NULL);
+ else if (do_merge)
+ err = report_progress(pa, old, new, GOT_STATUS_MERGE, NULL);
else
err = report_progress(pa, old, new, GOT_STATUS_MODIFY, NULL);
diff --git a/regress/cmdline/patch.sh b/regress/cmdline/patch.sh
index 5d79b58..9fb1dd3 100755
--- a/regress/cmdline/patch.sh
+++ b/regress/cmdline/patch.sh
@@ -1482,9 +1482,18 @@ test_patch_merge_simple() {
fi
(cd $testroot/wt && got patch $testroot/old.diff) \
- 2>&1 > /dev/null
+ > $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done $testroot $ret
+ return 1
+ fi
+
+ echo 'G numbers' > $testroot/stdout.expected
+ cmp -s $testroot/stdout $testroot/stdout.expected
ret=$?
if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout $testroot/stdout.expected
test_done $testroot $ret
return 1
fi
@@ -1539,7 +1548,7 @@ test_patch_merge_conflict() {
fi
(cd $testroot/wt && got patch $testroot/old.diff) \
- >/dev/null 2>&1
+ > $testroot/stdout 2>/dev/null
ret=$?
if [ $ret -eq 0 ]; then
echo "got patch merged a diff that should conflict" >&2
@@ -1547,6 +1556,15 @@ test_patch_merge_conflict() {
return 1
fi
+ echo 'C numbers' > $testroot/stdout.expected
+ cmp -s $testroot/stdout $testroot/stdout.expected
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout $testroot/stdout.expected
+ test_done $testroot $ret
+ return 1
+ fi
+
# XXX: prefixing every line with a tab otherwise got thinks
# the file has conflicts in it.
cat <<-EOF > $testroot/wt/numbers.expected