Commit Graph

2644 Commits

Author SHA1 Message Date
Matthias Sohn cdfd22da30 Prepare 3.7.0-SNAPSHOT builds
Change-Id: Ib3e7b5f46ee1e27b9cf25b3b2d01d681a5c4904c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-24 01:17:40 +01:00
Matthias Sohn 9882915810 Merge branch 'stable-3.6'
* stable-3.6:
  Prepare 3.6.1-SNAPSHOT builds
  JGit v3.6.0.201412230720-r
  [pgm] Add option --bare to clone command
  [pgm] Implement clone using CloneCommand
  Fix junit tests under windows when the platform is explicitly changed
  Fix unit tests for windows by explicitly closing test repos
  [pgm] Add option --tags for ls-remote
  [pgm] Add option --heads for ls-remote
  [pgm] Use LsRemoteCommand to implement ls-remote and add a test

Change-Id: I8f31e76cb7e9416919f37e02c7e51ab1d221df40
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-24 01:09:25 +01:00
Matthias Sohn 02b0660b8b Prepare 3.6.1-SNAPSHOT builds
Change-Id: Ie620c90ffafbffc6755b4e1ed55a61a15b118a2a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-23 23:38:20 +01:00
Matthias Sohn b2ca2ffd7d JGit v3.6.0.201412230720-r
Change-Id: Ic28e2bbbdb1099e948c64a005c39f6b8d8ac69a8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-23 13:56:43 +01:00
Christian Halstrick 3226e35db8 Fix junit tests under windows when the platform is explicitly changed
SystemReader used a chached ObjectChecker which was instantiated only
once. But in case of unit tests where we can change the platform
dynamically (e.g. MockSystemReader.setWindows()) this is wrong and
caused DirCacheCheckoutMaliciousPathTest.
testMaliciousAbsoluteCurDrivePathWindowsOnUnix() to fail. This change
allows 
user of SystemReader to force the creation of a new ObjectChecker. 
MockSystemReader.setWindows() and .setUnix() make use of this feature.

Change-Id: I87458d1dc63c1f5c18979f972b1c1f0d670a9ed8
2014-12-22 15:19:09 +01:00
Shawn Pearce 90cccb96d2 Merge branch 'stable-3.6'
* stable-3.6: (26 commits)
  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
  Support the new repository layout for submodules
  Allow explicit configuration of git directory in CloneCommand
  Allow explicit configuration of git directory in InitCommand
  Fix tests on windows by closing repos
  RepoCommand should close opened repos
  Fix LocalDiskRepositoryTestCase to create correct type of repos
  Prevent NPE if ref can't be resolved when executing ReflogCommand
  Fix DirCacheCheckout to set correct file length if core.autocrlf=true
  CheckoutCommand: Fix checking out ours/theirs when no base stage exists
  Make sure modifications to config-param trustFolderStat are detected
  Apache HttpClientConnection: replace calls to deprecated LocalFile()
  ...

Change-Id: Ife6f21d64a148dbb0d0d9055356b1568188806fe
2014-12-19 07:59:22 -08:00
Shawn Pearce 3f27b9135b Merge "Implement FileSnapshot.toString() to help debugging" 2014-12-19 10:55:24 -05:00
Matthias Sohn 75272ccdfc Merge branch 'stable-3.5' into stable-3.6
* 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>
2014-12-19 00:17:54 +01:00
Matthias Sohn 8899006c09 JGit v3.5.3.201412180710-r
Change-Id: Iadbd460da494c04fba71f98c200d6b65ce1709c6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 15:23:10 +01:00
Matthias Sohn 4d6f66400e Merge branch 'stable-3.4' into stable-3.5
* 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>
2014-12-18 15:18:07 +01:00
Matthias Sohn dbe8b52c5c JGit v3.4.2.201412180340-r
Change-Id: Ie088cf129b04ec64738edbc8c3ce25aa43b557ca
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 14:49:20 +01:00
Matthias Sohn d476d2f729 ObjectChecker: Disallow names potentially mapping to ".git" on HFS+
Mac's HFS+ folds concatentations of ".git" and ignorable Unicode
characters [1] to ".git" [2]. Hence we need to disallow all names which
could potentially be a shortname for ".git". Example: in an empty
directory create a folder ".g\U+200Cit". Now you can't create another
folder ".git".

The following characters are ignorable Unicode which are ignored on
HFS+:

