Skip to content

Overzealous commits when using git add --patch #9

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
bogwonch opened this issue Feb 26, 2016 · 2 comments
Closed

Overzealous commits when using git add --patch #9

bogwonch opened this issue Feb 26, 2016 · 2 comments

Comments

@bogwonch
Copy link

When using git add --patch commit-comments from outside the current patch are added to the commit message and all commit tags are removed, not just those from the current patch.

For example, say I have the following diff of a file in my repo:

 #! /usr/bin/env python

+#@commit greeting alice
+print("Hi Alice")
+
 print("Hello World")
+
+#@commit say goodbye
+print("Goodbye World")

I add the first hunk using git add --patch, but ignore the second hunk.
The commit message I get is:

 - [test.py#3] greeting alice
 - [test.py#8] say goodbye

And after removing the commit-comments the file looks like:

#! /usr/bin/env python

print("Hi Alice")

print("Hello World")

print("Goodbye World")

The correct behaviour should be for the commit message to be:

 - [test.py#3] greeting alice

And the file to be:

#! /usr/bin/env python

print("Hi Alice")

print("Hello World")

#@commit say goodbye
print("Goodbye World")

(Loving the tool by-the-way!)

@bogwonch
Copy link
Author

Can see you're working on it as part of issue #1.
Apologies for the noise.

@jryio
Copy link
Owner

jryio commented Feb 26, 2016

No this is not noise at all!

I will make a pull request for this right away. Having not heavily used git add --patch myself, I appreciate the detail and correct output you provided.

The overarching plan was to use git diff --cached --name-status --diff-filter=ACM to only inspect Added, Created, or Modified files. However, that doesn't resolve the --patch issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants