summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
Commit message (Collapse)AuthorAgeFilesLines
* Merge changes Idaed9310,I62bd7c0bMatthias Sohn2016-01-031-879/+572
|\ | | | | | | | | | | * changes: ObjectChecker: honor some git-core fsck.* options ObjectChecker: allow some objects to skip errors
| * ObjectChecker: honor some git-core fsck.* optionsShawn Pearce2015-12-301-27/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Accept some of the same section keys that fsck does in git-core, allowing repositories to skip over specific kinds of acceptable broken objects, e.g.: [fsck] duplicateEntries = ignore zeroPaddedFilemode = ignore The zeroPaddedFilemode = ignore is a synonym for the JGit specific allowLeadingZeroFileMode = true. Only accept the JGit key if git-core key was not specified. Change-Id: Idaed9310e2a5ce5511670ead1aaea2b30aac903c
| * ObjectChecker: allow some objects to skip errorsShawn Pearce2015-12-301-873/+472
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Some ancient objects may be broken, but in a relatively harmless way. Allow the ObjectChecker caller to whitelist specific objects that are going to fail checks, but that have been reviewed by a human and decided the objects are OK enough to permit continued use of. This avoids needing to rewrite history to scrub the broken objects out. Honor the git-core fsck.skipList configuration setting when receiving a push or fetching from a remote repository. Change-Id: I62bd7c0b0848981f73dd7c752860fd02794233a6
* | Fixed few locale dependent pgm testsAndrey Loskutov2016-01-021-0/+31
| | | | | | | | | | | | See https://dev.eclipse.org/mhonarc/lists/jgit-dev/msg03040.html Change-Id: If51f3c750684d82cb6443f1578636c9f5ca56e2b Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
* | buck: set vm_args for testsShawn Pearce2016-01-011-0/+1
| | | | | | | | | | | | | | | | Maven pom files force the local encoding to UTF-8 to ensure there are no differences between machines. They also set the JVM max heap to 256m. Match both in Buck so that results are consistent. Change-Id: Ice5476dd09352a444a0c97aa0dc28806fddf2ab4
* | Merge changes from topic 'add-df'Shawn Pearce2016-01-013-5/+203
|\ \ | | | | | | | | | | | | | | | | | | * changes: DirCache: Do not create duplicate tree entries DirCacheEditor: Replace file-with-tree and tree-with-file AddCommand: Use NameConflictTreeWalk to identify file-dir changes
| * | DirCache: Do not create duplicate tree entriesShawn Pearce2015-12-291-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a file (e.g. "A") and a subtree file (e.g. "A/foo.c") both appear in the DirCache this cache should not be written out as a tree object. The "A" file and "A" subtree conflict with each other in the same tree and will fail fsck. Detect this condition during DirCacheBuilder and DirCacheEditor finish() so the application can be halted early before it updates a DirCache that might later write an invalid tree structure. Change-Id: I95660787e88df336297949b383f4c5fda52e75f5
| * | DirCacheEditor: Replace file-with-tree and tree-with-fileShawn Pearce2015-12-292-4/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a PathEdit tries to store a file where a subtree was, or a subtree where a file was, replace the entry in the DirCache with the new name(s). This supports switching between file and tree entry types using a DirCacheEditor. Add new unit tests to cover the conditions where these can happen. Change-Id: Ie843d9388825f9e3d918a5666aa04e47cd6306e7
| * | AddCommand: Use NameConflictTreeWalk to identify file-dir changesShawn Pearce2015-12-291-1/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding a path that already exists but is changing type such as from symlink to subdirectory requires a NameConflictTreeWalk to match up the two different entry types that share the same name. NameConflictTreeWalk needs a bug fix to pop conflicting entries when PathFilterGroup aborts the walk early so that it does not allow DirCacheBuilderIterator to copy conflicting entries into the output cache. Change-Id: I61b49cbe949ca8b4b98f9eb6dbe7b1f82eabb724
* | | buck: run testsShawn Pearce2015-12-311-0/+94
| |/ |/| | | | | | | | | | | | | | | | | | | | | Compile each test in its own java_test() target so they can run in parallel, reducing total time spent testing on large machines. $ buck test --all [-] PROCESSING BUCK FILES...FINISHED 0.3s [100%] [-] BUILDING...FINISHED 2.9s [100%] (351/383 JOBS, 351 UPDATED, 0.0% CACHE MISS) [-] TESTING...FINISHED 98.1s (3360 PASS/15 SKIP/0 FAIL) Change-Id: I8d6541268315089299f933ed23d785b1b3431133
* | PackWriter: use lib.ObjectIdSet to avoid wrapperShawn Pearce2015-12-291-12/+3
|/ | | | | | | | | | | | Hoist ObjectIdSet up to lib as part of the public API and add the interface to some common types like PackIndex and JGit custom ObjectId map types. This cleans up wrapper code in a number of places by allowing direct use of the types as an ObjectIdSet. Future commits can now rely on ObjectIdSet as a simple read-only type to check a set of objects from a number of storage options. Change-Id: Ib62b062421d475bd52abd6c84a73916ef36e084b
* Skip nested copyfiles in RepoCommand.Yuxuan 'fishy' Wang2015-12-221-1/+6
| | | | | | | | Similar to nested directories, nested copyfiles won't work with git submodule either. Change-Id: Idbe965ec20a682fca0432802858162f8238f05de Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
* Checkout should be able to override modified symbolic linksAndrey Loskutov2015-12-172-8/+83
| | | | | | | | | Handle existing symlink as a file, not as directory if deleting a file before creating (overriding) a symlink. Bug: 484491 Change-Id: I29dbf57d1daec2ba98454975b093e1d381d05196 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
* Included cached deltas in delta packStatistics.James Kolb2015-12-161-0/+34
| | | | | | | | Previously, non-reuse deltas were only included in packStatistics if they were not cached by the deltaWindow. Change-Id: I7684d8214875f0a7569b34614f8a3ba341dbde9c Signed-off-by: James Kolb <jkolb@google.com>
* Merge changes Ib4d53bdd,I55bd512cJonathan Nieder2015-12-161-33/+117
|\ | | | | | | | | | | * changes: Do not let PathFilter.create("a/b") match 'a' unless 'a' is a subtree Add tests for PathFilterGroup.Single
| * Do not let PathFilter.create("a/b") match 'a' unless 'a' is a subtreeJonathan Nieder2015-12-151-6/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PathFilter and PathFilterGroup form JGit's implementation of git's path-limiting feature in commands like log and diff. To save time when traversing trees, a path specification foo/bar/baz tells the tree walker not to traverse unrelated trees like qux/. It does that by returning false from include when the tree walker is visiting qux and true when it is visiting foo. Unfortunately that test was implemented to be slightly over-eager: it doesn't only return true when asked whether to visit a subtree "foo" but when asked about a plain file "foo" as well. As a result, diffs and logs restricted to some-file/non-existing-suffix unexpectedly match against some-file: $ jgit log -- LICENSE/no-such-file commit 629fd0d594d242eab26161b0dac34f7576fd4d3d Author: Shawn O. Pearce <spearce@spearce.org> Date: Fri Jul 02 14:52:49 2010 -0700 Clean up LICENSE file [...] Fix it by checking against the entry's mode. Gitiles +log has the same bug and benefits from the same fix. Callers know not to worry about what subtrees are included in the tree walk because shouldBeRecursive() returns true in this case, so this behavior change should be safe. This also better matches the behavior of C git: $ empty=$(git mktree </dev/null) $ git diff-tree --abbrev $empty HEAD -- LICENSE/no-such-file $ git diff-tree --abbrev $empty HEAD -- tools/no-such-file :000000 040000 0000000... b62648d... A tools Bug: 484266 Change-Id: Ib4d53bddd8413a9548622c7b25b338d287d8889d
| * Add tests for PathFilterGroup.SingleJonathan Nieder2015-12-151-33/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Expand the existing PathFilterGroup tests to check which paths the tree entry matches. This expands test coverage by ensuring that PathFilterGroup's simpler code path to match against a single PathFilter works correctly. While at it, move the check on tree entry d/e/f/g.y into two separate tests: one to check that it doesn't match any of the configured paths, and another to check that it does not throw StopWalkException to end the walk early. Change-Id: I55bd512cd049fc2018659e2f86a4b8650f171fda
* | Merge "Refspec: loosen restrictions on wildcard "*""Shawn Pearce2015-12-151-15/+35
|\ \
| * | Refspec: loosen restrictions on wildcard "*"Marc Strapetz2015-10-211-15/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Git 2.6 wildcard restrictions for refspecs have been loosened: refspecs like "refs/heads/*foo:refs/heads/foo*" are valid now. See Git commit 8d3981ccbed9fc211b4e67105015179d9d2a5692 Change-Id: Icb78afbd282c425173b3a7bc10eadc4015689bb8 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
* | | Merge "Bug 484342: Support @ in username in SSH url."Shawn Pearce2015-12-151-0/+42
|\ \ \ | |_|/ |/| |
| * | Bug 484342: Support @ in username in SSH url.Mike Gilbode2015-12-151-0/+42
| | | | | | | | | | | | | | | Change-Id: I5795e925afff796488ba26c83694e806b76a374f Signed-off-by: Mike Gilbode <gilbode@gmail.com>
* | | Merge "push: Do not blindly overwrite peer"Shawn Pearce2015-12-141-0/+143
|\ \ \ | |/ / |/| |
| * | push: Do not blindly overwrite peerShawn Pearce2015-12-141-0/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If an application uses PushConnection directly on the native Git wire protocols JGit should send along the application's expected oldId, not the advertised value. This allows the remote peer to compare-and-swap since it was not tested inside JGit. Discovered when I tried to use a PushConnection (bypassing the standard PushProcess) and the client blindly overwrote the remote reference, even though my app had supplied the wrong ObjectId for the expectedOldObjectId. This was not expected and cost me over an hour of debugging, plus "corruption" in the remote repository. By passing along the exact expectedOldObjectId from the app the remote side can do the check that the application skipped, and avoid data loss. Change-Id: Id3920837e6c47100376225bb4dd61fa3e88c64db
* | | Fix FileTreeIterator.idSubmodule(Entry)Christian Halstrick2015-12-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | FileTreeIterator was calling by mistake WorkingTreeIterator.idSubmodule(Entry). Instead it should always compute idSubmodule on its own. Change-Id: Id1b988aded06939b1d7edd2671e34bf756896c0e
* | | URIish: fixed full uri pattern not expecting end of line after host nameAndrey Loskutov2015-12-121-0/+15
| | | | | | | | | | | | | | | | | | Bug: 483326 Change-Id: I8b6e3eb648c8ec2c38f73de22382537b1276b779 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
* | | Add remote command to JGit CLIKaloyan Raev2015-12-115-0/+413
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Supported subcommands are: - <none> (lists available remotes) - add - remove - set-url - update Supported options are: --verbose --push --prune Bug: 481316 Change-Id: I57c34ed6daabb7d308bc383b17c1ef4af433e714 Signed-off-by: Kaloyan Raev <kaloyan.r@zend.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Support atomic push in JGit clientShawn Pearce2015-12-021-0/+200
| | | | | | | | | | | | | | | | | | | | | | | | | | This should mirror the behavior of `git push --atomic` where the client asks the server to apply all-or-nothing. Some JGit servers already support this based on a custom DFS backend. InMemoryRepository is extended to support atomic push for unit testing purposes. Local disk server side support inside of JGit is a more complex animal due to the excessive amount of file locking required to protect every reference as a loose reference. Change-Id: I15083fbe48447678e034afeffb4639572a32f50c
* | Delay locating .gitattributes until requestedShawn Pearce2015-11-291-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of checking every entry for .gitattributes only look for the entry on request by TreeWalk. This avoids impacting uses like RevWalk filtering history. When the attrs is requested skip to the start of the tree and look for .gitattributes until either it is found, or it is impossible to be present. Due to the sorting rules of tree entries .gitattributes should be among the first or second entries in the tree so very few entries will need to be considered. Waiting to find the .gitattributes file by native ordering may miss attrs for files like .config, which sorts before .gitattributes. Starting from the front of the tree on demand ensures the attributes are parsed as early as necessary to process any entry in the tree. Due to TreeWalk recursively processing up the tree of iterators we cannot just reset the current CanonicalTreeParser to the start as parent parsers share the same path buffer as their children. Resetting a parent to look for .gitattributes may overwrite path buffer data used by a child iterator. Work around this by building a new temporary CanonicalTreeParser instance. Change-Id: Ife950253b687be325340d27e9915c9a40df2641c
* | DirCacheEntry: Speed up creation by avoiding string castShawn Pearce2015-11-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The checkPath function is available as a byte[] form, in fact the String form just converts to byte[] to run the algorithm. Having DirCacheEntry take a byte[] -> String -> byte[] to check if each path is valid is a huge waste of CPU time. On some systems it can double the time required to read 38,999 files from trees to the DirCache. This slows down any operation using a DirCache. Expose the byte[] form and use it for DirCacheEntry creation. Change-Id: I6db7bc793ece99ff3c356338d793c07c061aeac7
* | Add support for smudge filtersChristian Halstrick2015-11-272-5/+126
| | | | | | | | | | | | | | | | | | | | | | If defined in .gitattributes call smudge filter during checkout. To support checkout where current HEAD,index do not contain attributes we need to also consider attributes from the tree we checkout. Therefore CanonicalTreeParser has to learn how to provide attributes. Change-Id: I168fdb81a8e1a9f991587b3e95a36550ea845f0a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Add support for clean filtersChristian Halstrick2015-11-271-0/+188
| | | | | | | | | | | | | | | | | | When filters are defined for certain paths in gitattributes make sure that clean filters are processed when adding new content to the object database. Change-Id: Iffd72914cec5b434ba4d0de232e285b7492db868 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Add the new class Attributes holding multiple Attribute(s)Ivan Motsch2015-11-274-29/+23
| | | | | | | | | | | | | | | | | | | | Attributes represents a semantic collector of Attribute(s) and replaces the anonymous Map<String,Attribute>. This class will be returned by TreeWalk.getAttributes(). It offers convenient access to the attributes wrapped in the Attributes object. Adds preparations for a future Attribute Macro Expansion Change-Id: I8348c8c457a2a7f1f0c48050e10399b0fa1cdbe1 Signed-off-by: Ivan Motsch <ivan.motsch@bsiag.com>
* | Fix unit tests on WindowsChristian Halstrick2015-11-262-22/+21
| | | | | | | | | | | | | | | | | | PushCommandTest and RunExternalScriptTest didn't succeed on Windows. Fix this by expecting a simple line-feed as line ending (instead of the platform dependent line separator. Additionally correct the computation of expected URLs in PushCommandTest. Change-Id: Idcdc41cd7e535ff88df33ea0a249333ed8fc91b0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Fix HookTest when running on Win32_CygwinChristian Halstrick2015-11-261-13/+8
| | | | | | | | | | | | | | | | | | This test expected that the test scripts emit a platform-dependent newline (crlf on windows, lf on linux). But that's not true. Expected result should always be a trailing "\n" because the test scripts explicitly echo a "\n" in the end. Change-Id: I604e08cda8cebe276b5214ba0f618b6112c3441f
* | Repository: Introduce exactRef and findRef, deprecate getRefJonathan Nieder2015-11-2515-173/+187
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Repository class provides only one method to look up a ref by name, getRef. If I request refs/heads/master and that ref does not exist, getRef will look further in the search path: ref/refs/heads/master refs/heads/refs/heads/master refs/remotes/refs/heads/master This behavior is counterintuitive, needlessly inexpensive, and usually not what the caller expects. Allow callers to specify whether to use the search path by providing two separate methods: - exactRef, which looks up a ref when its exact name is known - findRef, which looks for a ref along the search path For backward compatibility, keep getRef as a deprecated synonym for findRef. This change introduces findRef and exactRef but does not update callers outside tests to use them yet. Change-Id: I35375d942baeb3ded15520388f8ebb9c0cc86f8c Signed-off-by: Jonathan Nieder <jrn@google.com>
* | Merge "RefDirectory.getRef: Treat fake missing symrefs like real ones"Jonathan Nieder2015-11-241-0/+30
|\ \
| * | RefDirectory.getRef: Treat fake missing symrefs like real onesJonathan Nieder2015-11-191-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getRef() loops over its search path to find a ref: Ref ref = null; for (String prefix : SEARCH_PATH) { ref = readRef(prefix + needle, packed); if (ref != null) { ref = resolve(ref, 0, null, null, packed); break; } } fireRefsChanged(); return ref; If readRef returns null (indicating that the ref does not exist), the loop continues so we can find the ref later in the search path. And resolve should never return null, so if we return null it should mean we exhausted the entire search path and didn't find the ref. ... except that resolve can return null: it does so when it has followed too many symrefs and concluded that there is a symref loop: if (MAX_SYMBOLIC_REF_DEPTH <= depth) return null; // claim it doesn't exist Continue the loop instead of returning null immediately. This makes the behavior more consistent. Arguably getRef should throw an exception when a symref loop is detected. That would be a more invasive change, so if it's a good idea it will have to wait for another patch. Change-Id: Icb1c7fafd4f1e34c9b43538e27ab5bbc17ad9eef Signed-off-by: Jonathan Nieder <jrn@google.com>
* | | Let FS_Win32_Cygwin detect symlink support by creating temporary symlinkChristian Halstrick2015-11-215-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The class FS_Win32 was always trying out to create a temporary symlink in order to find out whether symlinks are supported. FS_Win32_Cygwin was overwriting this method and always returned true. But when the user running JGit does not have administrative rights then the creation of symlinks is forbidden even if he is running on FS_Win32_Cygwin. A lot of tests failed only on the Windows platform because of this. It was correctly detected that FS_Win32_Cygwin is the filesystem abstraction to be used but creation of symlinks always failed because of lacking privileges of the user running the tests. This fix teaches FS_Win32_Cygwin to behave like FS_Win32 and to test whether symlinks can be created in order to find out whether symlinks are supported. Change-Id: Ie2394631ffc4c489bd37c3ec142ed44bbfcac726 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Fix classpath of test launch configurationsMatthias Sohn2015-11-212-2/+0
| | | | | | | | | | | | | | | | | | | | | Remove references to the bundle org.eclipse.jgit.java7 which was removed in 4.0. Change-Id: I85527eb2a34bb94979fdab1311043ae77a2b5ecd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Avoid UnknownHostException in WalkEncryptionTestMatthias Sohn2015-11-211-9/+32
|/ / | | | | | | | | | | | | | | Prevent that WalkEncryptionTest fails when it can't determine the public IP address using http://checkip.amazonws.com. Also set timeouts when determining IP address in order to prevent long wait times during tests. Change-Id: I1d2fe09f99df2a5f75f8077811a72fb2271cdddb Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Introduce FS.execute() to execute a command defined by a ProcessBuilderChristian Halstrick2015-11-181-0/+40
| | | | | | | | | | Change-Id: I2ad2c71ad30b969455bdea89637b8e996b1dad8c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Adds the git attributes computation on the treewalkArthur Daussy2015-11-184-39/+887
| | | | | | | | | | | | | | | | | | | | | | | | Adds the getAttributes feature to the tree walk. The computation of attributes needs to be done by the TreeWalk since it needs both a WorkingTreeIterator and a DirCacheIterator. Bug: 342372 CQ: 9120 Change-Id: I5e33257fd8c9895869a128bad3fd1e720409d361 Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr> Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* | Merge "Fix MissingObjectException in RenameDetector"Christian Halstrick2015-11-171-0/+31
|\ \
| * | Fix MissingObjectException in RenameDetectorRĂ¼diger Herrmann2015-11-121-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When attempting to determine the size of a blob that does not exist, the RenameDetector throws a MissingObjectException. The fix is to return a size of zero if the size is requested for a blob id that doesn't exist. Bug: 481577 Change-Id: I4e86276039c630617610cc51d0eefa56d7d3952f Signed-off-by: RĂ¼diger Herrmann <ruediger.herrmann@gmx.de>
* | | Merge branch 'stable-4.1'Matthias Sohn2015-11-141-0/+19
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | * stable-4.1: Prepare 4.1.2-SNAPSHOT builds JGit v4.1.1.201511131810-r Fallback exactRef: Do not ignore symrefs to unborn branch RefDirectory.exactRef: Do not ignore symrefs to unborn branch Change-Id: I66afb303f355aad8a7eaa7a6dff06de70ae9c490 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | Prepare 4.1.2-SNAPSHOT buildsMatthias Sohn2015-11-142-41/+41
| | | | | | | | | | | | | | | Change-Id: I1d1c4d918f2260c866c4392c1abea1e40a1de962 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | JGit v4.1.1.201511131810-rv4.1.1.201511131810-rMatthias Sohn2015-11-142-2/+2
| | | | | | | | | | | | | | | Change-Id: If0246daab39fa279c30874549b198e7aa917bc62 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * | RefDirectory.exactRef: Do not ignore symrefs to unborn branchJonathan Nieder2015-11-111-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When asked to read a symref pointing to a branch-yet-to-be-born (such as HEAD in a newly initialized repository), DfsRepository and FileRepository return different results. FileRepository: exactRef("HEAD") => null DfsRepository: exactRef("HEAD") => SymbolicRef[HEAD -> refs/heads/master=00000000] getRef("HEAD") returns the same as DfsRepository's exactRef in both backends. The intended behavior is the DfsRepository one: exactRef() is supposed to be like getRef(), but more exact because it doesn't need to traverse the search path. The discrepancy is because DfsRefDatabase implements exactRef() directly with the intended semantics, while RefDirectory uses a fallback implementation built on top of getRefs(). getRefs() skips symrefs to an unborn branch. Override the fallback implementation with a correct implementation that is similar to getRef() to avoid this. A followup change will fix the fallback. Change-Id: Ic138a5564a099ebf32248d86b93e2de9ab3c94ee Reported-by: David Pursehouse <david.pursehouse@sonymobile.com> Improved-by: Christian Halstrick <christian.halstrick@sap.com> Bug: 478865
* | | Fix imports in DfsInserterTestMatthias Sohn2015-11-051-10/+9
| | | | | | | | | | | | | | | | | | | | | - remove unused import of AnyObjectId - auto-sort import statements Change-Id: I1c7cec2734bd58370a7dfae70a6a4ccbe3e304ce Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Insert duplicate objects to prevent race during garbage collection.Mike Williams2015-11-041-7/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, DfsInserter would not insert an object into a pack if it already existed in another pack in the repository, even if that pack was unreachable. Consider this sequence of events: - Object FOO is pushed to a repository. - Subsequent ref changes make FOO UNREACHABLE_GARBAGE. - FOO is subsequently re-inserted using a DfsInserter, but skipped due to existing in UNREACHABLE_GARBAGE. - The repository is repacked; FOO will not be written into a new pack because it is not yet reachable from a reference. If the UNREACHABLE_GARBAGE packs are deleted, FOO disappears. - A reference is updated to reference FOO. This reference is now broken as FOO was removed when the repacking process deleted the UNREACHABLE_GARBAGE pack that stored the only copy of FOO. The garbage collector can't safely delete the UNREACHABLE_GARBAGE pack because FOO might be in the middle of being re-inserted/re-packed. This change writes a duplicate copy of an object if it only exists in UNREACHABLE_GARBAGE. This "freshens" the object to give it a chance to survive long enough to be made reachable through a reference. Change-Id: I20f2062230f3af3bccd6f21d3b7342f1152a5532 Signed-off-by: Mike Williams <miwilliams@google.com>