unicode   hex         name
-------------------------------------------------
U+200C    0xe2808c    ZERO WIDTH NON-JOINER
U+200D    0xe2808d    ZERO WIDTH JOINER
U+200E    0xe2808e    LEFT-TO-RIGHT MARK
U+200F    0xe2808f    RIGHT-TO-LEFT MARK
U+202A    0xe280aa    LEFT-TO-RIGHT EMBEDDING
U+202B    0xe280ab    RIGHT-TO-LEFT EMBEDDING
U+202C    0xe280ac    POP DIRECTIONAL FORMATTING
U+202D    0xe280ad    LEFT-TO-RIGHT OVERRIDE
U+202E    0xe280ae    RIGHT-TO-LEFT OVERRIDE
U+206A    0xe281aa    INHIBIT SYMMETRIC SWAPPING
U+206B    0xe281ab    ACTIVATE SYMMETRIC SWAPPING
U+206C    0xe281ac    INHIBIT ARABIC FORM SHAPING
U+206D    0xe281ad    ACTIVATE ARABIC FORM SHAPING
U+206E    0xe281ae    NATIONAL DIGIT SHAPES
U+206F    0xe281af    NOMINAL DIGIT SHAPES
U+FEFF    0xefbbbf    ZERO WIDTH NO-BREAK SPACE

[1] http://www.unicode.org/versions/Unicode7.0.0/ch05.pdf#G40025
    http://www.unicode.org/reports/tr31/#Layout_and_Format_Control_Characters
[2] http://dubeiko.com/development/FileSystems/HFSPLUS/tn1150.html#UnicodeSubtleties

Change-Id: Ib6a1dd090b2649bdd8ec16387c994ed29de2860d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 14:49:20 +01:00
Christian Halstrick a09b1b6c3d ObjectChecker: Disallow Windows shortname "GIT~1"
Windows creates shortnames for all non-8.3 files (see [1]). Hence we
need to disallow all names which could potentially be a shortname for
".git". Example: in an empty directory create a folder "GIT~1". Now you
can't create another folder ".git".

The path "GIT~1" may map to ".git" on Windows. A potential victim to
such an attack first has to initialize a git repository in order to
receive any git commits. Hence the .git folder created by init will get
the shortname "GIT~1". ".git" will only get a different shortname if the
user has created a file "GIT~1" before initialization of the git
repository.

[1] http://en.wikipedia.org/wiki/8.3_filename

Change-Id: I9978ab8f2d2951c46c1b9bbde57986d64d26b9b2
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-18 14:49:17 +01:00
Shawn Pearce 10310bf8ef ObjectChecker: Disallow ".git." and ".git<space>"
Windows treats "foo." and "foo " as "foo". The ".git" directory is
special, as it contains metadata for a local Git repository. Disallow
variations that Windows considers to be the same.

Change-Id: I28eb48859a95a89111b4987c91de97557e3bb539
2014-12-18 14:49:03 +01:00
Shawn Pearce 07612a610f Always ignore case when forbidding .git in ObjectChecker
The component name ".GIT" inside a tree entry could confuse a
case insensitive filesystem into looking at a submodule and
not a directory entry.

Disallow any case permutations of ".git" to prevent this
confusion from entering a repository and showing up at a
later date on a case insensitive system.

Change-Id: Iaa3f768931d0d5764bf07ac5f6f3ff2b1fdda01b
2014-12-18 14:48:52 +01:00
Shawn Pearce 8d36fa343c DirCache: Refuse to read files with invalid paths
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
2014-12-18 14:48:46 +01:00
Shawn Pearce d547d0c44b DirCache: Replace isValidPath with DirCacheCheckout.checkValidPath
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
2014-12-18 14:48:39 +01:00
Christian Halstrick 53ff052998 Support the new repository layout for submodules
When updating a submodule (e.g. during recursive clone) the repository
for the submodule should be located at <gitdir>/modules/<submodule-path>
whereas the working tree of the submodule should be located at
<working-tree>/<submodule-path> (<gitdir> and <working-tree> are
associated to the containing repository). Since CloneCommand has learned
about specifying a separate gitdir this is easy to implement in
SubmoduleUpdateCommand.

Change-Id: I9b56a3dfa50f97f6975c2bb7c97b36296f331b64
2014-12-15 00:22:51 +01:00
Christian Halstrick 6e05d98cce Allow explicit configuration of git directory in CloneCommand
This feature is needed to support the new submodule layout where the
.git folder of the submodules is under .git/modules/<submodule>.

Change-Id: If5f13426cfd09b7677e23478e9700c8c25a6dae5
2014-12-15 00:22:51 +01:00
Christian Halstrick 03e860a7b7 Allow explicit configuration of git directory in InitCommand
Native git's "init" command allows to specify the location of the .git
folder with the option "--separate-git-dir". This allows for example to
setup repositories with a non-standard layout. E.g. .git folder under
/repos/a.git and the worktree under /home/git/a. Both directories
contain pointers to the other side: /repos/a.git/config contains
core.worktree=/home/git/a . And /home/git/a/.git is a file containing
"gitdir: /repos/a.git". This commit adds that option to InitCommand.
This feature is needed to support the new submodule layout where the
.git folder of the submodules is under .git/modules/<submodule>.

