threads / discuss / 13831

How to compare different files in different branches

Subject: How to compare different files in different branches

## tl;dr

10 messages between Jun 6, 2008 and Jun 16, 2008.

replies: 9people: 8as markdown or json

Nico -telmich- Schottelius· Jun 6, 2008, 12:24 UTC · lore
Hello!

I want to compare 'configure.in' from the master branch with 'configure.ac' from the gpm-2-dev branch.

What I tried:

% git-diff master..gpm-2-dev configure.ac fatal: ambiguous argument 'configure.ac': unknown revision or path not in the working tree. Use '--' to separate paths from revisions

# ok, correct, there is no configure.ac in master # But not what I want.

% git-diff master..gpm-2-dev configure.in

# shows that the file does not exist in gpm-2-dev. Correct. # But not what I want.

Strange ist: % git-diff --summary master...gpm-2-dev and % git-diff --stat master...gpm-2-dev do not show the rename.

But using
% git log -Sconfigure gpm-2-dev
I find the rename in commit 5fe49d36d775af47c08bb9a0c0beabef609bba20.
Now I could do 
% git-checkout master configure.in

in the gpm-2-dev branch and manually compare it with diff. But - you guessed it - is not what I want.

I really think git can do that, but currently I do not see the right way. So any idea on how to do that?

Sincerly
Nico
P.S.: Please cc on reply.
-- 
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C
Jonathan del Strother· Jun 6, 2008, 12:30 UTC · re: Nico -telmich- Schottelius · lore

Re: How to compare different files in different branches

On Fri, Jun 6, 2008 at 1:24 PM, Nico -telmich- Schottelius <nico-git-20080606@schottelius.org> wrote:

Show 20 quoted lines
> Hello!
>
> I want to compare 'configure.in' from the master branch with
> 'configure.ac' from the gpm-2-dev branch.
>
> What I tried:
>
> % git-diff master..gpm-2-dev configure.ac
> fatal: ambiguous argument 'configure.ac': unknown revision or path not
> in the working tree.
> Use '--' to separate paths from revisions
>
> # ok, correct, there is no configure.ac in master
> # But not what I want.
>
> % git-diff master..gpm-2-dev configure.in
>
> # shows that the file does not exist in gpm-2-dev. Correct.
> # But not what I want.
>
How about git diff master:configure.in gm-2-dev:configure.ac ?
Jakub Narebski· Jun 6, 2008, 12:34 UTC · re: Nico -telmich- Schottelius · lore

Re: How to compare different files in different branches

Nico -telmich- Schottelius <nico-git-20080606@schottelius.org> writes:
> I want to compare 'configure.in' from the master branch with
> 'configure.ac' from the gpm-2-dev branch.
[...]
> I really think git can do that, but currently I do not see the right
> way. So any idea on how to do that?
 $ git diff master:configure.in gpm-2-dev:configure.ac

See "Specifying revisions" in git-rev-list(1); I think it can be also found in other places, but I'm not sure. git-show(1) refers to this section when describing <object> option.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Jakub Narebski· Jun 6, 2008, 12:38 UTC · re: Jakub Narebski · lore

Re: How to compare different files in different branches

Jakub Narebski <jnareb@gmail.com> writes:
Show 9 quoted lines
> Nico -telmich- Schottelius <nico-git-20080606@schottelius.org> writes:
> 
> > I want to compare 'configure.in' from the master branch with
> > 'configure.ac' from the gpm-2-dev branch.
> [...]
> > I really think git can do that, but currently I do not see the right
> > way. So any idea on how to do that?
> 
>  $ git diff master:configure.in gpm-2-dev:configure.ac
 $ git diff -M master gpm-2-dev -- configure.in configure.ac
should also work.
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Teemu Likonen· Jun 6, 2008, 12:35 UTC · re: Nico -telmich- Schottelius · lore

Re: How to compare different files in different branches

Nico -telmich- Schottelius wrote (2008-06-06 14:24 +0200):
> I want to compare 'configure.in' from the master branch with
> 'configure.ac' from the gpm-2-dev branch.
You could do:
  $ git diff master:configure.in gpm-2-dev:configure.ac
In general form it means:
  $ git diff <commit1>:<path1> <commit2>:<path2>
You can also view directories and files similar way:
  $ git show <commit>:<path>

