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

feat(cmd): add thestrip_newline flag#1423

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

toku-sa-n
Copy link
Contributor

@toku-sa-ntoku-sa-n commentedApr 6, 2022
edited
Loading

This PR adds thestrip_newline flag to theGit.execute method. When this flag is set toTrue, it will trim the trailing\n. The default value isTrue for backward compatibility. Setting it toFalse is helpful for, e.g., thegit show output, especially with the binary file, as the missing\n may 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?

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.
@ByronByron added this to thev3.1.28 - Bugfixes milestoneApr 7, 2022
Copy link
Member

@ByronByron left a comment
edited
Loading

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 :/)

@toku-sa-ntoku-sa-n requested a review fromByronApril 7, 2022 01:25
Copy link
Member

@ByronByron left a 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!

@ByronByron merged commitd5cee4a intogitpython-developers:mainApr 7, 2022
@toku-sa-ntoku-sa-n deleted the strip_newline_option branchApril 7, 2022 02:49
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ByronByronByron approved these changes

Assignees
No one assigned
Labels
None yet
Development

Successfully merging this pull request may close these issues.

git show result misses newline at end of diff
2 participants
@toku-sa-n@Byron

[8]ページ先頭

©2009-2025 Movatter.jp