Fixes all deprecated API usage in libs.jgit and update gitignore IO code#7093
Fixes all deprecated API usage in libs.jgit and update gitignore IO code#7093mbien merged 2 commits intoapache:masterfrom
Conversation
one test fails, the bug is in |
1cf5b77 to
124c4db
Compare
| // git commit timestamp resolution is one second. | ||
| // commits with the same time stamp don't seem to influence log order unless branches | ||
| // change between commits. In that case the branch name is also affecting the order. | ||
| // (renaming "newbranch" to "aaa" would fix this too but obfuscate the problem) | ||
| Thread.sleep(1100); |
There was a problem hiding this comment.
this resolves the encountered test failure. (#7093 (comment))
matthiasblaesing
left a comment
There was a problem hiding this comment.
Looks sane to me. I only found a single location where I think the behavior changed.
ide/libs.git/src/org/netbeans/libs/git/jgit/commands/ListBranchCommand.java
Outdated
Show resolved
Hide resolved
124c4db to
e02c519
Compare
e02c519 to
74791e4
Compare
|
refreshed PR, testing this a bit manually and if I don't find anything I will merge once green again |
|
added an extra commit which renovates git ignore/unignore IO code |
| StringBuilder sb = new StringBuilder('/'); | ||
| StringBuilder sb = new StringBuilder(); |
There was a problem hiding this comment.
this did set the capacity of the SB. The char was cast to int. The code did still work though since it didn't need that slash.
Would it be possible to detect the line end character of the file and use that on save? I observe, that using the Ignore/Unignore action in NetBeans currently leads to many of my |
|
@matthiasblaesing I take a look |
ff8ea3a to
da74685
Compare
| @SuppressWarnings("NestedAssignment") | ||
| private static String probeLineSeparator(Path file) throws IOException { | ||
| if (Files.exists(file)) { | ||
| try (BufferedReader br = Files.newBufferedReader(file)) { | ||
| int current; | ||
| int last = -1; | ||
| while ((current = br.read()) != -1) { | ||
| if (current == '\n') { | ||
| return last == '\r' ? "\r\n" : "\n"; | ||
| } | ||
| last = current; | ||
| } | ||
| } | ||
| } | ||
| return rules; | ||
| return System.lineSeparator(); |
There was a problem hiding this comment.
@matthiasblaesing could you check if this works for you?
It probes before save and uses the probed result for write. System default as fallback.
- code renovation - file specific line separators are now retained between updates - added tests
da74685 to
2983c0f
Compare
|
added tests + refreshed PR |
matthiasblaesing
left a comment
There was a problem hiding this comment.
I was not able to test this at work on Windows, but I tested locally the opposite situation: A .gitignore file with windows line endings on linux. The implementation also looks sane to me.
Thank you!
first commit:
libs.jgit:))second commit:
I tested (stepped through it) some of it manually: list/switch branches, list/add/remove tags
lets see what tests say