Change-Id: I0208f643808bf8f28e2c979d6e33662607775f1f
2014-12-15 00:22:50 +01:00
Matthias Sohn ca7c928eae Merge "Fix tests on windows by closing repos" into stable-3.6 2014-12-12 08:50:20 -05:00
Christian Halstrick da595f093e Fix tests on windows by closing repos
Without explicitly closing repos we can't delete the test repositories
on windows.

Change-Id: Id5fa17bd764cbf28703c2f21639d7e969289c2d6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-12 14:49:02 +01:00
Christian Halstrick c893534059 Merge "Prevent NPE if ref can't be resolved when executing ReflogCommand" into stable-3.6 2014-12-12 08:31:16 -05:00
Christian Halstrick 1a054f1229 RepoCommand should close opened repos
RepoCommand opend two repos without closing them or returning them to
the caller. This caused certain tests to fail on Windows.

Change-Id: Ia04924aaaad4d16f883b06404c2a85d3f801231f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-12 14:06:51 +01:00
Matthias Sohn a24a99a13d Prevent NPE if ref can't be resolved when executing ReflogCommand
If the specified ref can't be resolved we should throw a
RefNotFoundException instead of an NPE.

Bug: 455005
Change-Id: I6ec9bf1c0f330eea5eb8277268f62663bdf58f66
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-12 13:02:27 +01:00
Christian Halstrick 42b20d4127 Merge "Fix DirCacheCheckout to set correct file length if core.autocrlf=true" into stable-3.6 2014-12-12 04:57:30 -05:00
Christian Halstrick 80b1da1aae Merge "CheckoutCommand: Fix checking out ours/theirs when no base stage exists" into stable-3.6 2014-12-12 04:54:46 -05:00
Matthias Sohn 59c4ea042c Fix DirCacheCheckout to set correct file length if core.autocrlf=true
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
a606dc363d.

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>
2014-12-11 16:30:57 +01:00
Robin Stocker 47927ac95e CheckoutCommand: Fix checking out ours/theirs when no base stage exists
In case of an add/add conflict, no base stage exists. The previous
implementation would skip over the entries because the condition
expected the base stage to always exist.

Change-Id: Ie2b3685d958c09b241991b74e6177401e8a1ebc9
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-12-10 12:56:10 +01:00
Alexander Kurtakov 5c788e2ce5 Do not use deprecated tasks in maven-antrun-plugin.
Maven-antrun-plugin deprecated tasks in favor of target, this patch
fixes JGit poms to do the same.

Change-Id: I420fd2ce88c61cf8e786ed45fbb8235dc30c124e
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
2014-12-09 14:48:42 +02:00
Matthias Sohn efb91ee2d1 Implement FileSnapshot.toString() to help debugging
Change-Id: Ic18d051327e491d5834929ff7fa28381f0f972c4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-06 02:38:23 +01:00
Christian Halstrick 1b9130e8db Make sure modifications to config-param trustFolderStat are detected
ObjectDirectory.searchPacksAgain() should always read trustFolderStat
from the config and not rely on a cached value.

Change-Id: I90edbaae3c64eea0c9894d05acde4267991575ee
2014-12-05 14:39:45 +01:00
Ilmars Poikans 786ad999cd Fix integer overflow in DiffFormatter when context is set to large int
In original code, if you call the DiffFormatter's setContext() method
with Integer.MAX_VALUE (to get full-context diffs) the format() method
will get into an infinite loop.

Bug: 382680
Change-Id: I804e82cde9b84b8ff232a20fb5cbde04478315e7
Signed-off-by: Ilmars Poikans <ilmars@delibero.lv>
2014-12-01 00:14:50 +02:00
Matthias Sohn c9a5fdb3cd Merge "Honor git-core meaning of receive.denyDeletes allowing tag deletion" 2014-11-29 19:18:31 -05:00
Shawn Pearce d1b627ed83 Honor git-core meaning of receive.denyDeletes allowing tag deletion
receive.denyDeletes parameter refers only to branch:
http://thread.gmane.org/gmane.comp.version-control.git/99746

Bug: 412640
Change-Id: Ief3fa6abc0c9a18ba0a671ff9854432cec480c4f
2014-11-29 10:49:04 -08:00
Shawn Pearce b6b843e519 Move checkPath from DirCacheCheckout to ObjectChecker
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
2014-11-28 20:59:34 -08:00
Michael Keppler 1a72143780 Use baseline instead of centerline in PlotRenderer
If the text extent height of a to be rendered plot line is odd, then the
SWTPlotRenderer cannot calculate the correct Y position for drawing the
label and draws the label with a 1 pixel offset. SWT text drawing uses
the baseline as Y coordinate. Due to the given centerline API in the
AbstractPlotRenderer the overall calculation of the baseline for SWT is
effectively (height / 2) * 2, thereby rounding all odd heights downward
to the next even number.

This change pushes the division by 2 from the caller into the
implementations of drawText. A corresponding change will be pushed in
the egit repository.

Bug: 450813
Change-Id: I66f4e71873bb8e6f936fde573bbe4c35fe23a022
Signed-off-by: Michael Keppler <michael.keppler@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-29 01:30:13 +01:00
Andrey Loskutov 147e24a7b2 Consider parent rules if ignore rule is negated
The change tries to make jgit behave more like native CLI git regarding
the negation rules. According to [1] "... prefix "!" which negates the
pattern; any matching file excluded by a previous pattern will become
included again." Negating the pattern should not automatically make the
file *not ignored* - other pattern rules have to be considered too.

The fix adds test cases for both bugs 448094 and 407475.

[1] https://www.kernel.org/pub/software/scm/git/docs/gitignore.html

Bug: 448094
Bug: 407475
Change-Id: I322954200dd3c683e3d8f4adc48506eb99e56ae1
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-29 01:24:20 +01:00
Shawn Pearce 3886a4f68b ResolveMerger: Use checkoutEntry during abort
The cleanUp path is trying to restore files that previously were
clean, but were overwritten in the work tree by a partial merge
attempt that has failed and needs to be aborted. Reuse the checkout
logic to write the file content and refresh the stat data.

Change-Id: I320d33b3744daf88d3155db99e957408937ddd00
2014-11-27 13:41:58 -08:00
Shawn Pearce a606dc363d Cleanup double stat update of symlinks in DirCacheCheckout
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
2014-11-27 13:38:50 -08:00
Shawn Pearce 75b4a23748 Deprecate checkoutEntry variant that accepts File
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
2014-11-27 13:37:12 -08:00
Shawn Pearce 6814728a82 DirCacheCheckout: create only one ObjectReader
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
2014-11-27 13:32:20 -08:00
Shawn Pearce 98c75a7ca2 Fix two nits about DirCacheEntry constructors
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
2014-11-25 11:35:54 -08:00
Shawn Pearce b34ea11720 Detect buffering failures while writing rebase todo file
By routing writes through SafeBufferedOutputStream the caller can be
alerted to any flush at close failures while writing or appending to
the rebase todo script.

Switch the character encoding to be done at the line granularity, as
this is sufficiently long enough that encoding overheads will not be a
bottleneck, but short enough that the amount of temporary data will
not cause memory problems for the JVM.

Change-Id: Ice5ec10a7cbadc58486d481b92940056f9ffc43a
2014-11-25 11:21:27 -08:00
Shawn Pearce 61b632ee5a Deprecate TemporaryBuffer.LocalFile without parent directory
Encourage callers to explicitly name a directory to hold any
overflow data. Call sites have more information about what is
going into the buffer and how it should be protected at the
filesystem level than just throwing content to the system wide
temporary directory.

Callers that still really don't care (or need to care) can pass
null for the File argument to have the system directory used.

Change-Id: I89009bbee49d3850d42cd82c2c462e51043acda0
2014-11-25 10:21:48 -08:00
Shawn Pearce 4206ea43b8 Switch FileHeader.extractFileLines to TemporaryBuffer.Heap
File contents are processed into a single byte[] for character
conversion. The data must fit entirely in memory, so avoid any
file IO.

Change-Id: I3fe8be2e5f37d5ae953596dda1ed3fe6d4f6aebc
2014-11-25 10:21:48 -08:00
Shawn Pearce 67b8bcc1c4 AmazonS3: Buffer pushed pack content under $GIT_DIR
This applies the same filesystem permissions as the source objects.
Users may override in properties files using the tmpdir value.

Change-Id: I3ec332cf41f12eae246cfaee9fd792c52cb2908b
2014-11-25 10:21:48 -08:00
Shawn Pearce f31323745f DirCache: Buffer TREE extension to $GIT_DIR
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
2014-11-25 10:21:48 -08:00
Shawn Pearce b2f0fd03d8 Support DfsRepository from GarbageCollectCommand
Bug: 406379
Change-Id: I7f4f23cd50d46ffcde69d6abfe3ca0cc6fa86604
2014-11-25 02:48:41 -05:00
Shawn Pearce 485b751b2f Allow configurable ObjectCheckers in fetch
RecievePack already honors fsck settings for safeForWindows and
safeForMacOS.  Allow those same checks to be performed during fetch
through a caller-configurable ObjectChecker.

