]> source.dussan.org Git - jgit.git/commit
Correctly handle initialization of shallow commits 64/125064/3
authorTerry Parker <tparker@google.com>
Tue, 26 Jun 2018 23:44:01 +0000 (16:44 -0700)
committerTerry Parker <tparker@google.com>
Wed, 27 Jun 2018 03:13:47 +0000 (20:13 -0700)
commit115a740e2fa65d3ab70f150691b045ecfdb146bb
treea305a363901e9d79437353fa74a120aa4aa32577
parente8e4fe7af674baf13acd074f7207d7e6758d0ec6
Correctly handle initialization of shallow commits

In a new RevWalk, if the first object parsed is one of the
shallow commits, the following happens:
1) RevCommit.parseCanonical() is called on a new "r1" RevCommit.
2) RevCommit.parseCanonical() immediately calls
   RevWalk.initializeShallowCommits().
3) RevWalk.initializeShallowCommits() calls lookupCommit(id),
   creating and adding a new "r2" version of this same object and
   marking its parents empty.
4) RevCommit.parseCanonical() initializes the "r1" RevCommit's
   fields, including the parents.
5) RevCommit.parseCanonical()'s caller uses the "r1" commit that
   has parents, losing the fact that it is a shallow commit.

This change passes the current RevCommit as an argument to
RevWalk.initializeShallowCommits() so that method can set its
parents empty rather than creating the duplicate "r2" commit.

Change-Id: I67b79aa2927dd71ac7b0d8f8917f423dcaf08c8a
Signed-off-by: Terry Parker <tparker@google.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkShallowTest.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevCommit.java
org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java