Skip to content
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

Patch File doesn't include Unstaged Changes #363

Open
rnveach opened this issue Nov 14, 2022 · 6 comments
Open

Patch File doesn't include Unstaged Changes #363

rnveach opened this issue Nov 14, 2022 · 6 comments

Comments

@rnveach
Copy link
Member

rnveach commented Nov 14, 2022

Not an issue with patch filter itself, but we need documentation on the best way to set up this repo for our users. There is nothing in our readme for this.

Identified when testing #352 , I made changes to the repo but did not commit them. They did not appear in show.patch which wasn't expected.

I test my changes before committing them all the time to ensure I am not committing something bad and losing my original work. I think we should find some way to include unstaged changes as well with the top commit.

Repo's patch file creation: https://github.com/checkstyle/eclipse-cs/blob/master/pom.xml#L125-L131

@romani
Copy link
Member

romani commented Nov 15, 2022

@romani
Copy link
Member

romani commented Dec 1, 2022

Approach above does not work.

Explanation on why it is not working:
https://www.reddit.com/r/git/comments/a8oju0/basic_question_does_git_diff_only_show_the/
https://stackoverflow.com/a/857696

Workaround is to use git add --intent-to-add . so in this case git diff HEAD~0 show new file. But it is sligh effect to user activity, there might be some files user did not plan to add to git at all. Good is that such adding to staging is not full staging, so 'git commit' will not take it.

We suggest to use it and user can decide to use it or not.

@romani
Copy link
Member

romani commented Apr 5, 2023

@rdiachenko , do you know any git commands trick to have new files patch files?

@rdiachenko
Copy link
Collaborator

@rdiachenko , do you know any git commands trick to have new files patch files?

No such a trick. Another option would be to append show.patch with new unstaged files as an additional step before filter execution: git ls-files -o --exclude-standard -x show.patch | xargs -I {} git diff /dev/null {} >> show.patch

It is equivalent to git add . ; git diff --cached --diff-filter=A >> show.patch ; git restore --staged .

@romani
Copy link
Member

romani commented Apr 12, 2023

is there way to put this bash magic to pom.xml and use it ? in real project (eclipse-cs)

@rnveach
Copy link
Member Author

rnveach commented Apr 12, 2023

This would be better if it was also possible to use this on Windows and not just Linux. I am not sure if Windows recognizes /dev/null.

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

No branches or pull requests

3 participants