Default the fetch fsck options to match the current platform, as
it can be reasonably assumed the repository will be accessed here.

Change-Id: I3c0f411fad209c6bd8fb9c4acf5c55a6799a6a2a
2014-11-24 14:56:13 -08:00
Shawn Pearce b88f3a2a2c Cleanup TreeWalk creation/release inside StashApplyCommand
The TreeWalk constructor doesn't throw in a meaninful way that
requires cleanup of the not-yet-created TreeWalk.

Hoist the constructor outside of the try/finally and remove the
now unnecessary != null check during the finally.

Change-Id: If5b8bb91562715df0699726648123a47426b9850
2014-11-24 12:59:45 -08:00
Shawn Pearce 3bc5188900 Deprecate checkoutEntry without ObjectReader
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
2014-11-24 12:59:45 -08:00
Yuxuan 'fishy' Wang 749dfeffc8 upload-pack: send symbolic refs as capabilities
cgit has this feature for some time. This will teach JGit to send symbolic refs,
too.

Change-Id: I7cb2ab4e6d31a838a0af92eac64535fdb66ed74a
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
2014-11-21 09:47:41 -08:00
Andrey Loskutov 2c940fa18a Don't use java.util.regex for two simple wildcard cases
To improve ignore parser performance we can avoid using java.util.regex
code on simple wildcard patterns with leading or trailing asterisk. As
those patterns represent a majority of ignore rules, the index diff
performance can be drastically increased on huge repository with lot of
ignore rules.

Bug: 450466
Change-Id: I80428441cc8d5de5468813f841d89322413eed8b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-18 10:58:26 +01:00
Shawn Pearce a31db826d4 Merge "Fix variable name and error message for sideband testing" 2014-11-13 16:50:59 -05:00
Christian Halstrick 140df39198 Let RepositoryBuilder find bare repos
BaseRepositoryBuilder.findGitDir() was not searching correctly for bare
repositories. E.g. when running org.eclipse.jgit.pgm.Log and the current
directory was that of a bare git repository an error "fatal: error:
can't find git directory" was raised. With this fix RepositoryBuilder
will also check whether the given directory is the root of a bare
repository.

Bug: 450193
Change-Id: I4d4ad42e24ca397745adb0f3385caee3bcf3a186
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 23:24:30 +01:00
Matthias Sohn 5672535360 Prepare post 3.6.0-m1 builds
Change-Id: Ie9927de64fa6b7d517f96b8cd12e57541f284ff2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 18:51:54 +01:00
Matthias Sohn 1555eeaa9c JGit v3.6.0.201411121045-m1
Change-Id: I9d789113d88cbbbdbabb8919f80c805aa4ba86fe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 16:41:54 +01:00
Matthias Sohn 0bb212019a Merge branch 'stable-3.5'
* stable-3.5:
  Prepare 3.5.3-SNAPSHOT builds
  JGit v3.5.2.201411120430-r
  Don't use SSL anymore to avoid POODLE attack

Change-Id: Icc8404a94512aae36da83baafb8b10422b7bbf7b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 15:07:18 +01:00
Matthias Sohn 3521712032 Prepare 3.5.3-SNAPSHOT builds
Change-Id: Ia37eb66a0deaf6e86a726b1b12eaea25416d4a36
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 08:32:54 -05:00
Matthias Sohn b5e5abcf4d JGit v3.5.2.201411120430-r
Change-Id: I217d25ee712cbde52bc9319ef1dd15d2f571d37a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 10:38:44 +01:00
Christian Halstrick 0fc8b05a71 Introduce config parameter core.trustfolderstat
JGit's ObjectDirectory implements the optimization that it remembers the
pack folders (.git/objects/pack) lastModified timestamp and doesn't
check for new packfiles in this folder if the lastModified attribute has
not changed.
In environments using NFS this can cause trouble. If multiple JGit
instances from multiple machines work on the same repository and one
instance creates a new ref and a new packfile (e.g. by doing a fetch)
then the other machines may detect the new ref but can't resolve the
referenced object because it doesn't detect that pack folder has a new
packfile. That's because NFS may cache file/folder metadata for quite a
long time and the pack folders modification time is not updated although
a new packfile is there and could be read.

The new config parameter core.trustfolderstat controls this behaviour.
The default is true and jgits behaviours is unchanged. But if this
parameter is set to false then jgit doesn't trust the pack directories
lastmodified anymore. Instead it will always iterate through the content
of that folder to detect new packfiles.

