aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/dircache
Commit message (Collapse)AuthorAgeFilesLines
* Silence deprecation warning in DirCacheCheckoutMatthias Sohn2015-05-291-0/+1
| | | | Change-Id: I9e021ba2e0d1317bd98e86f832d55787ed6b0a63 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Use AutoClosable to close resources in bundle org.eclipse.jgitMatthias Sohn2015-05-211-12/+3
| | | | | | | - use try-with-resource where possible - replace use of deprecated release() by close() Change-Id: I0f139c3535679087b7fa09649166bca514750b81 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge "Fix possible AIOOB in DirCacheTree.contains()"Christian Halstrick2015-05-111-1/+1
|\
| * Fix possible AIOOB in DirCacheTree.contains()Christian Halstrick2015-05-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When DirCacheTree.contains() is called and 'aOff' is greater than 'aLen' an ArrayIndexOutOfBoundsException was thrown. This fix makes DirCacheTree.contains() more robust and allows parsing such index files without throwing AIOOB. I couldn't create a test case leading to this situation but I have seen such situations while inspecting Bug: 465393. It seems that such situations are created on Windows when there are invalid pathes in the index. There may be a not yet known bug leading to such situations in combination with invalid pathes. Bug: 465393 Change-Id: I6535d924a22cba9a05df0ccd7e6dc2c9ddc42375
* | Delete deprecated checkoutEntry() methods in DirCacheCheckoutMatthias Sohn2015-04-251-67/+0
|/ | | | Change-Id: I7fcf6534e6092ba87360ccd68a7dd7466c5c8911 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge "Use try-with-resource to close resources in DirCache"Shawn Pearce2015-04-081-4/+1
|\
| * Use try-with-resource to close resources in DirCacheMatthias Sohn2015-04-031-4/+1
| | | | | | | | Change-Id: I7dd3fd38784689816a1a8e9d8ccb499ae2138a8a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Reduce visibility of DirCacheCheckout.checkValidPath()Matthias Sohn2015-04-031-3/+1
|/ | | | | | | This was deprecated and should only be used by DirCacheCheckout and friends. Other classes should use SystemReader.checkPath() instead. Change-Id: I37cf753b1f081602dee9f0f47979eff39d735f92 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Handle invalid tree extensionsChristian Halstrick2015-01-261-1/+1
| | | | | | | | | | | | | | | | | | In case the index contains wrong tree extensions don't throw a ArrayIndexOutOfBounds exception but revalidate the tree extension. It happened that the git index written by Git for Windows contained valid (means entryCount>0) tree extensions for pathes which are not existing in the index. Native git handles this inconsistency silently but JGit was crashing with a ArrayIndexOutOfBounds exception. Teach JGit to better recognize such cases and revalidate such extensions. It's hard to write a test because JGit doesn't write such extensions. It only reads, validates and makes use of them. But the bug tells how to create such situations. Bug: 457152 Change-Id: Id3ffd7dc7ae1c55674d88bf1b43953234fe0b68d
* Add basic support for .gitattributesArthur Daussy2015-01-071-0/+64
| | | | | | | | | | | | | | | | | | | | | | Core classes to parse and process .gitattributes files including support for reading attributes in WorkingTreeIterator and the dirCacheIterator. The implementation follows the git ignore implementation. It supports lazy reading attributes while walking the working tree. Bug: 342372 CQ: 9078 Change-Id: I05f3ce1861fbf9896b1bcb7816ba78af35f3ad3d Also-by: Marc Strapetz <marc.strapetz@syntevo.com> Also-by: Gunnar Wagenknecht <gunnar@wagenknecht.org> Also-by: Arthur Daussy <arthur.daussy@obeo.fr> Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org> Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com> Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
* Merge branch 'stable-3.5' into stable-3.6Matthias Sohn2014-12-193-48/+34
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-3.5: JGit v3.5.3.201412180710-r JGit v3.4.2.201412180340-r ObjectChecker: Disallow names potentially mapping to ".git" on HFS+ ObjectChecker: Disallow Windows shortname "GIT~1" ObjectChecker: Disallow ".git." and ".git<space>" Always ignore case when forbidding .git in ObjectChecker DirCache: Refuse to read files with invalid paths DirCache: Replace isValidPath with DirCacheCheckout.checkValidPath Replace "a." with "a-" in unit tests Apache HttpClientConnection: replace calls to deprecated LocalFile() Fix two nits about DirCacheEntry constructors Detect buffering failures while writing rebase todo file Deprecate TemporaryBuffer.LocalFile without parent directory Switch FileHeader.extractFileLines to TemporaryBuffer.Heap AmazonS3: Buffer pushed pack content under $GIT_DIR DirCache: Buffer TREE extension to $GIT_DIR Change-Id: Iee8acbaa9d4d9047b550641db1b8845d64530785 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Merge branch 'stable-3.4' into stable-3.5Matthias Sohn2014-12-183-48/+34
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-3.4: JGit v3.4.2.201412180340-r ObjectChecker: Disallow names potentially mapping to ".git" on HFS+ ObjectChecker: Disallow Windows shortname "GIT~1" ObjectChecker: Disallow ".git." and ".git<space>" Always ignore case when forbidding .git in ObjectChecker DirCache: Refuse to read files with invalid paths DirCache: Replace isValidPath with DirCacheCheckout.checkValidPath Replace "a." with "a-" in unit tests Apache HttpClientConnection: replace calls to deprecated LocalFile() Fix two nits about DirCacheEntry constructors Detect buffering failures while writing rebase todo file Deprecate TemporaryBuffer.LocalFile without parent directory Switch FileHeader.extractFileLines to TemporaryBuffer.Heap AmazonS3: Buffer pushed pack content under $GIT_DIR DirCache: Buffer TREE extension to $GIT_DIR Change-Id: I398cf40b006a05a6537788fc6eb1f84df1ed8814 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * DirCache: Refuse to read files with invalid pathsShawn Pearce2014-12-181-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | If the DirCache contains a path that is known to be invalid, refuse to read the DirCache into memory. This avoids confusing errors later if an invalid path read from the DirCache were to be passed into a new DirCacheEntry constructor. Change-Id: Ic033d81e23a5fbd554cc4dff80a232504562ffa8
| | * DirCache: Replace isValidPath with DirCacheCheckout.checkValidPathShawn Pearce2014-12-182-34/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | isValidPath is an older simple form of the validation performed by checkValidPath. Use the latter as it more consistently matches git-core's validation rules. By running the same validation as fsck, callers creating an entry for the DirCache are more likely to learn early they are trying to build trees that will fail fsck. Change-Id: Ibf5ac116097156aa05c18e231bc65c0854932eb1
| | * Fix two nits about DirCacheEntry constructorsShawn Pearce2014-11-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Explicitly pass STAGE_0 when creating a DirCacheEntry from String. This matches the immediate next constructor that accepts the int stage argument better, making the code easier to read. Fix a weird line break where the comma was orphaned by itself. Change-Id: Icf0970dd02a63877f9e41b51b982b0265e8b8887
| | * DirCache: Buffer TREE extension to $GIT_DIRShawn Pearce2014-11-251-10/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Increase the in-memory buffer for the TREE extension to 5 MiB, and overflow to $GIT_DIR instead of /tmp. Using a larger buffer reduces the chances a repository will overflow and need to spool the extension to disk. Using $GIT_DIR allows the TREE extension contents to have the same file system protections as the final $GIT_DIR/index. Wrap the entire thing in a try/finally to ensure the temp file is deleted from disk after the block has finished using it. To avoid dangling NFS files, LocalFile.destroy() does close the local file before deleting it. Change-Id: I8f871181a4689e3ebf0cdd4fd1769333cf7546c3
* | | Fix DirCacheCheckout to set correct file length if core.autocrlf=trueMatthias Sohn2014-12-111-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To update the file length stat we need to use the length of the temporary file since it's not yet renamed to the target file name here. The incorrect file length stat update was introduced in a606dc363d0f6b09e4527cca6b645d3cb1ec407d. Bug: 453962 Change-Id: I715c048227553efae6f8f6b6878c0f04f2609d9c Also-by: Konrad Kügler <swamblumat-eclipsebugs@yahoo.de> Also-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | Move checkPath from DirCacheCheckout to ObjectCheckerShawn Pearce2014-11-281-15/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bulk of the "is this sane" logic is inside of ObjectChecker. The only caller for the version in DirCacheCheckout is an obtuse usage for the static isValidRefName() method in Repository. Deprecate the weird single use method in DirCacheCheckout and move all code for checking a sequence of path components into ObjectChecker, where it makes sense alongside the existing code that checks a single component at a time. Reuse a single ObjectChecker for the local platform, to avoid looking up the system properties on each path string considered. Change-Id: Iae6e769f2bfcad05c166e70ff255f9cf9fcdc87e
* | | Cleanup double stat update of symlinks in DirCacheCheckoutShawn Pearce2014-11-271-33/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When writing a symlink the stat data should only be written once into the DirCacheEntry, based on the symlink itself and not the possibly resolved destination observed by java.io.File. Refactor the code to handle symlinks and early return. This removes the risk the blob stat info update is used against a newly checked out symlink. Hoist the file length stat update immediately after writing the file, before a rename. This eliminates any race caused by another process updating the file length after the rename and having it to fall into the racily clean path. Change-Id: I978ad9719c018ce1cf26947efbabaa8b9dff2217
* | | Deprecate checkoutEntry variant that accepts FileShawn Pearce2014-11-271-17/+38
| | | | | | | | | | | | | | | | | | | | | | | | Entries should only be written to the working tree managed by the Repository. Simplify callers by passing only the entry and computing the work tree location inside of the checkoutEntry method. Change-Id: I574e41280d0407f1853fda12f4bd0d30f75d74e7
* | | DirCacheCheckout: create only one ObjectReaderShawn Pearce2014-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This deprecated method accidentally creates two ObjectReader instances. Use the instance created one line above that is correctly released in the finally block. Change-Id: Ic57d041674611802a9384d8fa1d292e821055019
* | | Deprecate checkoutEntry without ObjectReaderShawn Pearce2014-11-241-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Callers should manage the ObjectReader, as this allows the JGit library to cache context relevant information across files checked out at the same time. If the caller only has one file to checkout, it should still explicitly manage the life span of the ObjectReader. Change-Id: Ib57fba6cb4b774ccff8c416ef4d32e2b390f16a9
* | | Make sure checkout doesn't report conflicts on ignored pathsChristian Halstrick2014-11-061-1/+1
|/ / | | | | | | | | | | | | | | | | | | | | | | | | In a situation where a certain path was ignored but a working tree file with this path existed jgit didn't allow to checkout a branch which didn't ignore this path but contained different content. JGit considered this to be a checkout conflict to prevent overwriting the file in the working tree and raised an error. This commit fixes this by ensuring that ignored dirty working tree files don't lead to a checkout conflict. Bug: 450169 Change-Id: I90288d314ffac73c24a9c70a5181f8243bd4679a Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | Eliminate warnings for non-nls strings that will never be translatedRobin Rosenberg2014-09-041-2/+2
| | | | | | | | | | | | | | Some of these eliminations just reduces the number of warnings on lines where messages are constructed that can/will be translated. Change-Id: I6eddb39ccc8f2488741bb58540d9ec5f5665e2c4
* | Handle initial checkout correctlyChristian Halstrick2014-07-251-4/+11
|/ | | | | | | | | | As described in native gits file "git-read-tree.txt" git has in a special mode when doing the "initial" checkout. "Initial" means that the index is empty before the checkout. This was not handled correctly in JGit and is fixed in this commit. Also see https://github.com/git/git/blob/master/Documentation/git-read-tree.txt#L181 Change-Id: I9b9d1bd9ebf349cfca420c891c7b099a18d07ba4
* Fix a number of failing conflict situationsRobin Rosenberg2014-05-171-45/+121
| | | | | | | | | | | | | Adds further tests where the working tree is dirty (differs from index) and where we have staged but uncommitted changes. Fixed the test case 9 for file/directory conflicts. Bug: 428819 Change-Id: Ie44a288b052abe936ebb74272d0fefef3b218a7a Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* Fix wrong Exception messagesChristian Halstrick2014-05-141-1/+1
| | | | | | | | | | | | | In two places we threw an IOException and the message was built using JGitText.couldNotWriteFile. We specified 2 parameters, but this pattern expects only one parameter. In both places we tried to rename a file, that's why we wanted two parameters (src and target) for the exception text. I changed it to use JGitText.renameFileFailed which accepts two parameters and fits better. Change-Id: Ib8c2cf78f2b26ca2b97754fe91fdb20b30392415 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Cleanup javadocs so they pass the java8 doclint checksRobin Rosenberg2014-03-292-10/+10
| | | | | | Bug: 431552 Change-Id: I469316f5645205016e1fa6b0fbd2ff3b509b14bc Signed-off-by: Robin Stocker <robin@nibor.org>
* Change DirCacheCheckout to verify path using ObjectCheckerShawn Pearce2014-03-121-123/+28
| | | | | | | | Reuse the generic logic in ObjectChecker to examine paths. This required extracting the scanner loop to check for bad characters within the path name segment. Change-Id: I02e964d114fb544a0c1657790d5367c3a2b09dff
* Add missing breakRobin Rosenberg2014-03-091-0/+1
| | | | | | It does not really matter functionally, but it looked bad, Change-Id: Icb5b73b38fcaa19f7d1c5a0235c3e8dd125b888b
* Add @since tag to new DirCache#findEntryRobin Rosenberg2014-03-081-0/+1
| | | | Change-Id: Ia58efd178a4571c013bf1104d1da956a86fd7029 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix some wrong @since 3.3 tags which should be @since 3.4Matthias Sohn2014-03-071-1/+1
| | | | Change-Id: Idafe6e041cc40a00ac52eb4ba88753c49db86988 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Merge "DirCache.findEntry(byte[], in) made public"Robin Rosenberg2014-03-031-8/+20
|\
| * DirCache.findEntry(byte[], in) made publicMarc Strapetz2014-02-241-8/+20
| | | | | | | | | | Change-Id: Ice64e3b0e5d67a39690aa24e41c954b8ce312d49 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>‌
* | Merge "Don't raise checkout conflict for file missing in working tree"Christian Halstrick2014-02-271-3/+3
|\ \
| * | Don't raise checkout conflict for file missing in working treeChristian Halstrick2014-02-261-3/+3
| |/ | | | | | | | | | | | | | | | | | | | | During a checkout we want to prevent to overwrite unsaved local file content. Jgit was therefore checking whether the file to overwrite is dirty or missing and would raise a conflict if this was the case. That was wrong. It should only check if the file is dirty. It's ok to "overwrite" a missing/non-existing file. Change-Id: I63c3a94f663c87f09170fdf8b1b1bf4ed5246fc5 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* | Add a missing @since tagChristian Halstrick2014-02-261-0/+1
| | | | | | | | Change-Id: Ie34a4a9c4c47c2f27579094d74a7849fc26a323b
* | DirCacheEntry: access to raw pathMarc Strapetz2014-02-261-0/+9
|/ | | | | Change-Id: I5d1f6c4b5b3d7a971367cdd0cc9fa4022dff5b85 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>‌
* Add symlink support to JGitRobin Rosenberg2014-02-101-33/+42
| | | | | | | | | | | | | | | | | | | | The change includes comparing symbolic links between disk and index, adding symbolic links to the index, creating/modifying links on checkout. The behavior is controlled by the core.symlinks setting, just as C Git does. When a new repository is created core.symlinks will be set depending on the capabilities of the operating system and Java runtime. If core.symlinks is set to true, the assumption is that symlinks are supported, which may result in runtime errors if this turns out not to be the case. Measuring the cost of jgit status on a repository with ~70000 files, of which ~30000 are tracked reveals a penalty of about 10% for using the Java7 (really NIO2) support module. Bug: 354367 Change-Id: I12f0fdd9d26212324a586896ef7eb1f6ff89c39c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Ban dangerous ref names in WindowsRobin Rosenberg2014-02-051-17/+50
| | | | | | | Bug: 423551 Change-Id: I3e71ef1b4a8181f46d2902c9169859f150cd6ad0 Also-By: Robin Stocker <robin@nibor.org> Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Fix for core.autocrlf=input resulting in modified fileRobin Rosenberg2014-02-021-6/+14
| | | | | | | | | | | This version does not attempt to unsmudge, unlike the first attempt in Idafad150553df14827eccfde2e3b95760e16a8b6. Bug: 372834 Change-Id: I9300e735cb16d6208e1df963abb1ff69f688155d Also-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Robin Stocker <robin@nibor.org>
* More helpful InvalidPathException messages (include reason)Robin Stocker2013-12-032-23/+43
| | | | | | | | | | Instead of just a generic "Invalid path: $path", add a reason for the cases where it's not obvious what the problem is (e.g. "aux" being reserved on Windows). Bug: 413915 Change-Id: Ia6436bd2560e4f049c92d9aac907cb87348605e0 Signed-off-by: Robin Stocker <robin@nibor.org>
* Fix handling of file/folder conflicts during a checkoutChristian Halstrick2013-11-291-1/+7
| | | | | | | | | | | | | | | | | | | | JGit was not handling certain file/folder conflicts during a checkout correctly. This was reported by Axel Richard in http://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02358.html. This commit fixes this problem. Still JGit behaves intentionally different than native git. If HEAD contains a tree, and workingtree, Index and Merge contain a file with same content ... then JGit allows a conflict free checkout of Merge. Native git always complains that it doesn't want to overwrite local changes. But there is no need to update the working tree because Index and Merge are already equal. A shell script which shows how native git behaves can be found here. https://gist.github.com/chalstrick/7694959#file-gistfile1-sh Change-Id: Ifd6a68974d61cd4fa23bc575f3a40773db66cafc Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
* testMaliciousPathEmpty fails on WindowsRobin Rosenberg2013-11-011-2/+3
| | | | | | | | Checking of spaces at the end of the file name caused the test to fail for Windows only. Bug: 396662 Change-Id: I47bcccb0fa32ce606276c3f30d454851d115ca11 Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
* ResetCommand: Allow reset on unborn branch when ref not specifiedRobin Stocker2013-09-131-1/+1
| | | | | | | | | | | | | In C Git 1.8.2, "git reset" now also works on an unborn branch (no HEAD yet) if no explicit ref was specified. In that case, it is treated as a reset to an empty tree. This can be useful for callers because "unborn branch" no longer has to be special-cased to "git rm --cached". Bug: 414870 Change-Id: Ied750116f767518ae4d48823cf00752b049a8477 Signed-off-by: Robin Stocker <robin@nibor.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Make sure checkout is not deleting folders outside the workingtreeChristian Halstrick2013-07-101-2/+2
| | | | | | | | | | | | | | | There was a chance that jgit deletes symbolic links which point to the folder on top of the working tree. Make sure not to touch these resources. Thanks to Cedric Darloy who reported this bug on http://www.eclipse.org/forums/index.php/m/776910/#msg_776910 and to Ondrej Vrabec who reported bug 412489. Bug: 412489 Change-Id: I81735ba0394ef6794e9b2b8bdd8bd7e8b9c6460f Signed-off-by: Christian Halstrick <christian.halstrick@sap.com> Signed-off-by: Robin Stocker <robin@nibor.org>
* Check parentFile is not nullHiroshi Tomita2013-07-051-1/+1
| | | | | | | | | parentFile becomes null when f is relative path, such as ".". This patch avoids NullPointerException in such case. Change-Id: I4752674b1daab6eedd7c3650c7749462810eaffd Signed-off-by: Hiroshi Tomita <tomykaira@gmail.com>
* File.renameTo behaves differently on Unix and WindowsRobin Rosenberg2013-03-261-10/+6
| | | | | | | | On Windows renameTo will not overwrite a file, so it must be deleted first. The fix for Bug 402834 did not account for that. Bug: 403685 Change-Id: I3453342c17e064dcb50906a540172978941a10a6
* JGit 3.0: move internal classes into an internal subpackageShawn Pearce2013-03-181-2/+2
| | | | | | | | This breaks all existing callers once. Applications are not supposed to build against the internal storage API unless they can accept API churn and make necessary updates as versions change. Change-Id: I2ab1327c202ef2003565e1b0770a583970e432e9
* A folder does not constitute a dirty work treeRobin Rosenberg2013-03-101-1/+2
| | | | | | | | | | | This fixes two cases: - A folder without tracked content exist both in the workdir and merged commit, as long as there names within that folder does not conflict. - An empty folder structure exists with the same name as a file in the merged commit. Bug: 402834 Change-Id: I4c5b9f11313dd1665fcbdae2d0755fdb64deb3ef