# How to compare different files in different branches

10 messages from 2008-06-06 to 2008-06-16. Participants: Nico -telmich- Schottelius, Jonathan del Strother, Jakub Narebski, Teemu Likonen, Junio C Hamano, Ask Bjørn Hansen, Frederik Dohr.
Thread: https://gitlist.dev/t/13831

## Nico -telmich- Schottelius, 2008-06-06 12:24

Subject: How to compare different files in different branches
Message-ID: <20080606122421.GA1521@denkbrett.schottelius.org>
URL: https://gitlist.dev/e/20080606122421.GA1521%40denkbrett.schottelius.org

```
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, 2008-06-06 12:30

Subject: Re: How to compare different files in different branches
Message-ID: <57518fd10806060530k7a15f79fh1823afef2a747233@mail.gmail.com>
URL: https://gitlist.dev/e/57518fd10806060530k7a15f79fh1823afef2a747233%40mail.gmail.com
In-Reply-To: <20080606122421.GA1521@denkbrett.schottelius.org>

```
On Fri, Jun 6, 2008 at 1:24 PM, Nico -telmich- Schottelius
<nico-git-20080606@schottelius.org> wrote:
> 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, 2008-06-06 12:34

Subject: Re: How to compare different files in different branches
Message-ID: <m3skvqyc78.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3skvqyc78.fsf%40localhost.localdomain
In-Reply-To: <20080606122421.GA1521@denkbrett.schottelius.org>

```
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

```

## Teemu Likonen, 2008-06-06 12:35

Subject: Re: How to compare different files in different branches
Message-ID: <20080606123539.GA3119@mithlond.arda.local>
URL: https://gitlist.dev/e/20080606123539.GA3119%40mithlond.arda.local
In-Reply-To: <20080606122421.GA1521@denkbrett.schottelius.org>

```
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.

```

## Jakub Narebski, 2008-06-06 12:38

Subject: Re: How to compare different files in different branches
Message-ID: <m3od6eyc0s.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3od6eyc0s.fsf%40localhost.localdomain
In-Reply-To: <m3skvqyc78.fsf@localhost.localdomain>

```
Jakub Narebski <jnareb@gmail.com> writes:

> 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

```

## Nico -telmich- Schottelius, 2008-06-08 09:47

Subject: Re: How to compare different files in different branches
Message-ID: <20080608094754.GB1521@denkbrett.schottelius.org>
URL: https://gitlist.dev/e/20080608094754.GB1521%40denkbrett.schottelius.org
In-Reply-To: <20080606123539.GA3119@mithlond.arda.local>

```
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]:
> 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, 2008-06-08 09:51

Subject: Re: How to compare different files in different branches
Message-ID: <7v1w38l0el.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1w38l0el.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20080608094754.GB1521@denkbrett.schottelius.org>

```
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, 2008-06-15 01:49

Subject: Re: How to compare different files in different branches
Message-ID: <3E23E92E-37E7-4076-9277-0E1002EC196F@develooper.com>
URL: https://gitlist.dev/e/3E23E92E-37E7-4076-9277-0E1002EC196F%40develooper.com
In-Reply-To: <7v1w38l0el.fsf@gitster.siamese.dyndns.org>

```

On Jun 8, 2008, at 2:51, Junio C Hamano wrote:

>> 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, 2008-06-16 12:21

Subject: git-svn breaks svn when adding .svn
Message-ID: <20080616122117.GA14292@denkbrett.schottelius.org>
URL: https://gitlist.dev/e/20080616122117.GA14292%40denkbrett.schottelius.org
In-Reply-To: <7v1w38l0el.fsf@gitster.siamese.dyndns.org>

```
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, 2008-06-16 16:09

Subject: Re: git-svn breaks svn when adding .svn
Message-ID: <af6c748e0806160909t1e6dd22exf8e6d6c47215ec80@mail.gmail.com>
URL: https://gitlist.dev/e/af6c748e0806160909t1e6dd22exf8e6d6c47215ec80%40mail.gmail.com
In-Reply-To: <200806161603.05166.thomas@koch.ro>

```
> 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.

```
