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

Add an output_nostrip kwarg to Git.execute#77

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

Closed
znerol wants to merge2 commits intogitpython-developers:masterfromznerol:feature/master/cmd-output-nostrip
Closed

Add an output_nostrip kwarg to Git.execute#77

znerol wants to merge2 commits intogitpython-developers:masterfromznerol:feature/master/cmd-output-nostrip

Conversation

znerol
Copy link

The last line of the output normally is stripped if it is empty. Ifoutput_nostrip isTrue, this behavior is disabled. This can be important when constructing patches e.g. using thediff command.

The last line of the output normally is stripped if it is empty. Ifoutput_nostrip is True, this behavior is disabled. This can be importantwhen constructing patches e.g. using the diff command.
@Byron
Copy link
Member

Thanks for the fix.
One thing that you might consider changing is the double-negation. Thus you could call the parameteroutput_strip and default it totrue.
As you have created the fix to make diff work better, it wold be great to have a test case which verifies this functionality.

@znerol
Copy link
Author

One thing that you might consider changing is the double-negation.

I tried this but it does not feel right for me. IMHOGit.execute should somehow behave like invoking a command line tool. Many cli tools have--no-xy-style options to turn off features which normally are turned on. Just take a look at some randomman-pages (e.g.man man). Maybe it's just me but I think the double negation works better in this case.

I try to come up with some test cases.

@Byron
Copy link
Member

Thanks for the unit test, its much appreciated.

Besides that, I don't think one can compare a CLI with an API. The--no-* or--disable-* options might also be paired with--enable-* or--* counterparts. Those usually set nothing more than a flag to true or false which is then handled in code.

In APIs I consider it bad practice to negate something in the first place, and then have double-negations in the code likeif not no_strip. Its much nicer to have to have thestrip option with a True default value, and then check withif strip: in code.

@znerol
Copy link
Author

Following up in#79

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@znerol@Byron

[8]ページ先頭

©2009-2025 Movatter.jp