-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Display specific message if diff is not displayed because of too long line #15611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display specific message if diff is not displayed because of too long line #15611
Conversation
Codecov Report
@@ Coverage Diff @@
## master #15611 +/- ##
==========================================
- Coverage 43.89% 43.82% -0.07%
==========================================
Files 678 678
Lines 81878 81881 +3
==========================================
- Hits 35941 35886 -55
- Misses 40087 40153 +66
+ Partials 5850 5842 -8
Continue to review full report at Codecov.
|
Tested, did not work for me with this file because I think there is a off-by-one error in the code. So the code initializes a reader readerSize := maxLineCharacters
input := bufio.NewReaderSize(reader, readerSize) This reader is passed to lineBytes, isFragment, err = input.ReadLine()
line := string(lineBytes)
if len(line) > maxLineCharacters { I think we need to use cc: @zeripath |
Co-authored-by: silverwind <[email protected]>
Thanks for the test. readerSize := maxLineCharacters
if readerSize < 4096 {
readerSize = 4096
} else {
readerSize++
} If the line's length is superior to maxLineCharacters we get the new message. |
agh sorry I had thought that the OP had tried this so just looked at the proposed PR and thought it looked alright. |
Right we want to look at how too long a line could cause IsIncomplete set. So the easiest thing to do is to look at all the places where IsIncomplete is set and see why that would occur: gitea/services/gitdiff/gitdiff.go Lines 713 to 714 in ca0460b
This is due to maxFiles - so this one is fine. gitea/services/gitdiff/gitdiff.go Lines 935 to 944 in ca0460b
This one is due to a line that is so long that it is larger than the buffer can buffer. So this is one that needs to have the IncompleteLine flag set. gitea/services/gitdiff/gitdiff.go Lines 961 to 964 in ca0460b
gitea/services/gitdiff/gitdiff.go Lines 997 to 1000 in ca0460b
gitea/services/gitdiff/gitdiff.go Lines 1012 to 1015 in ca0460b
gitea/services/gitdiff/gitdiff.go Lines 1027 to 1029 in ca0460b
gitea/services/gitdiff/gitdiff.go Lines 1042 to 1045 in ca0460b
these are too many lines - so is fine. gitea/services/gitdiff/gitdiff.go Lines 1063 to 1073 in ca0460b
This one is due to a line that is so long that it is larger than the buffer can buffer. So this is one that needs to have the IncompleteLine flag set. gitea/services/gitdiff/gitdiff.go Lines 1074 to 1077 in ca0460b
This is a line that although less than the buffer is still too long for the maxLineCharacters setting so it needs the flag. @Loutro there are therefore two other places you need to set this flag - which I have set in 263f33c |
Signed-off-by: Andrew Thornton <[email protected]>
I've just pushed those two missing cases up to your branch. @silverwind please feel free to test again. |
@zeripath , If i understand well, The cases you added are useful if you are in error because you will never go on this check: If there is no error in reading the file, the solution i provided works.
|
Current solution works for me now with my test case. |
@Loutro I don't think you need that change - I don't understand how it is supposed to help. |
it help because on the condition below, your len(line) is maxLineCharacters + 1 if line too long. Has i previously said, If the line's length is superior to maxLineCharacters we get the new message. I tested it and it worked for the test case of @silverwind. But your solution seems ok, and perhap's seems cleaner to you. |
If file diff incomplete because one line is too long, display specific message
Fix #7184