git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Does CVS has a easy way to compare file with its previous version?

From
EREric Raible <raible@gmail.com>
Date
Jul 6, 2009, 23:39 UTC
Message-ID
<279b37b20907061639o6d6c72e7qf7bbc2459c7fc77e@mail.gmail.com>
In-Reply-To
<4A4DA7A5.7020303@gnu.org>
On Thu, Jul 2, 2009 at 11:39 PM, Paolo Bonzini<bonzini@gnu.org> wrote:
Show 13 quoted lines
> On 07/02/2009 08:04 PM, Eric Raible wrote:
>>
>> Isn't the first one incorrect because<file>  needs to be inside the
>> backticks?
>> git diff `git log -2 --pretty=format:%h<file>` --<file>
>>
>> And isn't the replacement incorrect also (the diffs are backwards)?
>> git log --no-merges -p -R -1<file>
>
> Yes and no.
>
> Paolo
>
Are you sure that you didn't mean yes and yes?

As the transcript shows the git-diff form produces a backwards diff. Thus to get the same output git-log needs the -R:

$ git init
$ perl -e 'for (0..10) { print "$_\n" }' > file
$ git add file
$ git commit -minitial
[master (root-commit) 2d451ec] initial
 1 files changed, 11 insertions(+), 0 deletions(-)
 create mode 100644 file
$ sed -e 's/4/four/' < file > file1
$ mv file1 file
$ git commit -a -m'updated'
[master d49613a] updated
 1 files changed, 1 insertions(+), 1 deletions(-)
$ git diff `git log -2 --pretty=format:%h file` -- file
diff --git a/file b/file
index b29b605..b033488 100644
--- a/file
+++ b/file
@@ -2,7 +2,7 @@
 1
 2
 3
-four
+4
 5
 6
 7

$ git log --no-merges -p -1 file
commit d49613a1d16c9ece551f9a52f56f16a3dae8bebc
Author: Eric Raible <raible@nextest.com>
Date:   Mon Jul 6 16:25:29 2009 -0700

    updated

diff --git a/file b/file
index b033488..b29b605 100644
--- a/file
+++ b/file
@@ -2,7 +2,7 @@
 1
 2
 3
-4
+four
 5
 6
 7

$ git log --no-merges -p -R -1 file
commit d49613a1d16c9ece551f9a52f56f16a3dae8bebc
Author: Eric Raible <raible@nextest.com>
Date:   Mon Jul 6 16:25:29 2009 -0700

    updated

diff --git b/file a/file
index b29b605..b033488 100644
--- b/file
+++ a/file
@@ -2,7 +2,7 @@
 1
 2
 3
-four
+4
 5
 6
 7
Previous: Paolo BonziniNext: Paolo Bonzini
Message 8 of 10 in “Does CVS has a easy way to compare file with its previous version?”
  1. dtletmnJun 30, 2009
  2. Andreas EricssonJun 30, 2009
  3. Jakub NarebskiJun 30, 2009
  4. Paolo BonziniJun 30, 2009
  5. Linus TorvaldsJul 1, 2009
  6. Eric RaibleJul 2, 2009
  7. Paolo BonziniJul 3, 2009
  8. Eric RaibleJul 6, 2009
  9. Paolo BonziniJul 7, 2009
  10. dtletmnJul 1, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.