Skip to content

Diff broken in 1.0.2 #382

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

Closed
Shrews opened this issue Feb 12, 2016 · 8 comments
Closed

Diff broken in 1.0.2 #382

Shrews opened this issue Feb 12, 2016 · 8 comments

Comments

@Shrews
Copy link

Shrews commented Feb 12, 2016

I believe this change breaks diff functionality in 1.0.2:

332521a

Using OS X and git 2.5.4, the generated command puts a space between the diff -U option and its value. This causes an exception as git insists on there being no space between them.

openstack-gerrit pushed a commit to openstack-archive/gertty that referenced this issue Feb 12, 2016
gitpython-developers/GitPython#382

Change-Id: I6d9bdaadb82b6702ffb75245f84637f9795d4e02
@Byron
Copy link
Member

Byron commented Feb 13, 2016

Thanks for getting down to the root of the problem. This change was introduced to solve a particular (and to me unknown) problem, and I am wondering how to solve this issue without introducing breakage for someone else.

When looking at the code, I couldn't find any usage of the -U option described here.

Can you help me to reproduce the problem ?

@Shrews
Copy link
Author

Shrews commented Feb 15, 2016

I believe the U option is being passed as part of the kwargs. Actually experiencing this with a tool called gertty. Here is the line with the diff() call where the crash occurs:

https://github.com/openstack/gertty/blob/master/gertty/gitrepo.py#L390-L391

Also, see new comments in: 332521a

@Byron
Copy link
Member

Byron commented Feb 21, 2016

What about using the respective long option instead, i.e. --unified ? The line in question would then look like this:

extra_contexts, oldc.diff(
     newc, color='never',create_patch=True, unified=context))

@Shrews
Copy link
Author

Shrews commented Feb 21, 2016

Yes, the long option works. Buts that's nothing more than a workaround.

@Byron
Copy link
Member

Byron commented Feb 21, 2016

Great to hear it works ! Where else are you having problems with that particular behaviour of the git executable when used with gitpython ?
To me it seems the issue is fixed, even without having to change defaults that are likely to break other code elsewhere.

@jeblair
Copy link
Contributor

jeblair commented Feb 21, 2016

It might be helpful to know what commit 332521a was attempting to fix. It seems like we have traded something unknown to us being broken for the breakage described in this issue. A quick check of some random diff options suggests that this behavior change will affect not only "-U" in git diff, but also "-C", "-M', and "-B". These are likely to cause GitPython users to run into difficult-to-diagnose problems when they attempt to use these options in their customary form.

With an understanding of what 332521a was fixing, we could evaluate a way forward -- perhaps there is another way to accomplish what was intended there, or perhaps we need to support different behaviors for different git subcommands, or perhaps we need to say that single-char options with arguments are not supported and return a useful error to gitpython users.

@Shrews
Copy link
Author

Shrews commented Feb 25, 2016

Agree with jeblair here. I find it odd to consider it "fixed" by putting the responsibility on users of the library to modify their once-working code.

@Byron
Copy link
Member

Byron commented Feb 27, 2016

Thanks for your feedback !
When looking at #341, it appears that fixing it for one is breaking it for another. Even though a viable solution could be to enforce long options for diff-related commands, I would love to be able to configure this particular flag split_single_char_options on a per-command basis.
That way, the diff implementation could 'fix it by default' and thus prevent the unexpected behaviour experienced here.

Just to unclutter this issue a bit, I would like to move attention to the linked issue, and close this one. In the meanwhile, one could go with the proposed workaround of using long options instead of short ones.

@Byron Byron closed this as completed Feb 27, 2016
openstack-gerrit pushed a commit to openstack-archive/gertty that referenced this issue Mar 10, 2016
GitPython had a very incompatible change that breaks any call that
uses a single character option (e.g., -U) that requires no space
between the option and the value. So far, this breaks the diff API
where we used the -U option instead of the long option equivalent.
For history:

gitpython-developers/GitPython#382

So far, I've only seen one place where this bites gertty. Since the
GitPython author has stated this will not be reverted or fixed, having
a permanent cap on that library seems harsh as we won't get any other
bug fixes.

This fixes the known/found areas where we are affected.

Change-Id: Iadb279234af2ea01fbff35dc629c01dae5a3195c
openstack-gerrit pushed a commit to openstack-archive/gertty that referenced this issue Mar 16, 2016
GitPython had a very incompatible change that breaks any call that
uses a single character option (e.g., -U) that requires no space
between the option and the value. So far, this breaks the diff API
where we used the -U option instead of the long option equivalent.
For history:

gitpython-developers/GitPython#382

So far, I've only seen one place where this bites gertty. Since the
GitPython author has stated this will not be reverted or fixed, having
a permanent cap on that library seems harsh as we won't get any other
bug fixes.

This fixes the known/found areas where we are affected.

Change-Id: Iadb279234af2ea01fbff35dc629c01dae5a3195c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants