aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
Commit message (Collapse)AuthorAgeFilesLines
* Move FileRepository to storage.file.FileRepositoryShawn O. Pearce2010-06-2618-28/+94
| | | | | | | | | | | | This move isolates all of the local file specific implementation code into a single package, where their package-private methods and support classes are properly hidden away from the rest of the core library. Because of the sheer number of files impacted, I have limited this change to only the renames and the updated imports. Change-Id: Icca4884e1a418f83f8b617d0c4c78b73d8a4bd17 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Use getObjectsDatabase().getDirectory() to find objectsShawn O. Pearce2010-06-254-11/+11
| | | | | | | | | | | Only the ObjectDirectory type of database knows where to find the objects directory on the local filesystem, so defer to it whenever we need to know where the objects reside. Since this is the type returned by FileRepository's getObjectDatabase() method, we mostly don't have to do much other than use a slightly longer invocation. Change-Id: Ie5f58132a6411b56c3acad73646ad169d78a0654 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Rename Repository getWorkDir to getWorkTreeShawn O. Pearce2010-06-254-23/+23
| | | | | | | | | | | | | | This better matches with the name used in the environment (GIT_WORK_TREE), in the configuration file (core.worktree), and in our builder object. Since we are already breaking a good chunk of other code related to repository access, and this fairly easy to fix in an application's code base, I'm not going to offer the wrapper getWorkDir() method. Change-Id: Ib698ba4bbc213c48114f342378cecfe377e37bb7 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Refactor repository construction to builder classShawn O. Pearce2010-06-252-35/+39
| | | | | | | | | | | | | | | | | The new FileRepositoryBuilder class helps applications to construct a properly configured FileRepository, with properties assumed based upon the standard Git rules for the local filesystem. To better support simple command line applications, environment variable handling and repository searching was moved into this builder class. The change gets rid of the ever-growing FileRepository constructor variants, and the multitude of java.io.File typed parameters, by using simple named setter methods. Change-Id: I17e8e0392ad1dbf6a90a7eb49a6d809388d27e4c Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove Repository.toFile(ObjectId)Shawn O. Pearce2010-06-251-2/+4
| | | | | | | | | | | | Not every type of Repository will be able to map an ObjectId into a local file system path that stores that object's file contents. Heck, its not even true for the FileRepository, as an object can be stored in a pack file and not in its loose format. Remove this from our public API, it was a mistake to publish it. Change-Id: I20d1b8c39104023936e6d46a5b0d7ef39ff118e8 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Replace WindowCache with ObjectReaderShawn O. Pearce2010-06-252-2/+2
| | | | | | | | | | | | | | | | The WindowCache is an implementation detail of PackFile and how its used by ObjectDirectory. Lets start to hide it and replace the public API with a more generic concept, ObjectReader. Because PackedObjectLoader is also considered a private detail of PackFile, we have to make PackWriter temporarily dependent upon the WindowCursor and thus FileRepository and ObjectDirectory in order to just start the refactoring. In later changes we will clean up the APIs more, exposing sufficient support to PackWriter without needing the file specific implementation details. Change-Id: I676be12b57f3534f1285854ee5de1aa483895398 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Start using ObjectInserter instead of ObjectWriterShawn O. Pearce2010-06-254-37/+50
| | | | | | | | | | | | Some newer style APIs are updated to use the newer ObjectInserter interface instead of the now deprecated ObjectWriter. In many of the unit tests we don't bother to release the inserter, these are typically using the file backend which doesn't need a release, but in the future should use an in-memory HashMap based store, which really wouldn't need it either. Change-Id: I91a15e1dc42da68e6715397814e30fbd87fa2e73 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Refactor object writing responsiblities to ObjectDatabaseShawn O. Pearce2010-06-251-5/+1
| | | | | | | | | | | | | | | | | | | | | | The ObjectInserter API permits ObjectDatabase implementations to control their own object insertion behavior, rather than forcing it to always be a new loose file created in the local filesystem. Inserted objects can also be queued and written asynchronously to the main application, such as by appending into a pack file that is later closed and added to the repository. This change also starts to open the door to non-file based object storage, such as an in-memory HashMap for unit testing, or a more complex system built on top of a distributed hash table. To help existing application code port to the newer interface we are keeping ObjectWriter as a delegation wrapper to the new API. Each ObjectWriter instances holds a reference to an ObjectInserter for the Repository's top-level ObjectDatabase, and it flushes and releases that instance on each object processed. Change-Id: I413224fb95563e7330c82748deb0aada4e0d6ace Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Use FileRepository where we assume other file semanticsShawn O. Pearce2010-06-255-11/+12
| | | | | | | | | | | When the surrounding code is already heavily based upon the assumption that we have a FileRepository (e.g. because it created that type of repository) keep the type around and use it directly. This permits us to continue to do things like save the configuration file. Change-Id: Ib783f0f6a11acd6aa305c16d61ccc368b46beecc Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Make lib.Repository abstract and lib.FileRepository its implementationShawn O. Pearce2010-06-253-31/+31
| | | | | | | | | | | | | | | | | | | | To support other storage models other than just the local filesystem, we split the Repository class into a nearly abstract interface and then create a concrete subclass called FileRepository with the file based IO implementation. We are using an abstract class for Repository rather than the much more generic interface, as implementers will want to inherit a large array of utility functions, such as resolve(String). Having these in a base class makes it easy to inherit them. This isn't the final home for lib.FileRepository. Future changes will rename it into storage.file.FileRepository, but to do that we need to also move a number of other related class, which we aren't quite ready to do. Change-Id: I1bd54ea0500337799a8e792874c272eb14d555f7 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Use CoreConfig, UserConfig and TransferConfig directlyShawn O. Pearce2010-06-231-2/+2
| | | | | | | | | | | | | | | Rather than relying on the helpers in RepositoryConfig to get these objects, obtain them directly through the Config API. Its only slightly more verbose, but permits us to work with the base Config class, which is more flexible than the highly file specific RepositoryConfig. This is what I really meant to do when I added the section parser and caching support to Config, we just failed to finish updating all of the call sites. Change-Id: I481cb365aa00bfa8c21e5ad0cd367ddd9c6c0edd Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Use higher level Config types when possibleShawn O. Pearce2010-06-232-4/+4
| | | | | | | | | | We don't have to assume/depend on RepositoryConfig here, these two tests can use higher level versions of the class and still come up with the same test. That frees us up to do some changes to the RepositoryConfig API. Change-Id: Ia7b263c8c5efa3fae1054416d39c546867288132 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove test of the unsupported core.legacyHeaders variableShawn O. Pearce2010-06-231-5/+1
| | | | | | | | | | | | Long ago we stopped supporting the core.legacyHeaders variable, as JGit (like C Git) stopped creating the new pack-style loose objects, rendering this variable pointless. The test is still valid, it proves we write the standard loose object format for a commit, but the variable assignment has no impact on the test so drop it from the code. Change-Id: I051336ada23033c05e86bbff73ae5d78a37b1640 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove pack stream from PackWriterTestShawn O. Pearce2010-06-231-11/+8
| | | | | | | | | | | | | | | This stream was used only to determine how many bytes had been written thus far. Except we're always dumping it into a simple ByteArrayOutputStream, which also knows that. Drop the dependency on the pack stream and use ByteArrayOutputStream directly. This lets us later move this test into the new storage.file package without dragging along the pack stream that is an internal implementation detail of PackWriter, which is more general than just the file storage layer. Change-Id: I291689c0b1ed799270c213ee73b710b2637fb238 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove pointless setOldObjectId in testShawn O. Pearce2010-06-231-1/+0
| | | | | | | | | | Setting this value is pointless, because its automatically set by the refs.newUpdate call that created the update operation. The API is protected by default, because application level code, including this test, should not be calling it. Change-Id: I8867a4e8007892e2bd44a05d7dec619081081943 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* "Bare" Repository should not return working directory.Mathias Kinzler2010-06-161-0/+208
| | | | | | | | | If a repository is "bare", it currently still returns a working directory. This conflicts with the specification of "bare"-ness. Bug: 311902 Change-Id: Ib54b31ddc80b9032e6e7bf013948bb83e12cfd88 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* Allow to read configured keysMathias Kinzler2010-06-151-0/+38
| | | | | | | | | | | | | | | | Currently, there is no way to read the content of the Git Configuration in a way that would allow to list all configured values generically. This change extends the Config class in such a way as to being able to get a list of sections and to get a list of names for any given section or subsection. This is required in able to implement proper configuration handling in EGit (show all the content of a given configuration similar to "git config -l"). Change-Id: Idd4bc47be18ed0e36b11be8c23c9c707159dc830 Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
* Repository can be configured with FSMarc Strapetz2010-06-043-23/+24
| | | | | | | | | | | | | On Windows, FS_Win32_Cygwin has been used if a Cygwin Git installation is present in the PATH. Assuming that the user works with the Cygwin Git installation may result in unnecessary overhead if he actually does not. Applications built on top of jgit may have more knowledge on the actually used Git client (Cygwin or not) and hence should be able to configure which FS to use accordingly. Change-Id: Ifc4278078b298781d55cf5421e9647a21fa5db24
* Merge "Refactor ReadTreeTest to allow testing other checkout classes"Shawn Pearce2010-06-041-41/+96
|\
| * Refactor ReadTreeTest to allow testing other checkout classesChristian Halstrick2010-06-051-41/+96
| | | | | | | | | | | | | | | | | | | | | | | | ReadTreeTest contains a lot of useful tests for "checkout" implementations. But ReadTreeTest was hardcoded to test only WorkDirCheckout. This change doesn't add/modify any tests semantically but refactors ReadTreeTest so that a different implementations of checkout can be tested. This was done to allow DirCacheCheckout to be tested without rewriting all these tests. Change-Id: I36e34264482b855ed22c9dde98824f573cf8ae22 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Add support for computing a Change-Id à la GerritRobin Rosenberg2010-06-041-0/+523
|/ | | | | | | | | | | A Change-Id helps tools like Gerrit Code Review to keeps different versions of a patch together. The Change-Id is computed as a SHA-1 hash of some of the same basic information as a commit id on the first commit intended to solve a particular problem and then reused for updated solutions. Change-Id: I04334f84e76e83a4185283cb72ea0308b1cb4182 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* Add a merge command to the jgit APIStefan Lay2010-05-241-0/+183
| | | | | | | | | | | Merges the current head with one other commit. In this first iteration the merge command supports only fast forward and already up-to-date. Change-Id: I0db480f061e01b343570cf7da02cac13a0cbdf8f Signed-off-by: Stefan Lay <stefan.lay@sap.com> Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Added merge support to CommitCommandChristian Halstrick2010-05-211-5/+42
| | | | | | | | | | | | | The CommitCommand should take care to create a merge commit if the file $GIT_DIR/MERGE_HEAD exists. It should then read the parents for the merge commit out of this file. It should also take care that when commiting a merge and no commit message was specified to read the message from $GIT_DIR/MERGE_MSG. Finally the CommitCommand should remove these files if the commit succeeded. Change-Id: I4e292115085099d5b86546d2021680cb1454266c Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* Test root locale translationsSasa Zivkov2010-05-191-0/+75
| | | | | | Ensures all translations exist in the root locale. Change-Id: Ic8a8bdfd4a06c6d1ebd1e85a8082a32c82d155c7
* Externalize strings from JGitSasa Zivkov2010-05-195-16/+23
| | | | | | | | | | | | | | | 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>
* Reduce size of PackedObjectLoader by dropping long to intShawn O. Pearce2010-05-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Rather than keep track of both the position of the object, and the position of its data, just keep track of the number of bytes used by the object's header in the pack. This shaves 4 bytes out of the size of the PackedObjectLoader instances. We also can defer the addition instruction to the materialize() operation, avoiding it entirely if the caller never actually uses the loader. This may be relevant for PackWriter invocations, where only 1 loader gets chosen for a given object, even though the object may appear on disk in more than one pack file. Error reporting is now simplified, as we can rely on the object offset rather than its data offset. This is the value displayed by pack debugging tools like `git verify-pack -v`, so its better to use that in our own errors. Because nobody needs getDataOffset() now, we can drop that from the public API. Change-Id: Ic639c0d5a722315f4f5c8ffda6e26643d90e5f42 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Add builder-style API to jgit and Commit & Log cmdChristian Halstrick2010-05-101-0/+117
| | | | | | | | | | | | | | | | | Added a new package org.eclipse.jgit.api and a builder-style API for jgit. Added also the first implementation for two git commands: Commit and Log. This API is intended to be used by external components when functionalities of the standard git commands are required. It will also help to ease writing JGit tests. For internal usages this API may often not be optimal because the git commands are doing much more than required or they expect parameters of an unappropriate type. Change-Id: I71ac4839ab9d2f848307eba9252090c586b4146b Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* Added MERGING_RESOLVED repository stateChristian Halstrick2010-05-081-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | The repository state tells in which state the repo is and also which actions are currently allowed. The state MERGING is telling that a commit is not possible. But this is only true in the case of unmerged paths in the index. When we are merging but have resolved all conflicts then we are in a special state: We are still merging (means the next commit should have multiple parents) but a commit is now allowed. Since the MERGING state "canCommit()" cannot be enhanced to return true/false based on the index state (MERGING is an enum value which does not have a reference to the repository its state it is representing) I had to introduce a new state MERGING_RESOLVED. This new state will report that a commit is possible. CAUTION: there might be the chance that users of jgit previously blindly did a plain commit (with only one parent) when the RepositoryState allowed them to do so. With this change these users will now be confronted with a RepositoryState which says a commit is possible but before they can commit they'll have to check the MERGE_MESSAGE and MERGE_HEAD files and use the info from these files. Change-Id: I0a885e2fe8c85049fb23722351ab89cf2c81a431 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix FooterLine.matches(FooterKey) on same length keysShawn O. Pearce2010-05-041-0/+20
| | | | | | | | | | | | | | If two keys are the same length, but don't share the same sequence of characters, we were incorrectly claiming they still matched due to a bug in the for loop condition. I used the wrong variable and the loop never executed, resulting in equality anytime the two keys being compared were the same length. Use the proper local variable to loop through the arrays, and add a JUnit test to verify equality works as expected. Change-Id: I4a02400e65a9b2e0da925b05a2cc4b579e1dd33a Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Fix ReceivePackRefFilterTest on WindowsShawn O. Pearce2010-04-271-0/+9
| | | | | | | | | | | | The pack files were left open after the test ended, which meant we could not delete them automatically when the test was over. Make sure we close the repositories (and thus their underlying packs) before the tear down finishes. Bug: 310367 Change-Id: I4d2703efa4b2e0c347ea4f4475777899cf71073e Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* ReceivePack: Clarify the check reachable optionShawn O. Pearce2010-04-161-6/+6
| | | | | | | | | | | | | | | | | | | This option was mis-named from day 1. Its not checking that the objects provided by the client are reachable, its actually doing a scan to prove that objects referenced by the client are already reachable through another reference on the server, or were sent as part of the pack from the client. Rename it checkReferencedObjectsAreReachable, since we really are trying to validate that objects referenced by the client's actions are reachable to the client. We also need to ensure we run checkConnectivity() anytime this is enabled, even if the caller didn't turn on fsck for object formats. Otherwise the check would be completely bypassed. Change-Id: Ic352ddb0ca8464d407c6da5c83573093e018af19 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* ReceivePack: fix ensureProvidedObjectsVisible on thin packsShawn O. Pearce2010-04-161-0/+477
| | | | | | | | | | | | | | | | If ensureProvidedObjectsVisible is enabled we expected any trees or blobs directly reachable from an advertised reference to be marked with UNINTERESTING. Unfortunately ObjectWalk doesn't bother setting this until the traversal is complete. Even then it won't necessarily set it on every tree if the corresponding commit wasn't popped. When we are going to check the base objects for the received pack, ensure the UNINTERESTING flag gets carried into every immediately reachable tree or blob, because these are the ones that the client might try to use as delta bases in a thin pack. Change-Id: I5d5fdcf07e25ac9fc360e79a25dff491925e4101 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* IndexPack: Correct thin pack fix using less than 20 bytesShawn O. Pearce2010-04-161-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | If we need to append less than 20 bytes in order to fix a thin pack and make it complete, we need to set the length of our file back to the actual number of bytes used because the original SHA-1 footer was not completely overwritten. That extra data will confuse the header and footer fixup logic when it tries to read to the end of the file. This isn't a very common case to occur, which is why we've never seen it before. Getting a delta that requires a whole object which uses less than 20 bytes in pack representation is really hard. Generally a delta generator won't make these, because the delta would be bigger than simply deflating the whole object. I only managed to do this with a hand-crafted pack file where a 1 byte delta was pointed to a 1 byte whole object. Normally we try really hard to avoid truncating, because its typically not safe across network filesystems. But the odds of this occurring are very low. This truncation is done on a file we have open for writing, will append more content onto, and is a temporary file that we won't move into position for others to see until we've validated its SHA-1 is sane. I don't think the truncate on NFS issue is something we need to worry about here. Change-Id: I102b9637dfd048dc833c050890d142f43c1e75ae Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Make parsing of PersonIdent from raw byte array fault-tolerant.Marc Strapetz2010-03-231-0/+100
| | | | | | RawParseUtils.parsePersonIdent handles now those invalid byte sequences which would result in IndexOutOfBoundsException and returns null in this case.
* Merge branch 'push-sideband' into stable-0.7Shawn O. Pearce2010-03-123-47/+112
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * push-sideband: Reuse the line buffer between strings in PacketLineIn http.server: Use TemporaryBuffer and compress some responses Reduce multi-level buffered streams in transport code Fix smart HTTP client buffer alignment Use "ERR message" for early ReceivePack problems Catch and report "ERR message" during remote advertisements Wait for EOF on stderr before finishing SSH channel Capture non-progress side band #2 messages and put in result ReceivePack: Enable side-band-64k capability for status reports Use more restrictive patterns for sideband progress scraping Prefix remote progress tasks with "remote: " Decode side-band channel number as unsigned integer Refactor SideBandInputStream construction Refactor SideBandOutputStream to be buffered Change-Id: Ic9689e64e8c87971f2fd402cb619082309d5587f
| * Reduce multi-level buffered streams in transport codeShawn O. Pearce2010-03-121-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some transports actually provide stream buffering on their own, without needing to be wrapped up inside of a BufferedInputStream in order to smooth out system calls to read or write. A great example of this is the JSch SSH client, or the Apache MINA SSHD server. Both use custom buffering to packetize the streams into the encrypted SSH channel, and wrapping them up inside of a BufferedInputStream or BufferedOutputStream is relatively pointless. Our SideBandOutputStream implementation also provides some fairly large buffering, equal to one complete side-band packet on the main data channel. Wrapping that inside of a BufferedOutputStream just to smooth out small writes from PackWriter causes extra data copies, and provides no advantage. We can save some memory and some CPU cycles by letting PackWriter dump directly into the SideBandOutputStream's internal buffer array. Instead we push the buffering streams down to be as close to the network socket (or operating system pipe) as possible. This allows us to smooth out the smaller reads/writes from pkt-line messages during advertisement and negotation, but avoid copying altogether when the stream switches to larger writes over a side band channel. Change-Id: I2f6f16caee64783c77d3dd1b2a41b3cc0c64c159 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
| * Refactor SideBandOutputStream to be bufferedShawn O. Pearce2010-03-122-43/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of relying on our callers to wrap us up inside of a BufferedOutputStream and using the proper block sizing, do the buffering directly inside of SideBandOutputStream. This ensures we don't get large write-throughs from BufferedOutputStream that might overflow the configured packet size. The constructor of SideBandOutputStream is also beefed up to check its arguments and ensure they are within acceptable ranges for the current side-band protocol. Change-Id: Ic14567327d03c9e972f9734b8228178bc448867d Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Fix NLS to build under Java 5Shawn O. Pearce2010-03-122-17/+17
| | | | | | | | | | | | | | | | | | The tests were using a Locale.ROOT constant which was introduced in Java 6. However, we need to retain Java 5 support. Change-Id: I75c5648fcfc728a9aea2e839d2ad0320f5cf742f Signed-off-by: Shawn O. Pearce <spearce@spearce.org> CC: Sasa Zivkov <sasa.zivkov@sap.com>
* | Provide NLS support in JGit.Sasa Zivkov2010-03-1110-0/+462
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The support for NLS relies on java.util API to load a standard ResourceBundle and then uses java reflection API to inject localized strings into public String fields of the corresponding instance of TranslationBundle. Locale setting is supported per thread to enable concurrent threads to use different locales. This is useful when JGit runs in a server context where (error) messages might need to differ per-request to suit the user's preference. Change-Id: Ie0e63a0d7bb74eaad495dbe8248595d8a3a76883 Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
* | Fix TimeoutInputStreamTest, TimeoutOutputStreamTest assertionsShawn O. Pearce2010-02-102-4/+4
|/ | | | | | | | | | If the build server is really busy, we might wait longer than 250 ms before being interrupted, simply because one of our threads couldn't be scheduled onto a CPU. Don't make that cause a test failure. Instead tolerate longer than expected waits, but not shorter waits. Change-Id: I64511eec24b49e33928451e4c8b8c124eddaf0c2 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Don't allow DirCacheEntry with mode of 0Shawn O. Pearce2010-02-037-14/+213
| | | | | | | | | | | | | | | | | | | | | | | A 0 file mode in a DirCacheEntry is not a valid mode. To C git such a value indicates the record should not be present. We already were catching this bad state and exceptioning out when writing tree objects to disk, but we did not fail when writing the dircache back to disk. This allowed JGit applications to create a dircache file which C git would not like to read. Instead of checking the mode during writes, we now check during mutation. This allows application bugs to be detected sooner and closer to the cause site. It also allows us to avoid checking most of the records which we read in from disk, as we can assume these are formatted correctly. Some of our unit tests were not setting the FileMode on their test entry, so they had to be updated to use REGULAR_FILE. Change-Id: Ie412053c390b737c0ece57b8e063e4355ee32437 Originally: http://thread.gmane.org/gmane.comp.version-control.git/128214/focus=128213 Signed-off-by: Shawn O. Pearce <spearce@spearce.org> CC: Adam W. Hawks <awhawks@writeme.com>
* Fix ObjectWalk corruption when skipping over empty treesShawn O. Pearce2010-02-021-0/+44
| | | | | | | | | | | | | | | | | | | The supplied test case comes out of the example tree identified by Robert de Wilde and Ilari on #git: $ git ls-tree -rt a54f1a85ebf6a7f53aa60a45a1be33f8b078fb7e 040000 tree bfe058ad536cdb12e127cde63b01472c960ea105 A 040000 tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 A/A 040000 tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 A/B 100644 blob abbbfafe3129f85747aba7bfac992af77134c607 B In this tree, "B" was being skipped because "A/A" as an empty tree was immediately followed by "A/B", also an empty tree, but the ObjectWalk broke out too early and never visited "B". Bug: 286653 Change-Id: I25bcb0bc99d0cbbbdd9c2bd625ad6a691a6d0335 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Correctly skip over unrecognized optional dircache extensionsShawn O. Pearce2010-02-021-0/+29
| | | | | | | | | | | | | | | | | | | We didn't skip the correct number of bytes when we skipped over an unrecognized but optional dircache extension. We missed skipping the 8 byte header that makes up the extension's name and length. We also didn't include the skipped extension's payload as part of our index checksum, resuting in a checksum failure when the index was done reading. So ensure we always scan through a skipped section and include it in the checksum computation. Add a test case for a currently unsupported index extension, 'ZZZZ', to verify we can still read the DirCache object even though we don't know what 'ZZZZ' is supposed to mean. Bug: 301287 Change-Id: I4bdde94576fffe826d0782483fd98cab1ea628fa Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Remove RepositoryTestCase from DirCacheCGitCompatabilityTestShawn O. Pearce2010-02-021-3/+5
| | | | | | | | | This test doesn't actually depend upon the large data set we have in the RepositoryTestCase, so drop that from the dependency and use the more simple LocalDiskRepositoryTestCase instead. Change-Id: I0fd4affe1dd5ec86e8c3253db42df11d3b612e36 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Merge "Add unsetSection to Config to remove an entire block"Robin Rosenberg2010-01-281-0/+41
|\
| * Add unsetSection to Config to remove an entire blockShawn O. Pearce2010-01-291-0/+41
| | | | | | | | | | | | | | | | | | The unsetSection method can be used to delete an entire configuration block, such as a [branch ""] or [remote ""] section in a file. Change-Id: I93390c9b2187eb1b0d51353518feaed83bed2aad Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* | Merge "Relax ObjectChecker to permit missing tagger lines"Robin Rosenberg2010-01-282-29/+49
|\ \ | |/ |/|
| * Relax ObjectChecker to permit missing tagger linesShawn O. Pearce2010-01-232-29/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Annotated tags created with C Git versions before the introduction of c818566 ([PATCH] Update tags to record who made them, 2005-07-14), do not have a "tagger" line present in the object header. This line did not appear in C Git until v0.99.1~9. Ancient projects such as the Linux kernel contain such tags, for example Linux 2.6.12 is older than when this feature first appeared in C Git. Linux v2.6.13-rc4 in late July 2005 is the first kernel version tag to actually contain a tagger line. It is therefore acceptable for the header to be missing, and for the RevTag.getTaggerIdent() method to return null. Since the Javadoc for getTaggerIdent() already explained that the identity may be null, we just need to test that this is true when the header is missing, and allow the ObjectChecker to pass anyway. Change-Id: I34ba82e0624a0d1a7edcf62ffba72260af6f7e5d See: http://code.google.com/p/gerrit/issues/detail?id=399 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Don't confuse empty configuration variables with booleansShawn O. Pearce2010-01-231-1/+30
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | Config was confusing the following two variables when writing the file back to text format: [my] empty = enabled When parsed, we say that my.empty has 1 value, null, and my.enabled is an empty string value that in boolean context should be evaluated as true. Saving this configuration file back to text format was ignoring the null value for my.empty, producing a completely different file than what Config read: [my] empty enabled Instead handle the writing differently to ensure the original format is output. New tests cases cover the expected behavior and return values from accessor methods. Change-Id: Id37379ce20cb27e3330923cf989444dd9f2bdd96 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Merge branch 'ref-abstract'Shawn O. Pearce2010-01-2311-90/+2328
|\ | | | | | | | | | | | | | | | | | | | | * ref-abstract: Optimize RefAdvertiser performance by avoiding sorting branch: Add -m option to rename a branch Replace writeSymref with RefUpdate.link Rewrite reference handling to be abstract and accurate Create new RefList and RefMap utility types Change-Id: If43aacf5aa4013edbd0a6e84d84c4f9e94de5be0