Don't normalise newlines
This commit is contained in:
parent
355fe4399f
commit
0f5d1b102e
1 changed files with 12 additions and 4 deletions
|
|
@ -22,15 +22,23 @@ def main() -> None:
|
||||||
print("Usage: merge_file.py <mine> <base> <theirs> [output]", file=sys.stderr)
|
print("Usage: merge_file.py <mine> <base> <theirs> [output]", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
mine = Path(args[0]).read_text()
|
# Disable universal newline translation to preserve the original line endings.
|
||||||
base = Path(args[1]).read_text()
|
with Path(args[0]).open(newline="") as file:
|
||||||
theirs = Path(args[2]).read_text()
|
mine = file.read()
|
||||||
|
with Path(args[1]).open(newline="") as file:
|
||||||
|
base = file.read()
|
||||||
|
with Path(args[2]).open(newline="") as file:
|
||||||
|
theirs = file.read()
|
||||||
|
|
||||||
result = reconcile(base, mine, theirs)
|
result = reconcile(base, mine, theirs)
|
||||||
|
|
||||||
if len(args) == 4:
|
if len(args) == 4:
|
||||||
Path(args[3]).write_text(result["text"])
|
with Path(args[3]).open("w", newline="") as file:
|
||||||
|
file.write(result["text"])
|
||||||
else:
|
else:
|
||||||
|
reconfigure = getattr(sys.stdout, "reconfigure", None)
|
||||||
|
if reconfigure is not None:
|
||||||
|
reconfigure(newline="")
|
||||||
print(result["text"], end="")
|
print(result["text"], end="")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue