Commit Graph

3523 Commits

Author SHA1 Message Date
Christian Halstrick 35c00a7a73 Fix LocalDiskRepositoryTestCase to create correct type of repos
In one place LocalDiskRepositoryTestCase was ignoring the specification
whether to create a bare or non-bare repository. Fix this and fix also
one test which fails now because bare repos don't write reflogs by
default.

Change-Id: I4bcf8cf97c5b46e2f3919809eaa121a8d0e47010
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-12-12 13:34:43 +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
Jonathan Nieder 64162ab40d AWTPlotRenderer: use float arithmetic instead of double followed by a conversion
Multiplying by 0.9 and converting back to float is slightly more
complicated and achieves the same effect as multiplying by the float
0.9f directly.

Change-Id: I555863bb1251badee8887b9b93c5463eda0a3509
Signed-off-by: Jonathan Nieder <jrn@google.com>
2014-12-10 15:30:21 -08:00
Shawn Pearce 82f191bd79 Merge "Extract path info from requests without decoding" 2014-12-10 12:06:42 -05: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
David Pletcher 19f869996f Extract path info from requests without decoding
Gitiles malfunctions in conjunction with jgit and guice
because of a recent Guice bug fix. Work around the problem
by parsing the URI directly, bypassing the unescaping
performed by the getPathInfo method.

This rest of this message is copied from
https://gerrit-review.googlesource.com/#/c/60820/ :

The fix for Guice issue #745[1] causes getPathInfo() within the
GuiceFilter to return decoded values, eliminating the difference
between "foo/bar" and "foo%2Fbar". This is in spec with the servlet
standard, whose javadoc for getPathInfo[2] states that the return
value be "decoded by the web container".

Work around this by extracting the path part directly from the request
URI, which is unmodified by the container. This is copying the Guice
behavior prior to the bugfix.

[1] https://github.com/google/guice/issues/745
[2] http://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html#getPathInfo()

Change-Id: I7fdb291bda377dab6160599ee537962d5f60f1e8
Signed-off-by: David Pletcher <dpletcher@google.com>
2014-12-09 21:06:21 -08:00
Alexander Kurtakov 4b090e5da5 Build with Tycho 0.22.
Change-Id: I32444e926179827be31d9201a6bbc5d514672110
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
2014-12-09 15:10:08 +02: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
Christian Halstrick 145b1bf0fb Make jgit.sh work on windows when JGIT_CLASSPATH is set
jgit.sh was concatenating classpath entries with ":". On Windows systems
using "Git for Windows" this caused problems when JGIT_CLASSPATH was set.

Find out whether we are running on a platform which name starts with
"MINGW" ("Git for Windows" sets this) and use ";" as classpath
separator in this case.

Change-Id: I7e8fc2bee6513f587612accfc456a83d6277ef4a
2014-12-01 14:54:17 +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
Christian Halstrick c1b9b50b5e Merge changes Icf0970dd,Ice5ec10a into stable-3.4
* changes:
  Fix two nits about DirCacheEntry constructors
  Detect buffering failures while writing rebase todo file
2014-11-26 07:54:07 -05:00
Matthias Sohn f9088d6dda Apache HttpClientConnection: replace calls to deprecated LocalFile()
Change-Id: I79f422e004f386b3f2875de6997e5a0949fff566
2014-11-26 01:35:59 +01: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
Matthias Sohn 6c3999477c Merge changes If5b8bb91,Ib57fba6c
* changes:
  Cleanup TreeWalk creation/release inside StashApplyCommand
  Deprecate checkoutEntry without ObjectReader
2014-11-24 16:16:39 -05: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
Matthias Sohn bc2f5aeca1 Delete .eclipse_iplog
We don't use this file anymore since a long time since IP log
generation has been automated at the Eclipse foundation.

Change-Id: I36dd5291d53d06af6a3378c0229c1908e153caae
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-24 14:49:25 +01:00
Andrey Loskutov d81529029a Set permission bits for "executable" attribute according to the umask
Bug: 424395
Change-Id: I3f5c55dd4c084529af2319029305ba2e174e0636
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-22 23:55:47 +01: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
Matthias Sohn babc24b46e Define version of javadoc plugin used to generate site
This silences the Maven warning "'reporting.plugins.plugin.version' for
org.apache.maven.plugins:maven-javadoc-plugin is missing"

Change-Id: I036210fefb6bd81ca04fcd91aaba0f9d0c1e8862
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-18 05:30:56 -05:00
Matthias Sohn 85c89534d2 Include the java7 feature in org.eclipse.jgit.feature
This way we no longer need to advertise it in the release train and can
uncategorize the jgit features without making it harder for users to
find and install the java7 feature.

Bug: 451276
Change-Id: I4c7dd0e1609fc1939d8ea83c01251dec59c228a3
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2014-11-18 11:10:13 +01: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