Change-Id: Ie3b4e92933286aa9916070a22422e629b3147f54
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 00:41:35 +01:00
Matthias Sohn da178eedd2 Fix javadoc formatting in ConfigConstants
Change-Id: I6ae39b874a3c1fa9e1cda235ff137c9eb8dd359f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-12 00:38:45 +01:00
Stefan Beller 423ad8b0ad Fix variable name and error message for sideband testing
Actually the test only allows a range from [1,255], so let's name the
variable so.

Change-Id: Iecdb8149b83389c67e3cd2f64f4a654c175475be
Signed-off-by: Stefan Beller <sbeller@google.com>
2014-11-10 18:18:34 -08:00
Shawn Pearce 0cf902e473 Expand wildcard imports to specfic classes
JGit style is to import exactly the classes required, and never
to use "import foo.*" as the foo package could add new classes
in the future which are conflicting/confusing with the imports
already used by a source file.

Change-Id: I5693408c777e5843ec65fff1163d5d717849fa34
2014-11-10 15:35:20 -08:00
Christian Halstrick 9597c41ea9 Fix possible NPE in IndexDiff when not all submodules are cloned
The latest changes to IndexDiff just assumed that all configured
submodules are allways cloned. If a configured submodule did not exist
an exception was thrown. This is fixed by this commit.

Bug: 450567
Change-Id: Iabe3b196d998c19483082e5720038ebddaeb1890
2014-11-09 22:44:07 +01:00
Christian Halstrick 714f677ca5 Add missing @since tags
Change-Id: Ia657e46b9abc8c8640f63f6ff579b2f8f2b01de4
2014-11-09 22:21:31 +01:00
Shawn Pearce cba3060969 Merge "Implement atomic refs update, if possible by database" 2014-11-07 22:04:34 -05:00
Stefan Beller 88c1b82e7a Implement atomic refs update, if possible by database
Inspired by the series[1], this implements the possibility to
have atomic ref transactions.
If the database supports atomic ref update capabilities, we'll
advertise these. If the client wishes to use this feature, either
all refs will be updated or none at all.

[1] http://thread.gmane.org/gmane.comp.version-control.git/259019/focus=259024

Change-Id: I7b5d19c21f3b5557e41b9bcb5d359a65ff1a493d
Signed-off-by: Stefan Beller <sbeller@google.com>
2014-11-07 18:51:18 -08:00
Dani Megert 3e131a35e3 Don't use SSL anymore to avoid POODLE attack
For details about poodle see:
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3566

Bug 450170
Change-Id: Ib169e88d9d51f4d0e6caa3a498f48edc81e0991d
Signed-off-by: Dani Megert <Daniel_Megert@ch.ibm.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-07 00:20:25 +01:00
Christian Halstrick 8456927b1b Make sure checkout doesn't report conflicts on ignored paths
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>
2014-11-06 15:27:46 -05:00
Matthias Sohn abb57e6b56 Do not swallow exception if IndexDiff hits invalid ignore param
Change-Id: I8a595e1f01a0731118d3c537be420222f7fec744
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-06 09:48:01 +01:00
Matthias Sohn d8fcc964a8 Fix non-externalized string warnings in IndexDiff
Change-Id: Ia803182114f0e8b418428e03601f9afc6542ed28
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-06 09:46:45 +01:00
Axel Richard 5328c8c916 Add new method IndexDiff#getPathsWithIndexMode
Get the list of paths that have the given file mode.

This helps EGit to efficiently determine which modified files are
symlinks and should be shown with a symlink icon in the staging view.

Bug: 429302
Change-Id: Id15f0c6f265667f5b8b57cc2d9f97de568371919
Signed-off-by: Axel Richard <axel.richard@obeo.fr>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-06 09:40:29 +01:00
Christian Halstrick 2532c28cb9 add missing @since tag in StatusCommand
Change-Id: Ie8d9c3878116488b973dfc80c7c97f174e769d3f
2014-11-04 09:43:58 +01:00
Matthias Sohn 8a398a9147 Add missing @since tags in SubmoduleWalk
Change-Id: Ica34e6709a34977422fd528cbd4df0044403e45d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-03 23:49:36 +01:00
Matthias Sohn c017ac4c85 Add missing @since tags
Change-Id: I27207bafe0ce31caab25ab9c0be1f22adf151783
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-03 17:08:39 +01:00
Christian Halstrick 696de653f3 Enhance SubmoduleWalk with a fast check whether a repo contains
submodules

