-
Notifications
You must be signed in to change notification settings - Fork 335
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
Git add --patch does not use diff-so-fancy #35
Comments
Someone else pinged me about this a month ago. I'm not sure. Based on https://github.com/git/git/blob/master/git-add--interactive.perl#L747-L768 it doesn't look good. But i'd love to be proven wrong. There's a lot of mention of color in here, so there may be SOME configurability, but not sure if we can intercept with a pager or something. |
There's some other people who were poking around this: http://www.nickcoding.com/2014/10/30/making-git-prose-friendly/ .. which my unveil some solutions. |
Thanks for the swift response @paulirish, would it be worth leaving this issue open or do you think we should close it? |
Leave it open. It still requires some research to see if it's possible or not. |
👍 was just going to add the same issue |
|
As @danielcompton pointed out, |
The solution here appears to be to fork I don't see a cleaner way to configure this. |
We could open a feature request to git itself and see if we could get a config for this? |
Yup, we'll need to get this supported upstream in git core first. @peff I think you're the right person to help us out. First of all, thank you. This project has been a big success mostly due to your work on diff-highlight. You can read the above issue for context, but it appears we are lacking support in git-core for a key area. We'd like to propose, I think, that |
Please forgive me for asking the obvious - I'm sure others have a firmer grasp of it than I do - but perhaps it's best to get a note of it anyway. Does a configurable pager make sense for For example, most have pager set to Ultimately this would mean that whether interactive or not, |
@OJFord Yeah you're right. It's not a pager, but just a hook to pipe the diff output somewhere. It does seem like the value is mostly for diff formatting tools. yup. |
@paulirish Yes, I think what you're asking for makes sense. I don't use The infrastructure is already there to have "diffs to apply" versus "diffs to show the user" (that's how we do the color stuff). It assumes there's a 1:1 correlation in lines between the two versions of the diff (which is certainly true for I think you'd basically just need to pipe the colorized |
I just sent http://article.gmane.org/gmane.comp.version-control.git/287659 to the list. Not well tested, but it works for me. You can also fetch it from the |
An update here: @peff put up a patch on the git mailing list (thank you, btw! so perfect). and it's now been merged into git's next branch. commit: git/git@0114384 When it's available in git's master, folks can try things with If anyone wants to try it now, they can build git from the |
@paulirish You're welcome. I'll be interested to hear whether diff-so-fancy users run into problems with things like hunk-splitting. The colorization code in |
@peff thanks for implementing this for interactive adds; from what you've seen in the code base, does it seem possible to relatively easily implement for interactive commits, e.g. thanks again! |
@megalithic I'm not quite sure what you mean. If you mean The |
@peff i built git from the I'm doing [interactive]
diffFilter = "tail -n 3" But I'm seeing full headers, lines of context for each prompt. Any suggestions? |
@paulirish I assume Either install it (with |
ah thanks. That sounds like the ticket. will try. |
It works! ... however it looks like we're getting an error..
it could very likely be however we're handling the output. cc @scottchiefbaker .. you can see the hunk headers are a bit confused: (on the left i'm using |
The problem is that git doesn't actually re-parse the filtered output (nor would you want it to, since it doesn't understand your fancy output). It just assumes that line 1 of the diff corresponds to line 1 of the filtered output, and so on. The diff header has 4 lines ( I think you'll need to output an extra line somewhere in the fancy header to match git. Note that git's diffs can actually vary a little, too, depending on whether there is other data like renames, and possibly with mode changes, too. So you may want to actually count the number of lines to the first hunk, output your header, and then insert the appropriate amount of filler. |
Is there a way to make an offset somehow? Or even fake it? |
Considering the number of respondents on this issue I figured we'd have some more testers. I haven't heard anything from anyone about this issue. Has anyone tested this fix with |
I'm testing it since your last message (8 days ago), works fine for me. 👍 |
Same as @dorian-marchal. Have been testing over the last week, and it works as advertised. No problems yet. |
I've been testing the
I'm using Git 2.29.2 on macOS with Thank @wren @scottchiefbaker and everyone that made |
@wvega-godaddy I wasn't aware of the If anyone else has some time to test this before then, please go ahead, and let me know whatever change the PR needs. |
@wvega-godaddy Actually, nevermind. After sending my last comment, I realized that I already knew the problem, so I went ahead an pushed a new commit. Give it a shot and see if that fixes your problem. The problem was that--because I didn't know about |
@wren thank you so much for the quick reply! I checked out your branch and the error is gone using that version 🎉 I accidentally got the error again when I attempted to add an empty file, but there is not point in using I can now do |
Some really cool person fixed so-fancy/diff-so-fancy#35 so we can all use our favorite git pager in patch mode. 🎉
Some really cool person fixed so-fancy/diff-so-fancy#35 so we can all use our favorite git pager in patch mode. 🎉
I'm going to close this issue because I just released v.1.4.0 which should address this. If issues come up related to |
Please update the fat-packed versions as well! |
FYI macos users: the Homebrew version is here :) |
Really nice, thanks so much to everyone that put in hard work here! Should the Git configuration / setup of the |
@nthapaliya I don't maintain the fatpack version anymore because so few people use it. It's pretty easy to clone the whole repo and use it directly so the fatpacked version wasn't the best use of my time. That said I did a one-off and updated the release to include a fatpacked binary just for you. It will probably be the last time though. The code to build a fatpacked version is in |
Is a |
I believe @paulirish handles those? |
Hey @paulirish and/or @stevemao! 👋🏻 What would it take to get a 1.4.2 NPM package out the door? Anything any of us can do to help? 👼🏻 |
This is a hacky workaround for the issue below, but it works with all the test cases I could come up with so far. I'll try to get a perl version of this fix merged upstream soon, but need to sit with this for a bit until I'm fully convinced all the various edge cases work. so-fancy/diff-so-fancy#35
Some really cool person fixed so-fancy/diff-so-fancy#35 so we can all use our favorite git pager in patch mode. 🎉
Due to issue [so-fancy/diff-so-fancy#35](1) [1]:so-fancy/diff-so-fancy#35
I am seeing the Is this a possible regression? |
diff-so-fancy does not work on `git add -p`, but delta does. There had been a long discussion on the --patch issue in diff-so-fancy[0] and the problems there, happen during git add, too. Some commits [1] are referencing this issue. Here it got replaced with delta. After some checks, it seems to work fine and much better than diff-so-fancy. [0] so-fancy/diff-so-fancy#35 [1] arcticicestudio/igloo@4815419
It drops this error message: fatal: mismatched output from interactive.diffFilter hint: Your filter must maintain a one-to-one correspondence hint: between its input and output lines. See so-fancy/diff-so-fancy#35
Hi
Not sure if this is the correct place for this issue.
Just started using this npm package and it's great, it makes reading diffs in my terminal great.
However when I use
git add --patch
it uses the old style diff to display each chunk that's about to be staged.Is
git add --patch
not supposed to usediff
under the hood, which is nowdiff-so-fancy
?Is there anything we can do to use
diff-so-fancy
withgit add --patch
?Thanks
The text was updated successfully, but these errors were encountered: