Re: git log --follow doesn't follow a rename over a merge

5 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: git log --follow doesn't follow a rename over a merge

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:29

Jeff King [off-list ref] writes:
On Thu, Jun 16, 2011 at 02:31:02PM +0100, James Blackburn wrote:
quoted
I'm also interested in knowing what incantation I need to give to
actually get history of the file which was previously removed.  e.g. I
know the full path:
   plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java
used to exist, but without --follow, git log returns nothing.
Doesn't:

  git log -- plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java

do that?
If the file emerged in one branch (either the primary or a side branch) in
the past as a failed experiment and then got removed before merging back,
i.e.

   past ---o----o-----o-----o-----o-----o-----o-----o--- now
            \                          /
             o----*----o----o----*----o
                  ^added         ^removed

then the merges are simplified away and you would not see it.

Perhaps simplify-merges option may help.

Re: git log --follow doesn't follow a rename over a merge

From: Jeff King <hidden>
Date: 2016-06-15 22:51:29

On Thu, Jun 16, 2011 at 10:59:23AM -0700, Junio C Hamano wrote:
quoted
Doesn't:

  git log -- plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java

do that?
If the file emerged in one branch (either the primary or a side branch) in
the past as a failed experiment and then got removed before merging back,
i.e.

   past ---o----o-----o-----o-----o-----o-----o-----o--- now
            \                          /
             o----*----o----o----*----o
                  ^added         ^removed

then the merges are simplified away and you would not see it.
Ah, right. The default simplification so often does what I want that I
forget there are cases it can miss.
Perhaps simplify-merges option may help.
This test case shows full-history helping:

-- >8 --
commit() {
  echo $1 >$1 && git add $1 && git commit -m $1
}

git init repo &&
cd repo &&
commit one &&
commit two &&
commit three &&
git checkout -b side HEAD^ &&
commit four &&
commit five &&
git rm five && git commit -m "remove five" &&
commit six &&
git checkout master &&
git merge side &&
echo "==> default log (shows nothing)" &&
git --no-pager log -- five
echo "==> full-history" &&
git --no-pager log --full-history -- five

Re: git log --follow doesn't follow a rename over a merge

From: James Blackburn <hidden>
Date: 2016-06-15 22:51:29

On 16 June 2011 18:59, Junio C Hamano [off-list ref] wrote:
  past ---o----o-----o-----o-----o-----o-----o-----o--- now
           \                          /
            o----*----o----o----*----o
                 ^added         ^removed

then the merges are simplified away and you would not see it.

Perhaps simplify-merges option may help.
Magic, that works!

What I don't get is that I believe the file is removed in the 'merge'
commit 'X', which is reachable from master, not in the feature branch:

 2002 ---o----o-----o-----o-----X-----o-----o-----o--- 2011         (CDT)
                                    /
 2006 ---o----o-----o-----o--   (2009)                                  (DSF)
git log --simplify-merges --oneline -- plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java
2f1c904 [memory] DSDP-DD -> CDT initial commit
5b47187 Migrated DSF and DSF-GDB to the CDT project.
10580b5 Updated copyright statements.
...

So 5b48718 is X, and the file exists in the DSF parent of X: c1e6da2

I think 2f1c904 is entirely wrong too -- it's another graft I've done,
to a different repo, which isn't to do with DSF, and doesn't contain
IBreakpoints.java:
 > git show 2f1c904:plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java
fatal: Path 'plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBreakpoints.java'
does not exist in '2f1c904'

Given the file was removed during my 'merge' graft in commit X,
shouldn't it be visible  in log without --simplify-merges?

Cheers,
James

Re: git log --follow doesn't follow a rename over a merge

From: James Blackburn <hidden>
Date: 2016-06-15 22:51:29

On 16 June 2011 19:15, Jeff King [off-list ref] wrote:
This test case shows full-history helping:
This test shows what I've done:

commit() {
 echo $1 >>$1 && git add $1 && git commit -m $1
}

git init repo
cd repo
commit one
commit two
commit three

git symbolic-ref HEAD refs/heads/newroot
rm *
git rm --cached *
commit four
commit four
commit four
commit four
commit four
commit four
commit five

git checkout master
git merge --no-commit newroot

git mv four four2
commit six
commit four2
commit five

git log --graph --oneline
* 7c4c441 five
* 02a7262 four2
*   6ac2fe0 six
|\
| * d4f5e35 five
| * 350d3e9 four
| * b975d48 four
| * 3bdbf38 four
| * 5b58da8 four
| * 9fb4f59 four
| * a6d1492 four
* b301c9c three
* 38865e2 two
* 9a9c689 one

At this point, only git-blame seems correct:
git blame -- four2
Correct
git log --oneline -- four2
02a7262 four2
6ac2fe0 six
git log --follow --oneline -- four2
02a7262 four2
From the above: I can't log past four2 (without using  blame-log.sh).
git log -- four
 <no output>
git log --follow --oneline -- four
350d3e9 four
b975d48 four
3bdbf38 four
5b58da8 four
9fb4f59 four
a6d1492 four
From above: I can't log four without doing '--follow', and the output
is missing the deletion in the merge commit.

Log of 'five', which hasn't been renamed, looks ok.

James

Re: git log --follow doesn't follow a rename over a merge

From: James Blackburn <hidden>
Date: 2016-06-15 22:51:29

On 16 June 2011 19:41, James Blackburn [off-list ref] wrote:
I think 2f1c904 is entirely wrong too -- it's another graft I've done,
to a different repo, which isn't to do with DSF, and doesn't contain
IBreakpoints.java:
This looks like a bug?   man git-log:
       [--] <path>...
           Show only commits that affect any of the specified paths.
To prevent confusion with options and branch names,
           paths may need to be prefixed with "-- " to separate them
from options or refnames.

git log --graph --oneline
* 6530823 six2
*   05512d0 nine
|\
| * 9917e1c seven
| * 76a230e six
| * a6d7961 six
* f7f43f9 four2
*   94392ac eight
|\
| * 5cf0b04 five
| * 5183657 four
* bd329af three
* 57aafee two
* 3d9ecdf one

git log --simplify-merges --oneline -- four
05512d0 nine
94392ac eight
5183657 four

but the merge commit at 'nine' has nothing to do with that path 'four'.


Reproduction steps:

commit() {
 echo $1 >>$1 && git add $1 && git commit -m $1
}

git init repo
cd repo
commit one
commit two
commit three

git symbolic-ref HEAD refs/heads/newroot
rm *
git rm --cached *
commit four
commit five

git symbolic-ref HEAD refs/heads/newnewroot
rm *
git rm --cached *
commit six
commit six
commit seven

git checkout master
git merge --no-commit newroot

git mv four four2
commit eight
commit four2

git merge --no-commit newnewroot

git mv six six2
commit nine
commit six2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help