How to change command switch

24 views
Skip to first unread message

York Zhao

unread,
Jan 25, 2012, 7:20:03 PM1/25/12
to magit
Hi,

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

York Zhao

unread,
Jan 26, 2012, 10:58:19 AM1/26/12
to magit

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

York Zhao

unread,
Jan 26, 2012, 11:21:59 AM1/26/12
to magit

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

Yann Hodique

unread,
Jan 26, 2012, 11:32:10 AM1/26/12
to York Zhao, magit

(add-to-list 'magit-diff-options "--ignore-space-at-eol") will
probably do what you want

Hope this helps,

Yann.

York Zhao

unread,
Jan 26, 2012, 11:43:23 AM1/26/12
to Yann Hodique, magit
> (add-to-list 'magit-diff-options "--ignore-space-at-eol") will
> probably do what you want
>
> Hope this helps,

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

Yann Hodique

unread,
Jan 26, 2012, 11:51:39 AM1/26/12
to York Zhao, magit

> 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

York Zhao

unread,
Jan 26, 2012, 11:56:40 AM1/26/12
to Yann Hodique, magit
>> 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?
>
> (add-to-list 'magit-diff-options "--ignore-space-at-eol") will
> probably do what you want

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

York Zhao

unread,
Jan 26, 2012, 12:00:11 PM1/26/12
to Yann Hodique, magit
>> 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?
>
> 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.

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

Yann Hodique

unread,
Jan 26, 2012, 12:14:05 PM1/26/12
to York Zhao, magit
>>>>> "York" == York Zhao <gtdpl...@gmail.com> writes:

> 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

York Zhao

unread,
Jan 26, 2012, 12:43:25 PM1/26/12
to Yann Hodique, magit
Yann,

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

PJ Weisberg

unread,
Jan 26, 2012, 1:09:28 PM1/26/12
to Yann Hodique, York Zhao, magit

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

York Zhao

unread,
Jan 26, 2012, 1:19:05 PM1/26/12
to Yann Hodique, magit
> 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.

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

York Zhao

unread,
Jan 26, 2012, 1:28:17 PM1/26/12
to PJ Weisberg, Yann Hodique, magit
>>> 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?
>>
>> (add-to-list 'magit-diff-options "--ignore-space-at-eol") will
>> probably do what you want
>
> 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.

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

Reply all
Reply to author
Forward
0 new messages