Re: teach git diff -v/--invert-match?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 22, 2008 at 04:29:31PM -0500, Brian Ericson wrote:

> I was just working on a reply to my own email as I realized it was
> only  dumb-luck that converted 1200 noisy changes into a couple of
> dozen.  "-S" matches only  the string itself, not the line the string
> resides on.  So, -Sxyz will match if  "xyz" itself was added or
> deleted in the diff (if "xyz" is on a line that's changed but  did not
> itself change, it won't match).  Funny that I actually knew this -- I
> use it to look for System.out.println additions among other things.

Yes (though I couldn't have told you that without experimenting -- I
always assumed it checked whole lines).

> Interestingly, if I wanted to know if an import changed (on top of
> knowing if imports were added or deleted), eg: -import foo; +import
> bar;

That is a bit harder, and AFAIK not possible with -S. You could always
post process the log output. E.g.,:

  git log -p | perl -ne '
    BEGIN { $/ = "commit " }
    chomp; print if /^\+import /
  '

which lets you get quite fancy with the matching.

> The current behavior seems to work well to answer questions like "has
> somebody added a System.out.println",

The usual question (for me, anyway) is "when did X get introduced?" when
looking for a token.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux