Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd352431

Browse files
authored
Mark no file with /dev/null to align with git diff (#93)
If you run git diff locally with a staged new file the diff will indicate that the file did not exist before with `--- /dev/null`.I believe this should align with this?
1 parent85c3199 commitd352431

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎java-diff-utils/src/main/java/com/github/difflib/UnifiedDiffUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public final class UnifiedDiffUtils {
3333

3434
privatestaticfinalPatternUNIFIED_DIFF_CHUNK_REGEXP =Pattern
3535
.compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@$");
36+
privatestaticfinalStringNULL_FILE_INDICATOR ="/dev/null";
3637

3738
/**
3839
* Parse the given text in unified format and creates the list of deltas for it.
@@ -143,8 +144,8 @@ public static List<String> generateUnifiedDiff(String originalFileName,
143144
intcontextSize) {
144145
if (!patch.getDeltas().isEmpty()) {
145146
List<String>ret =newArrayList<>();
146-
ret.add("--- " +Optional.ofNullable(originalFileName).orElse(""));
147-
ret.add("+++ " +Optional.ofNullable(revisedFileName).orElse(""));
147+
ret.add("--- " +Optional.ofNullable(originalFileName).orElse(NULL_FILE_INDICATOR));
148+
ret.add("+++ " +Optional.ofNullable(revisedFileName).orElse(NULL_FILE_INDICATOR));
148149

149150
List<AbstractDelta<String>>patchDeltas =newArrayList<>(
150151
patch.getDeltas());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp