[Privoxy-devel] git: how2 show diff for one specific change?

Lee ler762 at gmail.com
Sat Mar 10 05:07:31 UTC 2018


That was very helpful -- thank you!!

On 3/9/18, Brian Mahaffy <bmahaffy at cradlepoint.com> wrote:
> You can get a diff of the specific changes from a particular SHA with the
> following command.  Lets use SHA 12345678 in the example.

and you find the SHA using some variation on 'git log' or are there
other commands?
(I haven't used git before, so I know zip about it)

> git diff 12345678^ 12345678
>
> What you asked for there was for Git to diff the SHA _one_ previous
> (indicated with the ‘^’ after the SHA) with the original SHA.

ok

> Here’s an example from the repo:
> $ git diff 8b27fea8^ 8b27fea8

  <.. snip example ..>

> If you add the following to your ~/.gitconfig file, you can use any visual
> diff tool you would like.

I like winmerge, which is a windows program, but I'm using git in
cygwin so a bit of extra fiddling is required to change the paths to
something a windows program can understand; this seems to do the
trick:

$ cat ~/.gitconfig
[diff]
    tool = winmerge

[difftool]
    prompt = false

[difftool "winmerge"]
    name = WinMerge
    trustExitCode = true
    cmd = "/cygdrive/c/myprogs/winmerge/winmergeu.exe" /u /e \
          /dl \"prev: $MERGED\" /dr \"curr: $MERGED\" \
          $(cygpath -wla $LOCAL) $(cygpath -wla $REMOTE)

> To use the visual diff tool that previous Git diff command would become:
>
> git difftool 12345678^ 12345678

sweet :)
git diff
  does normal output to the terminal, allowing redirection
git difftool
  opens up winmerge with the old & new files

> If you just want to see what files changed and how for a change, then the
> command becomes:
>
> git diff —raw 12345678^ 12345678

Cool.  'git log --raw' doesn't always show what files changed.  eg:
$ git log --raw
commit 5ca85857b093434ddf9327de6688cce4b611c688 (HEAD -> lee)
Author: Lee <ler762@
Date:   Fri Mar 9 10:50:51 2018 -0500

    remove trailing spaces

:100644 100644 ec7ff263 8ee6dd89 M      w32.rc

commit 152bbff18ff8b3451535c3da616ae7138a3d8a15
Merge: 59ad8ed8 451adf5e
Author: Lee <ler762@
Date:   Fri Mar 9 10:05:43 2018 -0500

    Merge branch 'master' into lee
    pick up all the changes removing cvs id tags

commit 451adf5e77554240efa778fc2e52e5d5b52c2059 (origin/master,
origin/HEAD, master)
Author: Fabian Keil <fk@
Date:   Fri Mar 9 13:08:50 2018 +0100

    Remove Id tag

so for what all changed when I merged the updated master into my playpen:
$ git diff --raw 152bbff18ff8b3451535c3da616ae7138a3d8a15^
152bbff18ff8b3451535c3da616ae7138a3d8a15
:100644 100644 7320850b 6249de9e M      actions.c
:100644 100644 c7b89b3c af401766 M      actions.h
:100644 100644 984ca86d 7a6fa2be M      amiga.c
:100644 100644 6745cc70 82a5cf00 M      amiga.h
:100644 100644 8a4eea0c 22601760 M      cgi.c
:100644 100644 be1dbf7b ba858d25 M      cgi.h
:100644 100644 4579b35b 750015cf M      cgiedit.c
   <.. snip ..>

and
$ git diff -U6 152bbff18ff8b3451535c3da616ae7138a3d8a15^ \
   152bbff18ff8b3451535c3da616ae7138a3d8a15 >| /tmp/diff

to review the changes

> There are some excellent Git books available for free out there.  I’d start
> with this one: https://git-scm.com/book/en/v2 for getting your introduction
> to things.

I started with
  https://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
which seems a bit easier for a total noob

Thanks
Lee


More information about the Privoxy-devel mailing list