Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork966
feat(cmd): add thestrip_newline flag#1423
Merged
Byron merged 5 commits intogitpython-developers:mainfromApr 7, 2022
Merged
Conversation
This commit adds the `strip_newline` flag to the `Git.execute` method.When this flag is set to `True`, it will trim the trailing `\n`. Thedefault value is `True` for backward compatibility. Setting it to`False` is helpful for, e.g., the `git show` output, especially with the binaryfile, as the missing `\n` may invalidate the file.
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks a lot for the fix!
Regarding stdout/stderr:strip_newline might imply a newline is stripped universally, even though it applies tostdout only at the moment.
Maybe it should be calledstrip_newline_in_stdout to be specific while allowing to add a similar flag forstderr when there is a need?
PS: CI had issues but after restarting it the error now seems 'legit' (as it is upset about whitespace :/)
Byron approved these changesApr 7, 2022
Member
Byron left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you, looks great to me!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
This PR adds the
strip_newlineflag to theGit.executemethod. When this flag is set toTrue, it will trim the trailing\n. The default value isTruefor backward compatibility. Setting it toFalseis helpful for, e.g., thegit showoutput, especially with the binary file, as the missing\nmay invalidate the file.Looking at the first some bytes and checking if the output is binary or not is another option to prevent making an invalid binary file. Still, I chose to add a parameter because it is easy to implement, is fully backward compatible, and doesn't add many lines to the source code.
Fixes:#1377
By the way, do we need to handle stderr too?