Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: 'git diff' against files outside a git repo

From: Avery Pennarun <hidden>
Date: 2016-06-15 22:49:37

On Fri, Sep 24, 2010 at 3:30 PM, Elijah Newren [off-list ref] wrote:
On Fri, Sep 24, 2010 at 4:23 PM, Avery Pennarun [off-list ref] wrote:
quoted
I'm interested in using 'git diff' on some files that aren't actually
inside a git repo at all.  Specifically, the --color-words and
--word-diff-regex are really cool and I happen to have a use for them
on files that aren't stored verbatim in git.  As a whole, git's
implementation of diff seems to be the fastest-moving one out there,
so I'd rather use it instead of another random diff implementation.
<snip>
quoted
Is there already a way to get 'git diff' to do this?

If not, would it be sensible to extend git-diff to do comparison
between two outside files?
Isn't this what git diff --no-index ... does?
Aha, that was exactly what I wanted. :)

Oddly, 'git diff file1 file2' *doesn't* work when file1 and file2 are
in a working tree; git tries to diff something, apparently, but I
don't know what.  When you're outside a working tree, it works.  And
your "--no-index" suggestion is what makes it work even when you're in
a working tree.

Thanks to you and Brandon for your help.  I guess I'll try to submit a
patch to the git-diff manpage to make this type of usage more obvious.

Have fun,

Avery
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help