And <commit> can be anything that refers to a commit, e.g. a branch name, a tag, SHA1 or a relative pointer like master^2~5.

Nico -telmich- Schottelius· Jun 8, 2008, 09:47 UTC · re: Teemu Likonen · lore

Re: How to compare different files in different branches

Thank you all for your fast answers!

I must confess I've overseen -M, as I saw --no-renames and searched for --renames.

Teemu Likonen [Fri, Jun 06, 2008 at 03:35:39PM +0300]:
Show 6 quoted lines
> Nico -telmich- Schottelius wrote (2008-06-06 14:24 +0200):
> [...]
> In general form it means:
> 
>   $ git diff <commit1>:<path1> <commit2>:<path2>
> [...]

Very nice syntax, somehow guessed that this is available, but didn't try... my fault.

Perhaps we should reference git-rev-list(1) from git-diff(1), too?
Sincerly
Nico
-- 
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C
Junio C Hamano· Jun 8, 2008, 09:51 UTC · re: Nico -telmich- Schottelius · lore

Re: How to compare different files in different branches

Nico -telmich- Schottelius <nico-git-20080606@schottelius.org> writes:
> Very nice syntax, somehow guessed that this is available, but didn't
> try... my fault. 
>
> Perhaps we should reference git-rev-list(1) from git-diff(1), too?

This is just the standard syntax to name blob _anywhere_, so we should not hide it in git-rev-list(1) but somewhere people would read before reading any "technical manual" material, perhaps in the tutorial and git(1).

Ask Bjørn Hansen· Jun 15, 2008, 01:49 UTC · re: Junio C Hamano · lore

Re: How to compare different files in different branches

On Jun 8, 2008, at 2:51, Junio C Hamano wrote:
Show 7 quoted lines
>> Perhaps we should reference git-rev-list(1) from git-diff(1), too?
>
> This is just the standard syntax to name blob _anywhere_, so we  
> should not
> hide it in git-rev-list(1) but somewhere people would read before  
> reading
> any "technical manual" material, perhaps in the tutorial and git(1).

+1! A "how to specify files and revisions" tutorial with tips, tricks and examples would be great.

Since it's much more powerful in git than in other SCMs, this is one of the larger bits of things to learn.

  - ask
-- 
http://develooper.com/ - http://askask.com/
Nico -telmich- Schottelius· Jun 16, 2008, 12:21 UTC · re: Junio C Hamano · lore

git-svn breaks svn when adding .svn

Hello dear git list!

The following information was submitted to me by Frederik and is forwarded to the list, because he's no mail access right now:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Using "git-svn dcommit", files or folders named ".svn" can be committed to the Subversion repository.
This breaks the SVN repo - e.g. "svn update" results in the following error:
    svn: Failed to add directory '.svn': object of the same name already exists
Ideally, the SVN server would reject such a commit.
However, if I interpret the following issues correctly, Subversion doesn't want to handle this server-side:
    http://subversion.tigris.org/issues/show_bug.cgi?id=1068
    (also: http://subversion.tigris.org/issues/show_bug.cgi?id=1065)

Since this is potentially a very critical issue, I suggest git-svn dcommit check and filter for such occurrences. Alternatively, a prominent warning could be added to the relevant git-svn commands.

Details:
    git version 1.5.4.3
    svn version 1.4.6 (r28521)
    Plattform: Ubuntu 8.04 Hardy Heron
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Sincerly
Nico
PS: Please CC him and me on reply.
-- 
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C
Frederik Dohr· Jun 16, 2008, 16:09 UTC · lore

Re: git-svn breaks svn when adding .svn

> I've reported the exact same problem on 18.04.08 under the subject: "git svn
> should refuse to checkin .svn directories"

Sorry about that - I did search the archives before having this posted, but that didn't come up with anything (the search functionality is quite limited though).

>> [...] Add this as the
>> pre-commit hook in .git/hooks (make sure to make it executable).

Not a bad idea - but this still requires manual intervention (and thus awareness), which doesn't solve the potential destructiveness of this issue.

> The Git website seems to be currently down, but one of us should search, if
> there is a Bugtracker for GIT and then open an issue for this.

The website is up again. However, there doesn't seem to be a dedicated bug tracking tool.

-- F.

← back to recent threads