How can I change the "git diff" command used by magit? More specifically,
somebody committed a huge set of files to repository with crlf line ending. So
when I check diff in magit, everything is different now making it impossible to
see the real difference. I don't want to rewrite the history to fix this in the
repository, instead, I want to pass "--ignore-space-at-eol" to "git diff". I
have tried this on command line and it works. But how can I tell magit to use
this option when it sends "git diff" to git?
Thanks in advance,
York
Can anybody tell me where Magit send git commands? Maybe because I was in a
hurry and didn't find it, partly because Magit used lots of macro. If you know,
please simply tell me the function name. At the same time I will search a bit
more before having to head to rewriting git history which would have to cause
some inconvenience to other developers.
Thanks,
York
OK, found it, it's `magit-run'. But still the question, do I have to hack at
this level, or, is there any simple way to modify the arguments?
Thanks,
York
(add-to-list 'magit-diff-options "--ignore-space-at-eol") will
probably do what you want
Hope this helps,
Yann.
Hi Yann,
Thank you very much for the help, I'm going to try this right away. By the way,
I set edebugger breakpoint in `magit-run*' but it never gets stop there, do you
have some idea of why?
Thanks,
York
> Hi Yann,
in general, magit doesn't use `magit-run*' for populating sections, but
`magit-cmd-insert'. So depending on what command you want to watch, you
might want to break there.
Yann.
--
There are weapons you cannot hold in your hand.
You can only hold them in your mind.
-- Bene Gesserit Teaching
Just tried, doesn't work. The following are steps of what I was doing:
M-x magit -> l -> L -> n -> -> n
Then I got the "diff" output in other window, which shows everything is
different, of course most of the difference are CRLF difference, suck!!!
What appeared strange to me is that it seems that magit never called "git diff"
to get this "diff". Can anybody tell me what I'm missing here?
Thanks,
York
Hi Yann,
Sorry I didn't see this reply while I was writing my previous post. Thanks a lot
and I'm going try it.
York
> Just tried, doesn't work. The following are steps of what I was doing:
> M-x magit -> l -> L -> n -> -> n
> Then I got the "diff" output in other window, which shows everything is
> different, of course most of the difference are CRLF difference, suck!!!
> What appeared strange to me is that it seems that magit never called "git diff"
> to get this "diff". Can anybody tell me what I'm missing here?
What you see here is the output of git log for this commit, not a git
diff of any kind. See `magit-refresh-commit-buffer'.
Unfortunately, there's currently no way to inject custom flags there,
without modifying the function.
Yann.
--
There exists no separation between gods and men:
one blends softly casual into the other.
-- Proverbs of Muad'dib
Thanks a lot for the help, saved me a lot of time to dig, really appreciated.
> What you see here is the output of git log for this commit, not a git
> diff of any kind. See `magit-refresh-commit-buffer'.
> Unfortunately, there's currently no way to inject custom flags there,
> without modifying the function.
Yes, and I have just figured this out actually, and I found that the command
being sent out for the "diff" was actually:
"git log --max-count=1 --pretty=medium --no-abbrev-commit --decorate=full --cc
-p <commit>"
I will see what I can do on this, not sure whether there is any option in git to
control "diff" in "log" command.
Thanks,
York
Caveat: Commands that operate on hunks or regions won't work if the
diff output doesn't match what's actually in the file. Magit might
also tell you that you have modified files without telling you what
they are.
If it wasn't for that, this would already be a configurable option.
-PJ
OK, so finally this works:
"git log --max-count=1 --pretty=medium --no-abbrev-commit --decorate=full --cc
-p <path> --ignore-space-at-eol"
The question is, however, is it a good idea to make this configurable in Magit?
Thanks,
York
Is it a good idea then, to make this a switch and bind to a key in that buffer
to toggle "--ignore-space-at-eol" on the fly?
Thanks,
York