Let merge-file write out conflict markers with correct EOLs
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest2 patches 1 replyIn review
- v42 patches 7 repliesSuperseded
- v32 patches 6 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 1 patch | 9 replies | Superseded | |
| v1 | 2 patches | 18 replies | Superseded |
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | merge-file: let conflict markers match end-of-line style of the contextt/ xdiff/ | +69 | 0 replies | |
| 2/2 | merge-file: ensure that conflict sections match eol stylet/ xdiff/ | +25 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.
Cover letter [PATCH v5 0/2] Let merge-file write out conflict markers with correct EOLs
The original patch was sent by Beat Bolli in
http://thread.gmane.org/gmane.comp.version-control.git/281600
My suggestion to extend it to respect gitattributes led to changes that broke the original patch. And they were misguided to begin with (see below).
Since there have been a couple of "What's cooking" mails containing unheard calls for updates on this patch, I took it on myself to fix things.
Junio's comment that we might look at blobs containing CR/LF line endings made me rethink the entire approach, and I am now convinced that we need to abandon the entire idea to make the conflict markers depend on config settings or attributes:
after all, I introduced git merge-file as a replacement for GNU merge that can be used *outside* of any repository, by design.
The crucial idea hit me yesterday when I took a step back: all we need to do is to ensure that the end-of-line style is matched when *all* input files are LF-only, or when they are all CR/LF. In all other cases, we have mixed line endings anyway.
And to do that, it is sufficient to look at *one single line ending* in the context. Technically, it does not even have to be the context, but the first line endings of the first file would be enough, however it is so much more pleasant if the conflict marker's eol matches the one of the preceding line.
To prevent my future self from repeating mistakes, I added a little bit of background to the first commit message.
Triggered by a comment by Junio, I realized that a second patch is
needed: we need to make sure that the conflicting sections are also augmented by the appropriate line endings if they lack any.
The change relative to v4 is that I now test the correct conflict
markers: the merge-file call we add to t6023 actually produces four conflict markers because a previous test switched the conflict style to diff3 mode. This is only a side effect, though, therefore I really wanted to avoid testing for it. However, I managed to test an *incorrect* subset of three, but this is now fixed. Thanks go to Ramsay Jones for poking my nose onto that issue.
Johannes Schindelin (2):
merge-file: let conflict markers match end-of-line style of the
context
merge-file: ensure that conflict sections match eol style
t/t6023-merge-file.sh | 13 +++++++ xdiff/xmerge.c | 98 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 93 insertions(+), 18 deletions(-)
Interdiff vs v4:
diff --git a/t/t6023-merge-file.sh b/t/t6023-merge-file.sh
index 1390548..20aee43 100755
--- a/t/t6023-merge-file.sh
+++ b/t/t6023-merge-file.sh
@@ -352,11 +352,11 @@ test_expect_success 'conflict sections match existing line endings' '
printf "1\\r\\n2\\r\\n5" >crlf-diff2.txt &&
test_must_fail git -c core.eol=crlf merge-file -p \
crlf-diff1.txt crlf-orig.txt crlf-diff2.txt >crlf.txt &&
- test $(tr "\015" Q <crlf.txt | grep "\\.txtQ$" | wc -l) = 3 && + test $(tr "\015" Q <crlf.txt | grep "^[<=>].*Q$" | wc -l) = 3 && test $(tr "\015" Q <crlf.txt | grep "[345]Q$" | wc -l) = 3 &&
test_must_fail git -c core.eol=crlf merge-file -p \
nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >nolf.txt &&
- test $(tr "\015" Q <nolf.txt | grep "\\.txtQ$" | wc -l) = 0
+ test $(tr "\015" Q <nolf.txt | grep "^[<=>].*Q$" | wc -l) = 0
'
test_done
Signature · 1 line
2.7.0.windows.1.7.g55a05c8