Skip to content

Commit fb4ced9

Browse files
rgrinbergLeonidas-from-XIV
authored andcommitted
fix: revert --diff-command behavior (#14098)
Pass non-existent files and directories to the --diff-command Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
1 parent 945d733 commit fb4ced9

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

doc/changes/fixed/14098.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Revert the change in behavior of `--diff-command` back to 3.21. Non-existent
2+
files are now passed to this command instead of being replaced with /dev/null
3+
(#14098, fixes 13891, @rgrinberg)

src/dune_engine/print_diff.ml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ let prepare_with_labels
177177
(Path.to_string_maybe_quoted (Path.drop_optional_sandbox_root path2))
178178
])
179179
in
180-
let path1 = noent_to_dev_null path1 in
181-
let path2 = noent_to_dev_null path2 in
182180
match !Clflags.diff_command with
183181
| Some "-" -> fallback
184182
| Some cmd ->
@@ -213,17 +211,28 @@ let prepare_with_labels
213211
| None -> fallback
214212
| Some diff -> With_fallback.run diff ~fallback
215213
in
214+
let builtin_path1 = noent_to_dev_null path1 in
215+
let builtin_path2 = noent_to_dev_null path2 in
216216
let diff =
217-
External.diff ~skip_trailing_cr ~dir promotion loc (label1, path1) (label2, path2)
217+
External.diff
218+
~skip_trailing_cr
219+
~dir
220+
promotion
221+
loc
222+
(label1, builtin_path1)
223+
(label2, builtin_path2)
218224
in
219225
if Execution_env.inside_dune
220226
then or_fallback ~fallback diff
221227
else (
222228
let fallback =
223-
Option.first_some (External.git ~skip_trailing_cr promotion loc path1 path2) diff
229+
Option.first_some
230+
(External.git ~skip_trailing_cr promotion loc builtin_path1 builtin_path2)
231+
diff
224232
|> or_fallback ~fallback
225233
in
226-
External.patdiff ~dir promotion loc path1 path2 |> or_fallback ~fallback)
234+
External.patdiff ~dir promotion loc builtin_path1 builtin_path2
235+
|> or_fallback ~fallback)
227236
;;
228237

229238
let prepare ~skip_trailing_cr promotion path1 path2 =

test/blackbox-tests/test-cases/promote/non-existent-dir.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dune promote should be able to promote into directories that don't exist
1818

1919
$ dune build ./foo --diff-command "$SHELL $PWD/diff.sh"
2020
File "dir/foo", line 1, characters 0-0:
21-
a: /dev/null
21+
a: dir/foo
2222
b: foo
2323
[1]
2424

0 commit comments

Comments
 (0)