diff --git a/hgext/eol.py b/hgext/eol.py --- a/hgext/eol.py +++ b/hgext/eol.py @@ -144,6 +144,8 @@ def hook(ui, repo, node, hooktype, **kwa elif target == "to-crlf" and singlelf.search(data): raise util.Abort(_("%s should not have LF line endings") % f) + # Ignore other rules for this file + break def preupdate(ui, repo, hooktype, parent1, parent2): diff --git a/tests/test-eol-hook.t b/tests/test-eol-hook.t --- a/tests/test-eol-hook.t +++ b/tests/test-eol-hook.t @@ -21,6 +21,7 @@ Create repo $ cat > .hgeol < [patterns] > mixed.txt = BIN + > crlf.txt = CRLF > **.txt = native > EOF $ hg add .hgeol @@ -61,3 +62,29 @@ Create repo adding manifests adding file changes added 2 changesets with 2 changes to 1 files + + $ printf "first\nsecond\nthird\n" > crlf.txt + $ hg add crlf.txt + $ hg commit -m 'LF crlf.txt' + $ hg push ../main + pushing to ../main + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files + error: pretxnchangegroup hook failed: crlf.txt should not have LF line endings + transaction abort! + rollback completed + abort: crlf.txt should not have LF line endings + [255] + + $ printf "first\r\nsecond\r\nthird\r\n" > crlf.txt + $ hg commit -m 'CRLF crlf.txt (fixed)' + $ hg push ../main + pushing to ../main + searching for changes + adding changesets + adding manifests + adding file changes + added 2 changesets with 2 changes to 1 files