aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/MergeBaseGenerator.java
Commit message (Collapse)AuthorAgeFilesLines
* [errorprone] Fix error pattern JdkObsoleteMatthias Sohn2024-04-291-2/+3
| | | | | | See https://errorprone.info/bugpattern/JdkObsolete Change-Id: Id105e2695eb64523bd217f507bf95f909bc6b348
* Add the ability to override parents on RevCommit.Ronald Bhuleskar2022-08-021-2/+2
| | | | | | | | | | | | | | | | | | | This makes RevCommit extensible to allow having different structure of child-parent relationship. This change is a pre-requsite for having a FilteredRevCommit that overrides parents from the RevCommit. That then provides a cheaper way to walk over a subset of RevCommits instead of an expensive way that applies filters while walking over selected commits. Useful with Blame which works on a single file and that can be made performant, if we know all the commits needed by the Blame algorithm. So Blame algorithm can avoid walking over finding what commits to blame on. This change makes parents field on RevCommit private and exposes it thrrough overrideable methods such as getParents, getParent at index, getParentCount and setParents. All other files other than RevCommit are updating the usages of accessing RevCommits parents. Change-Id: I2d13b001c599cc4ebc92d1ab6e07b07acb3b7fe5
* Update EDL 1.0 license headers to new short SPDX compliant formatMatthias Sohn2020-01-041-38/+5
| | | | | | | | | | This is the format given by the Eclipse legal doc generator [1]. [1] https://www.eclipse.org/projects/tools/documentation.php?id=technology.jgit Bug: 548298 Change-Id: I8d8cabc998ba1b083e3f0906a8d558d391ffb6c4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* RevWalk: Add a setFirstParent that mimics C git's --first-parentDave Borowitz2019-06-271-1/+2
| | | | | | | | | | | | | RevWalk does not currently provide a --first-parent equivalent and the feature has been requested. Add a field to the RevWalk class to specify whether walks should traverse first parents only. Modify Generator implementations to support the feature. Change-Id: I4a9a0d5767f82141dcf6d08659d7cb77c585fae4 Signed-off-by: Dave Borowitz <dborowitz@google.com> Signed-off-by: Alex Spradlin <alexaspradlin@google.com>
* Remove further unnecessary 'final' keywordsHan-Wen Nienhuys2018-05-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove it from * package private functions. * try blocks * for loops this was done with the following python script: $ cat f.py import sys import re import os def replaceFinal(m): return m.group(1) + "(" + m.group(2).replace('final ', '') + ")" methodDecl = re.compile(r"^([\t ]*[a-zA-Z_ ]+)\(([^)]*)\)") def subst(fn): input = open(fn) os.rename(fn, fn + "~") dest = open(fn, 'w') for l in input: l = methodDecl.sub(replaceFinal, l) dest.write(l) dest.close() for root, dirs, files in os.walk(".", topdown=False): for f in files: if not f.endswith('.java'): continue full = os.path.join(root, f) print full subst(full) Change-Id: If533a75a417594fc893e7c669d2c1f0f6caeb7ca Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* Remove 'final' in parameter listsHan-Wen Nienhuys2018-05-151-1/+1
| | | | | Change-Id: Id924f79c8b2c720297ebc49bf9c5d4ddd6d52547 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
* Fix stack overflow in MergeBaseGeneratorShawn Pearce2017-05-021-31/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some repository topologies can cause carryOntoHistory to overflow the thread stack, due to its strategy of recursing into the 2nd+ parents of a merge commit. This can easily happen if a project maintains a local fork, and frequently pulls from the upstream repository, which itself may have a branchy history. Rewrite the carryOntoHistory algorithm to use a fixed amount of thread stack, pushing the save points onto the heap. By using heap space the thread stack depth is no longer a concern. Repositories are instead limited by available memory. The algorithm is now structured as two loops: carryOntoHistory: This outer loop pops saved commits off the top of the stack, allowing the inner loop algorithm to dive down that path and carry bits onto commits along that part of the graph. The loop ends when there are no more stack elements. carryOntoHistoryInner: The inner loop walks along a single path of the graph. For a string of pearls (commits with one parent each) r <- s <- t <- u the algorithm walks backwards from u to r by iteratively updating its local variable 'c'. This avoids heap allocation along a simple path that does not require remembering state. The inner loop breaks in the HAVE_ALL case, when all bits have been found to be previously set on the commit. This occurs when a prior iteration of the outer loop (carryOntoHistory) explored a different path to this same commit, and copied the bits onto it. When the inner loop encounters a merge commit, it pushes all parents onto the heap based stack by allocating individual CarryStack elements for each parent. Parents are pushed in order, allowing side branches to be explored first. A small optimization is taken for the last parent, avoiding pushing it and instead updating 'c', allowing the side branch to be entered without allocating a CarryStack. Change-Id: Ib7b67d90f141c497fbdc61a31b0caa832e4b3c04
* Enable and fix warnings about redundant specification of type argumentsDavid Pursehouse2017-02-201-1/+1
| | | | | | | | | | Since the introduction of generic type parameter inference in Java 7, it's not necessary to explicitly specify the type of generic parameters. Enable the warning in Eclipse, and fix all occurrences. Change-Id: I9158caf1beca5e4980b6240ac401f3868520aad0 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Fix merge-base calculationChristian Halstrick2016-11-281-10/+33
| | | | | | | | | | | | | | | | | | | | Fix JGits merge-base calculation in case of inconsistent commit times. JGit was potentially failing to compute correct merge-bases when the commit times where inconsistent (a parent commit was younger than a child commit). The code in MergeBaseGenerator was aware of the fact that sometimes the discovery of a merge base x can occur after the parents of x have been seen (see comment in #carryOntoOne()). But in the light of inconsistent commit times it was possible that these parents of a merge-base have already been returned as a merge-base. This commit fixes the bug by buffering all commits generated by MergeBaseGenerator. It is expected that this buffer will be small because the number of merge-bases will be small. Additionally a new flag is used to mark the ancestors of merge-bases. This allows to filter out the unwanted commits. Bug: 507584 Change-Id: I9cc140b784c3231b972bd2c3de61a789365237ab
* ObjectReader: remove the walkAdvice APIShawn Pearce2015-05-101-1/+0
| | | | | | | | | | | | This was added a very long time ago to support the failed DHT storage implementation. Since then no storage system was able to make use of this API, but it pollutes internals of the walkers. Kill the API on ObjectReader and drop the invocations from the walker code. Change-Id: I36608afdac13a6c3084d7c7e0af5e0cb22900332
* Move JGitText to an internal packageRobin Rosenberg2012-03-121-1/+1
| | | | Change-Id: I763590a45d75f00a09097ab6f89581a3bbd3c797
* RevWalk: Don't release during inMergeBase()Shawn O. Pearce2011-02-241-1/+0
| | | | | | | | | | In bc1af8459e ("RevWalk: Don't reset ObjectReader when stopping") we stopped releasing the reader when the current log traversal is over. This should have also been applied to the merge base logic that is buried within MergeGenerator, but got missed. Change-Id: I8328f43f02cba06fd545e22134872e781b9d4d36 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Offer ObjectReaders advice about a RevWalkShawn O. Pearce2010-08-201-0/+1
| | | | | | | | | | | By giving the reader information about the roots of a revision traversal, some readers may be able to prefetch information from their backing store using background threads in order to reduce data access latency. However this isn't typically necessary so the default reader implementation doesn't react to the advice. Change-Id: I72c6cbd05cff7d8506826015f50d9f57d5cda77e Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Use ObjectReader in RevWalk, TreeWalkShawn O. Pearce2010-06-281-1/+1
| | | | | | | | | | | | | We don't actually need a Repository object here, just an ObjectReader that can load content for us. So change the API to depend on that. However, this breaks the asCommit and asTag legacy translation methods on RevCommit and RevTag, so we still have to keep the Repository inside of RevWalk for those two types. Hopefully we can drop those in the future, and then drop the Repository off the RevWalk. Change-Id: Iba983e48b663790061c43ae9ffbb77dfe6f4818e Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Externalize strings from JGitSasa Zivkov2010-05-191-1/+3
| | | | | | | | | | | | | | | The strings are externalized into the root resource bundles. The resource bundles are stored under the new "resources" source folder to get proper maven build. Strings from tests are, in general, not externalized. Only in cases where it was necessary to make the test pass the strings were externalized. This was typically necessary in cases where e.getMessage() was used in assert and the exception message was slightly changed due to reuse of the externalized strings. Change-Id: Ic0f29c80b9a54fcec8320d8539a3e112852a1f7b Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
* Initial JGit contribution to eclipse.orgGit Development Community2009-09-291-0/+224
Per CQ 3448 this is the initial contribution of the JGit project to eclipse.org. It is derived from the historical JGit repository at commit 3a2dd9921c8a08740a9e02c421469e5b1a9e47cb. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>