Change-Id: Id37efb4f4dd77f3b8eb5607d15d32adeda3992d4
2014-11-03 04:33:10 -05:00
Christian Halstrick 6f0b92ff22 RebaseCommand should ignore submodule modifications
Before a rebase happens the RebaseCommand checks that the working tree
is clean. We don't want to start a rebase on a dirty working tree. If
the working tree is dirty a rebase should not be allowed. But
RebaseCommand should ignore modifications done to submodules. E.g. if a
submodules HEAD points to <x> but the root repository has in index that
the submodule should point to <y> then this should not prohibit a
rebase. Also native git allows a rebase in this case. Since jgit's
StatusCommand has learned to ignore submodule changes this is now used
by the RebaseCommand to determine the repository state correctly.

Bug: 446922
Change-Id: I487bf7484dca3f5501e6e514584e2871524eea19
2014-11-03 04:32:54 -05:00
Christian Halstrick 95172dea17 Support for Submodule configuration submodule.<name>.ignore
For each submodule native git allows to configure which modifications to
submodules should be ignored by the status command. It is possible to
ignore "none", "all", "dirty", "untracked" [1]. This configuration is
now supported by IndexDiff. The StatusCommand offers the possibility to
specify this mode.

[1] http://git-scm.com/docs/gitmodules

Change-Id: Ifd81d574a680f9b4152945ba70f8ec4af4f452c9
2014-11-03 04:32:03 -05:00
Andrey Loskutov 2f5a08798e Reimplementation of ignore rule parser
The current IgnoreRule/FileNameMatcher implementation scales not well
with huge repositories - it is both slow and memory expensive while
parsing glob expressions (bug 440732). Addtitionally, the "double star"
pattern (/**/) is not understood by the old parser (bug 416348).

The proposed implementation is a complete clean room rewrite of the
gitignore parser, aiming to add missing double star pattern support and
improve the performance and memory consumption.

The glob expressions from .gitignore rules are converted to Java regular
expressions (java.util.regex.Pattern). java.util.regex.Pattern code can
evaluate expression from gitignore rules considerable faster (and with
less memory consumption) as the old FileNameMatcher implementation.

CQ: 8828
Bug: 416348
Bug: 440732
Change-Id: Ibefb930381f2f16eddb9947e592752f8ae2b76e1
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-27 19:26:42 +01:00
Robin Stocker 6eca51923f Merge "Initialize 'pathLen' field also for empty directories" 2014-10-23 06:50:00 -04:00
Andrey Loskutov 4ea8c655d6 Initialize 'pathLen' field also for empty directories
Bug: 445363
Change-Id: Ia8428af84fb61ba0d572374a19e8e8c55b138a63
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2014-10-23 12:31:49 +02:00
Shawn Pearce 2c25a1fde0 Merge "Add retainOnReset(RevFlag) to RevWalk to simplify reset usage" 2014-10-20 13:45:28 -04:00
Shawn Pearce 048dbf4173 Add retainOnReset(RevFlag) to RevWalk to simplify reset usage
Applications sometimes use a RevFlag instead of a Set<RevObject>
to track boolean state bits about objects being processed. However
this requires careful use of the resetRetain() methods to avoid an
accidental clearing of the RevFlag bits, effectively clearing the
Set<RevObject> the application wanted to track.

Simplify that use case by offering retainOnReset, a collection of
flags that are never cleared by the RevWalk.

Change-Id: I4c05b89b1398e4a4f371eac3a5d1d5edddec838f
2014-10-19 11:36:08 -07:00
Robin Stocker 590e1b7602 BundleWriter: Support including HEAD in bundle
Bug: 446813
Change-Id: Ide64aec2a995dd7ff6c1325c3ada242a4eb4565e
Signed-off-by: Robin Stocker <robin@nibor.org>
2014-10-19 14:40:29 +11:00
Matthias Sohn 5c85d5d58a Merge branch 'stable-3.5'
* stable-3.5:
  Prepare 3.5.2-SNAPSHOT builds
  JGit v3.5.1.201410131835-r
  Only hide gitdir if the repository isn't bare

Change-Id: I171e5fb8718cb6829bb1357859c95b4a29910ac6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-14 17:51:53 +02:00
Matthias Sohn dcb52291a9 Prepare 3.5.2-SNAPSHOT builds
Change-Id: Ib2ccdebe80bad0b09d2d31889a3ab89d77e341f6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-14 01:29:37 +02:00
Matthias Sohn 450ce163ef JGit v3.5.1.201410131835-r
Change-Id: I37e049c8e81f963cfb7c17f1af91fd4245766aee
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-14 00:38:49 +02:00
Christian Halstrick 2a01c98ea1 Merge "Only hide gitdir if the repository isn't bare" into stable-3.5 2014-10-13 11:57:55 -04:00
Matthias Sohn 13ffda0666 Fix ResetCommand to default to mixed reset
ResetCommand threw an NPE if neither mode nor path was defined. Instead
it should default to a mixed reset like native git does.

