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

Support excluding files/directories in the method Commit.diff #1260

Answered by Byron
dclong asked this question in Q&A
Discussion options

The method Commit.diff supports a paths parameter to limit diff to specified paths. However, it is more convenient sometimes to exclude files/directories. And since this feature is supported by the git command, it makes to support excluding files/directories in the method Commit.diff.

You must be logged in to vote

Did you try to use **kwargs which will be passed to the git diff command directly? Invocations would look like repo.head.commit.diff(diff_filter='a').

Replies: 1 comment 3 replies

Comment options

Did you try to use **kwargs which will be passed to the git diff command directly? Invocations would look like repo.head.commit.diff(diff_filter='a').

You must be logged in to vote
3 replies
Comment options

If I want to explicitly exclude one file/folder from the git diff, I can get this via the CLI using git diff <SHA> ':(exclude)path/to/exclude' as suggested in https://stackoverflow.com/a/39943727.

How can I achieve this with git.diff since the exclude in not a named parameter. Hence I don't know what to specify for the **kwargs

Comment options

Currently there is no support for using **kwargs for unnamed git flags, unfortunately excluding the suggested use case.
It's certainly possible to allow settings unnamed git flags through **kwargs with a set of special names, maybe like git_arg_01="value".

Comment options

Thanks for your answer. It shomehow pointed me into the right direction. It just works via *args. So git.diff(<SHA>, ":(exclude)path/to/exclude") did it.

Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #1259 on May 31, 2021 00:01.

AltStyle によって変換されたページ (->オリジナル) /