Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] 回复:[Internet]Re: A bug in the 'RevWalkUtils.findBranchesReachableFrom' method

I have pushed a new patch[1] to fix this problem.


Hope some one can review it :) .


Regards,

Kyle


[1] https://git.eclipse.org/r/c/jgit/jgit/+/183960


在 2021年8月4日 23:01,Nasser Grainawi<quic_nasserg@xxxxxxxxxxx> 写道:



On Aug 4, 2021, at 8:33 AM, Malyshkin, Denis via jgit-dev <jgit-dev@xxxxxxxxxxx> wrote:

Hello,

Our developers found a bug in the 'RevWalkUtils.findBranchesReachableFrom' method in JGit 5.12. On the second call, this method returns no commits even if commits exist in a repository.

Thanks for reporting this!

@Adithya, could this be related to the optimization done in 176854: Optimize RevWalkUtils.findBranchesReachableFrom() | https://git.eclipse.org/r/c/jgit/jgit/+/176854 ?


Below is a test example to reproduce the bug:
======================================================================
public class App
{
    private static final String REMOTE_URL = "https://github.com/a-golubnichenko/jgit_testing.git";
    private static final String[] COMMIT_IDS = new String[] {
            "edabfa50d9ec3be8026a2f77f94c5b1e074e70bf",
            "a0ab326927445608ee446de30ad076e075634e9f"
    };

    public static void main( String[] args ) throws IOException, GitAPIException {
        // prepare a new folder for the cloned repository
        File localPath = File.createTempFile("TestGitRepository", "");
        if(!localPath.delete()) {
            throw new IOException("Could not delete temporary file " + localPath);
        }

        try {
            // then clone
            System.out.println("Cloning from " + REMOTE_URL + " to " + localPath);
            try (Git result = Git.cloneRepository()
                    .setBare(true)
                    .setURI(REMOTE_URL)
                    .setCloneAllBranches(true)
                    .setCloneSubmodules(true)
                    .setDirectory(localPath)
                    .call()) {
                System.out.println("Having repository: " + result.getRepository().getDirectory());
            }

            try (Repository repository = FileRepositoryBuilder.create(localPath);
                 RevWalk revWalk = new RevWalk(repository)) {
                Collection<Ref> allRefs = repository.getAllRefs().values();
                for (String commitId : COMMIT_IDS) {
                    RevCommit revCommit = revWalk.parseCommit(ObjectId.fromString(commitId));
                    Collection<Ref> refs = RevWalkUtils.findBranchesReachableFrom(revCommit, revWalk, allRefs);
                    System.out.printf("refs.size() = %d for commit <%s> %n", refs.size(), commitId);
                }
            }
        } finally {
            // clean up here to not keep using more and more disk-space for these samples
            FileUtils.deleteDirectory(localPath);
        }
    }
}
======================================================================

And we got the following results:

v.5.12.0.202106070339-r
refs.size() = 4 for commit <edabfa50d9ec3be8026a2f77f94c5b1e074e70bf>
refs.size() = 0 for commit <a0ab326927445608ee446de30ad076e075634e9f>

v.5.11.1.202105131744-r and lower
refs.size() = 4 for commit <edabfa50d9ec3be8026a2f77f94c5b1e074e70bf>
refs.size() = 1 for commit <a0ab326927445608ee446de30ad076e075634e9f>  

This issue is reproduced for v.5.12 only. Should the client code be changed to work with v.5.12 or it is a bug?

We also tested on the latest builds '5.13.0-SNAPSHOT' and '5.12.1-SNAPSHOT'. The bug is reproduced on them either.

Thank you for the help.


--
Best regards,
  Denis Malyshkin,
Senior C++ Developer
of ISS Art, Ltd., Omsk, Russia.
Mobile Phone: +7 913 669 2896
Office tel/fax +7 3812 396959
Yahoo Messenger: dmalyshkin
Web: http://www.issart.com

E-mail: dmalyshkin@xxxxxxxxxx
_______________________________________________
jgit-dev mailing list
jgit-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jgit-dev


Back to the top