Change-Id: I455902394f9e7b0c7afae42381f34838f7f2a138
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-13 16:41:58 +02:00
Matthias Sohn 2983d224eb Merge branch 'stable-3.5'
* origin/stable-3.5:
  When marking commits as uninteresting don't care if the tree exists

Change-Id: I66559a72ed7284cb721cf929512af884c0db2d61
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-12 23:45:45 +02:00
Christian Halstrick 88b25a58f0 When marking commits as uninteresting don't care if the tree exists
When during an ObjectWalk commits are marked as uninteresting we should
be tolerant against the situation that the commit exists in the repo but
the referenced tree is not exisiting. Since commit
c4797fe986 we are throwing
MissingObjectException in such a case. This semantic differs from native
git behaviour and may cause push operations to fail while they would
work in native git. See:
http://dev.eclipse.org/mhonarc/lists/egit-dev/msg03585.html

Bug: 445744
Change-Id: Ib7dec10fd2ef1adbb8adbabb9d3d5a64e554286a
2014-10-10 10:52:43 -04:00
Christian Halstrick 6ed6494b8a Revert "When marking commits as uninteresting don't care if the tree exists"
This reverts commit 441fdb54ef.
2014-10-10 00:09:44 +02:00
Christian Halstrick 441fdb54ef When marking commits as uninteresting don't care if the tree exists
When during an ObjectWalk commits are marked as uninteresting we should
be tolerant against the situation that the commit exists in the repo but
the referenced tree is not exisiting. Since commit
c4797fe986 we are throwing
MissingObjectException in such a case. This semantic differs from native
git behaviour and may cause push operations to fail while they would
work in native git. See:
http://dev.eclipse.org/mhonarc/lists/egit-dev/msg03585.html

Bug: 445744
Change-Id: Ib7dec10fd2ef1adbb8adbabb9d3d5a64e554286a
2014-10-10 00:00:45 +02:00
Matthias Sohn 668acc6fc5 Only hide gitdir if the repository isn't bare
This problem was raised on the jgit list
https://dev.eclipse.org/mhonarc/lists/jgit-dev/msg02675.html

Change-Id: I8ce8a159120ce3747d31d6f012c6d2c0d0ce7917
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-10-07 09:28:58 +02:00
Matthias Sohn 9fd1325ecb Merge branch 'stable-3.5'
* stable-3.5:
  Prepare 3.5.1-SNAPSHOT builds
  JGit v3.5.0.201409260305-r
  Fix PackWriterBitmapWalker handling non-existing uninteresting objects
  Enable maven site generation for jgit
  Generate javadocs as part of Maven site project reports
  Compare API changes with clirr against 3.4.1
  [cli] Use chaining credentials provider to enable .netrc
  Add chaining credentials provider
  [Java 8] Configure doclint to accept missing descriptions
  Do not use .netrc implicitly if no CredentialsProvider was set
  Prepare post 3.5.0-rc1 builds
  JGit 3.5.0.201409071800-rc1
  Fix the ls-remote command when there is no local repo

Change-Id: Iaa4485cac6ff9c7917380e89e12e416e0f52a557
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-26 15:45:46 +02:00
Matthias Sohn 848186da86 Prepare 3.5.1-SNAPSHOT builds
Change-Id: Ibf89f996c9d9a7e431ee09261987bb76246de441
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-26 14:56:34 +02:00
Matthias Sohn 24a2f9e53d JGit v3.5.0.201409260305-r
Change-Id: Ibf382bda3dcbb4b70829b1dd3a8abfd07bc4879e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-26 09:02:45 +02:00
Christian Halstrick fa4f00b7ed Fix PackWriterBitmapWalker handling non-existing uninteresting objects
When writing new packs it should be allowed to specify objects as "have"
(objects which should not be included in the pack) which do not exist in
the local repository.

This works with the traditional PackWriter, but when PackWriter was
working on a repository with bitmap indexes and used
PackWriterBitmapWalker then this feature was broken. Non-existing "have"
objects lead to MissingObjectExceptions. That broke push and Gerrit
replication. When the replication target had branches unknown to the
replication source then the source repository wanted to build pack files
where "have" included branch-tips which were unknown in the source 
repository.

Bug: 427107
Change-Id: I6b6598a1ec49af68aa77ea6f1f06e827982ea4ac
Also-by: Matthias Sohn <matthias.sohn@sap.com>
2014-09-25 19:01:42 -04:00