Commit Graph

1650 Commits

Author SHA1 Message Date
Robin Rosenberg 42d7565ba9 Validate paths during DirCheckout
DirCacheCheckout and CanonicalTreeParser cooperate. CanonicalTreeParser
can detect malformed, potentially malicious tree entries and sets a
flag, while DirCacheCheckout refuses to work with such paths.

Malicious tree entries are ".", "..", ".git" (case insensitive), any
name containing '/' and (on Windows '\') and also (on Windows)
any paths ending in a combination of '.' or space or containing a ':'.
We also forbid all special names like "con" etc on Windows.

Some of the test can execute on any platform by enabling partial
platform emulation.

A new runtime exception, InvalidPathException, is introduced. For
backwards compatibility it extends InvalidArgumentException.

Change-Id: I86199105814b63d4340e5de0e471d0da6b579ead
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-04-23 22:37:50 +02:00
Robin Rosenberg 9c5b31703f Enable large file support
Allow adding files with size over 2 GB. The drawback is that the tests
for huge file support adds roughly 10 minutes of execution time.
For that reason we @Ignore the test in the standard test execution.

Change-Id: I5788e8009899203b346f353297166825b3744575
2012-04-18 21:59:15 +02:00
Tomasz Zarna a2dac2c78d Allow to write tests with CLI syntax
CQ: 6385
Bug: 365444
Change-Id: I2d5164cd92429673fe3c37e9f5f9bc565192cc12
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-04-18 18:57:36 +02:00
Robin Rosenberg 95ed300b04 Enable DirCacheEntry's copyMetaData to not copy stage info
When there is a conflict sometimes we did not set the stage of
the conflict entries properly for the STAGE_1 entry.

Change-Id: I1c28ff6251fdbc95f7c40fc3e401f1b41157a9f6
2012-04-17 09:51:03 +02:00
Robin Rosenberg bf33a6eeed Hide two warnings about boxing
Change-Id: I1cb7cdb81481019f4a55221d38d771fcc9451529
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-04-16 23:34:47 +02:00
Robin Rosenberg 0e8f3a6234 Fix constructor for SafeBufferedOutputStream
The size shoould be passed to BufferedOutputStream's constructor.
All callers seem to use the default, but that could change.

Change-Id: I874afee6a9114698805e36813781547e6aa328a5
2012-04-14 12:26:34 +02:00
Robin Rosenberg 32be70d209 Merge "UnsupportedCredentialItem with password authentication" 2012-04-09 10:40:28 -04:00
Robin Rosenberg 2047eaa4c2 UnsupportedCredentialItem with password authentication
If the server prompts for password, it comes as a StringType prompt.

Bug: 360862
Change-Id: Ic758456c21c8d68d1b3d7f56228beb7535b11735
2012-04-09 16:34:40 +02:00
Robin Rosenberg e951b407fa Merge "Fix broken TagCommand API" 2012-04-06 05:34:00 -04:00
Matthias Sohn fcacfdeaf7 Merge "Cleanup possiblyFilteredInputStream() in WorkingTreeIterator" 2012-04-05 20:32:03 -04:00
Robin Rosenberg b7e881e625 Merge "Handle content length in WorkingTreeIterator" 2012-04-05 19:29:08 -04:00
Robin Rosenberg fd53b454f2 Fix broken TagCommand API
Tags can be un-annotated whereby there is no RevTag object, only
a ref pointing to the tagged object.

Bug: 360650
Change-Id: I06309c45c0a896fe2a0a874700febf78c9fb87e8
2012-04-06 00:52:20 +02:00
Robin Rosenberg 8f9c4ee41d Cleanup possiblyFilteredInputStream() in WorkingTreeIterator
Use early return instead of nested if/else

Change-Id: I3b5048f9f5cfdfd01f916af550722532db3f9bb3
2012-04-06 00:26:06 +02:00
Matthias Sohn 6a1a80aa4c Merge "Recurse into cloned submodules" 2012-04-03 18:42:03 -04:00
Jens Baumgart 0a84ad2d2a Unlock DirCache in case of occurring exception
A DirCache was not unlocked if an exception occurred in the
DirCacheCheckout constructor.

Bug: 365449
Change-Id: I231d902d52e3e5e9a7748eedaa63a2bb889ebb13
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2012-04-03 17:25:32 +02:00
Robin Rosenberg 86db05602f Merge "Index config section and subsection names in one pass" 2012-04-02 17:59:34 -04:00
Robin Rosenberg 159533c4cf Merge "Add @Override annotations to enums" 2012-04-02 17:53:07 -04:00
Matthias Sohn 1b73db77ef Merge "Externalize parsing exception message for RebaseCommand#Action" 2012-04-02 16:02:39 -04:00
Shawn O. Pearce c0b1443926 Index config section and subsection names in one pass
Instead of indexing the subsection names on each request for a given
section name, index both the section and subsection names in a single
scan through the entry list. This should improve lookup time for
reading the section names out of the configuration, especially for the
url.*.insteadof type of processing performed in RemoteConfig.

Change-Id: I7b3269565b1308f69d20dc3f3fe917aea00f8a73
2012-04-02 11:44:45 -07:00
Tomasz Zarna 622232b936 Externalize parsing exception message for RebaseCommand#Action
Change-Id: Id0d7801e4de98bf118dbecadf623c9ffd7ab7554
2012-04-02 11:36:29 +02:00
Tomasz Zarna 4e1de30809 Add @Override annotations to enums
Change-Id: I8fa3b89a6349c1231251b346cae12c1c4f095929
2012-04-02 11:24:05 +02:00
Markus Duft 2ba67bedae Don't use java.nio channel for file size determination
Java NIO has some problems (like files closing unexpectedly because the
thread was interrupted). To avoid those problems, don't use a NIO
channel to determine the size of a file, but rather ask the File itself.

We have to be prepared to handle wrong/outdated information in this case
too, as the inode of the File may change between opening and determining
file size.

Change-Id: Ic7aa6c3337480879efcce4a3058b548cd0e2cef0
2012-04-02 07:27:25 +02:00
Kevin Sawicki 543c5238ae Recurse into cloned submodules
Iterate over all successfully cloned submodules recursively
and continue initializing and updating until no more are found.

Bug: 375426
Change-Id: Ifb99e41e2deb0c369442bca3c0f5f072dd006816
2012-04-01 18:36:42 -07:00
Robin Rosenberg 6189a68d1d Merge changes Ic8907231,I693148a5
* changes:
  Sort Config entries and use O(log N) lookup
  Extract inner classes from Config
2012-03-30 12:25:47 -04:00
Shawn O. Pearce 6c0d300a54 Fix loading packed objects >2G
Parsing the size from a packed object header was incorrectly computing
the total inflated length when the length exceeded the range of a Java
int. The next 7 bits of size information was shifted left as an int
using a shift of 25 bits, placing the higher bits of the size into the
sign position. When this size was extended to a long to be added to
the current size accumulator the size went negative, resulting in
NegativeArraySizeException being thrown.

Fix all places where this particular pattern of code is used to read a
pack size field, or a binary delta header, as they both use the same
variable length encoding scheme.

Change-Id: I04008728ed828f18202652c3d5401cf95a441d0a
2012-03-28 10:36:51 -04:00
Shawn O. Pearce 552682dc6a Sort Config entries and use O(log N) lookup
Decrease running time for getStringList (and all other get methods) by
looking for configuration entries using binary search rather than
linear search through the configuration file.

Configuration lines are sorted by section, subsection, name in a
sorted list whenever the snapshot is rebuilt. Binary search is used to
locate an index in the middle of the values, then walk backwards to
find the first value in the range.

Given a configuration of file of 5000 distinct section/subsection/name
triplets (e.g. a Gerrit Code Review project.config configuration file
with 5000 unique access control rules), this new code is faster to
lookup each rule individually using getStringList():

  old setStringList() 194 usec avg
      getStringList() 196 usec avg

  new setStringList() 188 usec avg
      getStringList()  24 usec avg

Change-Id: Ic8907231868c18eb946b72f341a6b58666b70324
2012-03-27 14:23:36 -04:00
Shawn O. Pearce 581e6ca2fe Extract inner classes from Config
The Config class is getting very large. Extract two of its inner
classes into new top level types to reduce the size of Config.
Rename them slightly in the process.

Change-Id: I693148a5ae2977378789bf455c880a6fd856c0f0
2012-03-27 10:43:02 -04:00
Robin Rosenberg 3f4725c179 Handle content length in WorkingTreeIterator
Content length is computed and cached (short term) in the working
tree iterator when core.autocrlf is set.

Hopefully this is a cleaner fix than my previous attempt to make
autocrlf work.

Change-Id: I1b6bbb643101a00db94e5514b5e2b069f338907a
2012-03-27 00:47:17 +02:00
Dave Borowitz 55bf06b43d Allow RepositoryResolver to throw ServiceMayNotContinueException
Implementations may want to send an error message to the user, which
doesn't really fit with any of the existing exception types.
ServiceMayNotContinueException, on the other hand, is documented as
always containing a user-visible error string, so use that.

Modify the git and HTTP transport mechanisms to properly relay this
message to the end user.

Change-Id: I362e67ea46102a145bf2c6284d38788537c9735f
2012-03-26 10:19:40 -07:00
Dave Borowitz d794a4fde3 Clarify documentation of exceptions in RepositoryResolver
Change-Id: Idf805f76f24bfa1f3552366197e0ed4e45cb2b74
2012-03-26 09:53:32 -07:00
Dave Borowitz e0531ace35 Properly parse first line in ReceivePack with no '\0'
Change-Id: Ic98e17aff4e4b3c3fa0359082bab689e4522e3d7
2012-03-23 14:38:06 -07:00
Matthias Sohn 9dd6e6cd29 Revert "Allow to write tests with CLI syntax"
This reverts commit bf845c126d since this
change needs to go through a formal IP review and Chris missed to file a
CQ for that.

Change-Id: I303515d78116f0591a2911dbfb9f857738f086a9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-03-23 00:30:46 +01:00
Christian Halstrick 473139bbf6 Merge "Allow to write tests with CLI syntax" 2012-03-22 07:39:14 -04:00
Tomasz Zarna bf845c126d Allow to write tests with CLI syntax
Bug: 365444
Change-Id: I86f382913bc47665c5b9a2827b878e7dbedce7b1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-03-22 11:29:18 +01:00
Kevin Sawicki b37b7e69cd Add command support for dropping a stashed commit
This extracts the logic for writing to the reflog from
RefDirectory into a new ReflogWriter class.  This class
creates a public API for writing reflog entries similar
to ReflogReader for reading reflog entries.

The new command supports rewriting the stash's log to remove
a configured entry followed by updating the stash ref to
the value at the bottom of the newly written log.

Change-Id: Icfcbc70e838666769a742a94196eb8dc9c7efcc7
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-21 14:16:14 -07:00
Kevin Sawicki bbfa4c9b2c Ignore trailing comments in transport SPI parsing
Check for a '#' character in each line read and
parse the leading characters as the class name of
a TransportProtocol being registered via SPI.

Bug: 373439
Change-Id: If36cb62c07ecea78ba0f326a87edf1d80b7b42b6
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-21 14:07:55 -07:00
Kevin Sawicki 7aeea3b27c Compare repository format version as parsed long
This allows repositoryies with a missing repositoryformatversion
config value to be successfully opened but still throws exceptions
when the value is a non-long or greater than zero.

git-core attempts to parse this config value as a long as well
and defaults to 0 if the value is missing.

Bug: 368697
Change-Id: I4a93117afca37e591e8e0ab4d2f2eef4273f0cc9
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-21 13:59:39 -07:00
Kevin Sawicki fd0c468b7a Copy all branch configuration values when renaming
Previously only certain values were copied over which caused
divergence in behavior between the JGit command and corresponding
CGit command.

Bug: 372051
Change-Id: I72a83215a679a713138da31f5ab838f14388d4bd
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-21 10:20:54 -07:00
Shawn O. Pearce 04ab2dac37 Clarify the purpose of ObjectInserter.buffer()
Recently Robin tried to increase the size of the buffer used by
ObjectInserter to fix a bug in the InputStream that handles AutoCRLF.
The purpose of this buffer is NOT to make a random InputStream work
correctly by passing it a larger buffer during read(byte[],int,int).

Clarify the Javadoc on the buffer() method to reduce the risk
someone tries to abuse it again.

While we are here, modify the method to load the field into a local
variable before returning. This should cut down 1 field load during
the common case of the buffer being already allocated.

Change-Id: Ic6898530d10fcd7e59f90397117a4a0d97e1f031
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-18 08:20:06 -05:00
Tomasz Zarna c75aa1aed2 LogCommand#setMaxCount affects all commits
Bug: 370132
Change-Id: I9f5ff3640a4f69c0b48c97609728d7672e63e6ab
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-18 08:08:35 -05:00
Dave Borowitz 9bc26efe9d Pass a DfsRepositoryDescription to InMemoryRepository
This was likely intended originally, but this class had never been
used, so the mistake went unnoticed.

Change-Id: I5e0e9f22ebf707c11d0581511c7a56b182188f77
2012-03-15 15:46:39 -07:00
Shawn O. Pearce ff13648ea2 Revert "Quickfix for AutoCRLF handling"
This reverts commit 88fe2836ed.

Auto CRLF isn't special enough to be screwing around with the buffers
used for raw byte processing of the ObjectInserter API. If it needs a
buffer to process a file that is bigger than the buffer allocated by
an ObjectInserter, it needs to do its own buffer management.

Change-Id: Ida4aaa80d0f9f78035f3d2a9ebdde904c980f89a
2012-03-15 07:22:24 -07:00
Kevin Sawicki 9be6526e9d Only unstash files changed when originally stashed
Previously a DirCacheCheckout was done using a merge tree reflecting
the state of the repository when the stash was originally done.
This was wrong since unstashing after making subsequent commits
would undo changes already committed by checking out entries from
an outdated tree.

The new approach is to scan for conflicts initially using a 6-way
tree walk that contains the trees for the stashed HEAD, stashed
index, stashed working directory, current HEAD, current index, and
current working directory.  Then perform a subsequent scan of the
stashed HEAD, index, and working directory trees and apply all
the stashed differences to the current index and working directory.

Bug: 372882
Change-Id: Ica65f162132c00a16964e838de66fc8b5cd0b0aa
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-13 19:14:15 -05:00
Shawn O. Pearce 6e13dfab4a Merge "Enable smart HTTP transport to place EOF at end of pack" 2012-03-13 14:50:27 -04:00
Shawn O. Pearce dfff04742f Enable smart HTTP transport to place EOF at end of pack
When fetching over smart HTTP the InputStream that gets fed into
a PackParser doesn't really support EOF at the end of the pack. It
instead tries to make a new HTTP request, which fails because there
is no request body currently buffered by the client.

Make EOF work correctly on the end of an HTTP derived InputStream
for the pack by denoting no more requests are expected as the higher
level code is now consuming the pack (or side-band embedded pack).
Smart HTTP support doesn't automatically enqueue execute support onto
the end of the UnionInputStream, which allows the UnionInputStream
to correctly reflect EOF when the HTTP response is consumed.

Change-Id: I975f1ab1c81ab1c1af925716970088bc7b8d6b1a
2012-03-13 11:41:51 -07:00
Tomasz Zarna 0705e95630 Do not import/export empty org.eclipse.jgit package
The package was removed in I763590a45d75f00a09097ab6f89581a3bbd3c797

Change-Id: Ifa9e75714f85d17609f9bf61581aaed0631a6fa7
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-03-13 09:10:10 -07:00
Robin Rosenberg 95d311f888 Move JGitText to an internal package
Change-Id: I763590a45d75f00a09097ab6f89581a3bbd3c797
2012-03-12 07:20:03 -07:00
Shawn Pearce 0a69f05647 Merge changes Ic0ee9c08,Ia3e82682,I8d8ab547,I8f2cd0a0,I45823b0c,Ie22ac47e
* changes:
  cleanup: Silence an unused-parameter warning
  cleanup: Get rid of some unused-warnings
  cleanup: Remove unused parameter in ConsoleCredentialsProvider
  cleanup: Drop unused parameter on DhtPackParser
  cleanup: Remove unneeded parameter to private method in RefUpdateTest
  cleanup: Remove unnecessary @SuppressWarnings
2012-03-12 10:16:42 -04:00
Shawn Pearce 95ceb24866 Merge "Use object id provided by working tree iterator for submodules" 2012-03-12 10:14:02 -04:00
Markus Duft d1403512f5 Fix compilation error due to missing javadoc.
Another change introduced this problem. With default JGit project
settings there is a compilation problem as javadoc problems are set to
Error in the project preferences.

Change-Id: I81e3ceeb02f7a2119b2a6cfefb7fbd9e83771fc9
2012-03-12 14:54:56 +01:00
Kevin Sawicki 3734db9282 Use object id provided by working tree iterator for submodules
The working tree iterator now supports providing an object id
for submodule entries and this value should be used instead
of recomputing it again in AddCommand.

Change-Id: I30082514c23fc65968bb78add5ad69a1ca95cf3a
2012-03-10 10:26:10 -08:00
Kevin Sawicki 5c18fcb81b Keep submodules in index that are missing in working directory
Submodules present in the index but missing from the working
directory should not be staged for deletion when AddCommand
is called with the update flag set to true.

This mirrors the behavior of CGit.  Submodules can still be
staged for deletion by running by using the RmCommand.

Change-Id: Iee508a67f9621269d1c28d422f88c6b8dd9f8e6e
2012-03-10 10:02:58 -08:00
Robin Rosenberg 9a9877da4e Merge "EolCanonicalizingInputStream: binary detection should be optional" 2012-03-09 15:52:11 -05:00
Stefan Lay d725ecb80e Merge "Fix rebase > continue when nothing left to commit." 2012-03-09 08:04:20 -05:00
Markus Duft edc1fee033 Fix rebase > continue when nothing left to commit.
If after resolving all conflicts nothing is left to commit, return
an according result, so that downstreams (EGit, ...) can behave like
cgit, and display a nice message informing the user.

Currently, EGit displays a "HEAD advanced fast forward" message, which
is absolutely not helpful at all.

This is the basic API revamping required to get that state communicated
to the outside world (EGit).

Bug: 336812
Change-Id: If2665005cf54a5b51c0fe80bad019fa42b0205af
2012-03-09 13:56:37 +01:00
Robin Rosenberg 708febedaf cleanup: Remove unnecessary @SuppressWarnings
Change-Id: Ie22ac47e315bff76f224214bc042fc483eb01550
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2012-03-09 13:30:07 +01:00
Robin Rosenberg 48bd58b8ee Merge "Revert non-sense logic in IO.readFully" 2012-03-09 04:47:45 -05:00
Shawn Pearce 500e17e7d6 Merge changes I8277fd45,I7ac4e0ae,Ib475dfc0,Ib26adf95
* changes:
  Try to send HTTP error messages over sideband
  Extract the capability parsing logic in {Upload,Receive}Pack
  Make capability strings in BasePack{Fetch,Push}Connection public
  Fix a typo in "capabilities" in ReceivePack
2012-03-07 22:22:22 -05:00
Dave Borowitz 039c785d9f Try to send HTTP error messages over sideband
When a client POSTs to /git-{upload,receive}-pack, the first line
includes their client capabilities. As soon as the C git client sends
side-band(-64k), it goes into a state where it chokes on data not sent
in a valid sideband channel.

GitSmartHttpTools.sendError() is called early in the request, likely
before a {Upload,Receive}Pack handler is assigned or, even so, before it
has read the request. In some cases we must read the first line manually
within sendError() to tell whether sideband is needed.

Change-Id: I8277fd45a4ec3b71fa8f87404b4f5d1a09e0f384
2012-03-07 15:04:45 -08:00
Dave Borowitz d2787d481e Extract the capability parsing logic in {Upload,Receive}Pack
Change-Id: I7ac4e0ae98872a74b01162b5ca936fb15e2f8cff
2012-03-07 12:53:49 -08:00
Dave Borowitz 2b0044f222 Make capability strings in BasePack{Fetch,Push}Connection public
Change-Id: Ib475dfc087705ea40e1db37ec9ef28a67fde6d72
2012-03-07 12:52:47 -08:00
Dave Borowitz eea8581da5 Fix a typo in "capabilities" in ReceivePack
Change-Id: Ib26adf954dcb90403be9d6ed3b7a425a724c67d0
2012-03-07 12:52:45 -08:00
Tomasz Zarna 90d002c15f Remove ambiguous CheckoutConflictException
Checkout command should throw o.e.j.api.errors.CheckoutConflictException
which is a GitAPIException not o.e.j.errors.CheckoutConflictException.
PullCommand should rethrow the API exception as a JGitInternalException.

Bug: 356922
Change-Id: I865c4905997d9834c85a97fbe7287604daf99075
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-03-06 22:43:25 +01:00
Christian Halstrick e05300b21d Merge "Check connection's error stream before reading from it" 2012-03-06 09:26:38 -05:00
Kevin Sawicki 9e4b4fc41c Set person and message on stash ref update
This will be the message and person used for the commit
of stashed working directory changes.

Bug: 372884
Change-Id: I2501b080f6b94e826cf7dba3fd526ae5c1d969d1
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-05 20:59:44 -08:00
Kevin Sawicki 8db5414dcf Return command from StashCreateCommand setters
Previously were void which made them inconsistent with
the fluid setter pattern used in other commands.

Change-Id: Idb81dfc7bb097306f0c5d6e34f91a2bbab501668
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-05 20:53:59 -08:00
Kevin Sawicki 9908c203a5 Support insteadOf and pushInsteadOf URL replacement
Bug: 346873
Change-Id: I4116328f93f411da56a633bc32fd064b2ac083f2
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-05 20:46:26 -08:00
Chris Aniszczyk db29665e64 Merge "Quickfix for AutoCRLF handling" 2012-03-05 23:44:45 -05:00
Kevin Sawicki 2c6187697c Check connection's error stream before reading from it
HttpURLConnection.getErrorStream can return null which is
currently not guarded against and will throw an NPE preventing
the actual error response code from bubbling up.

Change-Id: I04fb8dbda16b7df3b82fc579088a303b2fd21e87
2012-03-05 17:22:22 -08:00
Tomasz Zarna eedd77a97b RawText#getEOL() does the same thing as RawText#getLineDelimiter()
The duplication has been introduced when merging
I08e1369e142bb19f42a8d7bbb5a7d062cc8533fc and
I18adc63596f4657516ccc6d704a561924c79d445. The former should have been
manually rebased. It also missed a copyright update in ApplyCommandTest.

Change-Id: I18fe6108220f964524fb16b719604222aa7abee6
2012-03-05 12:59:10 +01:00
Christian Halstrick c71fff4ce2 Merge "Update example code for obtaining a locked DirCache" 2012-03-05 03:46:53 -05:00
Tomasz Zarna 92f90eb229 Add ApplyCommand to JGit API
Bug: 361548
CQ: 6243
Change-Id: I08e1369e142bb19f42a8d7bbb5a7d062cc8533fc
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-03-04 21:29:01 -08:00
Robin Rosenberg 8e1bc46061 Merge "Remove null access warning in DirCacheCheckout" 2012-03-04 13:06:59 -05:00
Robin Rosenberg 88fe2836ed Quickfix for AutoCRLF handling
CRLF only works for small files, where small is the size of the
buffer, i.e. about 8K. This QD fix reallocates the buffer to be
large enough.

Bug: 369780
Change-Id: Ifc34ad204fbf5986b257a5c616e4a8c601e8261a
2012-03-03 08:22:48 +01:00
Matthias Sohn e0910edf7c Include eclipse.inf
Commit 9169e7f9ec failed to add
org.eclipse.jgit/META-INF/eclipse.inf in order to fix bug 372845 since
JGit is not yet built by Tycho. Hence explicitly including it.

Bug: 372845
Change-Id: I6cb12327a237d69fbfe3d5e77d8a6ad7de442ad5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-03-03 00:53:00 +01:00
Kevin Sawicki d364fb2d4f Remove null access warning in DirCacheCheckout
Initially fill in the current DirCacheEntry field guarding 
against a null index tree and use that variable instead of
calling getDirCacheEntry() on a possibly null DirCacheBuildIterator.

Change-Id: I16f388a16636aefdb07d66dae5d05655009e2a0e
2012-03-02 15:01:13 -08:00
Kevin Sawicki 014d759d35 Update example code for obtaining a locked DirCache
Previous example was calling a method that no longer exists
on DirCache.

Change-Id: I864842c58df4f116b318dc4a150b789745769a0d
2012-03-02 12:49:38 -08:00
Tomasz Zarna 9c7371a8c4 Allow to get end-of-line characters for a RawText
Bug: 370320
Change-Id: I18adc63596f4657516ccc6d704a561924c79d445
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-03-02 12:06:09 -08:00
Sascha Scholz a1f877e312 Load .gitmodules config before adding values to it
This prevents existing entries from being cleared when the
.gitmodules config is saved after the new submodule configuration
is added.

Change-Id: I66841f5e758a7527e2e6e25cf1318e5fea91a909
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-03-02 09:31:09 -08:00
Christian Halstrick 1515d7b7d5 Merge "Exclude org.eclipse.jgit from pack200 packing" 2012-03-02 11:03:14 -05:00
Christian Halstrick 3083146d13 Merge "Reuse existing modes and ids" 2012-03-02 03:46:03 -05:00
Matthias Sohn 9169e7f9ec Exclude org.eclipse.jgit from pack200 packing
It seems pack200 became unable to correctly pack the bundle
org.eclipse.jgit (see bug 372845). Hence mark it to be excluded from
this packing step following the workaround which worked for
org.eclipse.jst.jsf.core (bug 335806).

Bug: 372845
Change-Id: I2e3d20645ac49125472ddc235afbe9f3c7480caf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-03-02 09:11:18 +01:00
Dave Borowitz d023f2c78b Extract filterCommands as a static method on ReceiveCommand
Change-Id: I24501f95185878d09b54562e48cb4e7e45dd3968
2012-02-29 19:09:24 -08:00
Dave Borowitz 903e1b81d4 Remove PreUploadHook.onPreAdvertiseRefs
AdvertiseRefsHook.advertiseRefs subsumes this behavior.

Change-Id: Id2d1ebb2503c9ba79eda58aaea2fd76ec233427f
2012-02-29 19:09:24 -08:00
Dave Borowitz 9d41dbd958 Add an AdvertiseRefsHookChain, similar to the other hook chains
Change-Id: I3bb0dc86047fe0446d18e0055f714092a658d228
2012-02-29 19:09:23 -08:00
Dave Borowitz 1f2022e3a7 Modify refs in UploadPack/ReceivePack using a hook interface
This is intended to replace the RefFilter interface (but does not yet,
for backwards compatibility). That interface required lots of extra
scanning and copying in filter cases such as only advertising a subtree
of the refs directory. Instead, provide a hook that can be executed
right before ref advertisement, using the public methods on
UploadPack/ReceivePack to explicitly set the map of advertised refs.

Change-Id: I0067019a191c8148af2cfb71a675f2258c5af0ca
2012-02-29 19:09:23 -08:00
Dave Borowitz 7acd333e7d Fix a typo referring to RevFilter as RefFilter
Change-Id: I173efca7540b522d386216d1bd229e9a061263b2
2012-02-29 19:09:23 -08:00
Dave Borowitz bb8f0bec4a Minor javadoc wording fixes in ReceivePack
Change-Id: I5b409ef39aee890bcd7d4277e36b85ac4dc48281
2012-02-29 19:09:23 -08:00
Dave Borowitz 27cbdaf497 Expose an OutputStream from ReceivePack for sending client messages
Callers may want to format and flush their own output, for example in a
PreReceiveHook that creates its own TextProgressMonitor. The actual
underlying msgOut can change over the lifetime of ReceivePack, so we
implement a small wrapper.

Change-Id: I57b6d6cad2542aaa93dcadc06cb3e933e81bcd3d
2012-02-29 19:09:23 -08:00
Dave Borowitz 4a01f47e82 Allow creating ReceiveCommands with a specified type
This allows callers who know in advance whether a command is UPDATE or
UPDATE_NONFASTFORWARD to specify this in the constructor rather than
with a separate method call.

Change-Id: Iae483594a4ff370ff75d17a7b0648c5590b3d1bd
2012-02-29 19:09:22 -08:00
Dave Borowitz 4bf22ff6e8 Execute ReceiveCommands via a method rather than in ReceivePack
This allows a PreReceiveHook to easily "take over" all of the
ReceiveCommands passed to it, preventing any of them from being handled
within the ReceivePack core.

Change-Id: I2a8c1fc44e8dcadf22cd97a8ec4ee79d4d9d08f1
2012-02-29 19:09:22 -08:00
Kevin Sawicki 0fb0e84405 Reuse existing modes and ids
This change replaces calls to getEntryObjectId and getEntryFileMode
with the existing method local variables for the index, merge, and
head tree iterators.

Change-Id: I75d1edfdd192a009fc916102ec052434c6302d00
2012-02-29 15:07:37 -08:00
Kevin Sawicki 4de8a84671 Add command support for applying a stashed commit
Applies the changes in a stashed commit to the local working
directory and index

Bug: 309355
Change-Id: I9fd5ede8affc7f0060ffa7c5cec34573b6fa2b1b
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-02-28 13:53:13 -08:00
Kevin Sawicki 03d4dc597e Add support for creating a stashed commit
Adds a new command to stash the index and working directory
changes in a commit stored in refs/stash

Bug: 309355
Change-Id: I2ce85b1601b74b07e286a3f99feb358dfbdfe29c
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-02-28 13:46:35 -08:00
Kevin Sawicki 10c0b34b88 Add all paths option to CheckoutCommand
This will perform the equivalent  of running a
'git checkout -- .' at the root of a repository

Change-Id: I3e2dd563700999bc063effdd3640499c8ed08136
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-26 16:10:57 +01:00
Daniel Megert 709cd52958 Let the date formatter pick the locale.
Instead of using the locale from the SystemReader we let the
SystemReader create the date formats without passing the locale.

Bug 368756
Change-Id: I6be9e07af804a08f3f3ac2d2d526ef594eed19e3
Signed-off-by: Daniel Megert <daniel_megert@ch.ibm.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-25 23:37:02 +01:00
Stefan Lay 54f23873d6 Add support for autosetuprebase to the CloneCommand
Bug: 345536
Change-Id: I93c609235dec4e5e3a2ddc275c28b202bf868d40
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-02-23 09:32:02 -08:00
Matthias Sohn 0211d91001 Merge "Add IGNORE_ERRORS to FileUtils.delete()" 2012-02-21 14:34:42 -05:00
Marc Strapetz 7df17e57d4 EolCanonicalizingInputStream: binary detection should be optional
EolCanonicalizingInputStream may also be used in combination with
.gitattributes. If .gitattributes states that a file is of type text, line
endings have to be canonicalized even if the actual file content seems
to be binary.

Change-Id: Ie4ccdfc5cb91fbd55e06f51146cf5c7c84b8e18b
2012-02-21 15:22:36 +01:00
Christian Halstrick b6d376a177 Add IGNORE_ERRORS to FileUtils.delete()
There are a few situations where you want to delete files or folders but
where you are not interested in getting exceptions if this doesn't
succeed. E.g. if you delete garbage in the GC class you want that if
certain files can't be deleted the command succeeds. Maybe the next
garbage collector run has more luck not to interfere with a virus
scanner run on Windows. Therefore an option is added to
FileUtils.delete() not to report errors in such cases.

Change-Id: I58994d8c481e591dcbb0f2be7dfa562e125f0f08
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2012-02-21 14:23:43 +01:00
Matthias Sohn 755dfdb409 Prepare 2.0.0-SNAPSHOT builds
Change-Id: I946e315af04227727ac937ebe9d70ae1ea4e8936
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-16 00:49:49 +01:00
Matthias Sohn 42b0fb4679 Merge branch 'stable-1.3'
* stable-1.3:
  Prepare post 1.3.0.201202151440-r build
  JGit 1.3.0.201202151440-r
  Generate conflicts and index updates on file mode changes

Change-Id: Ie99780ef5cdea7b3ea1ea076282fe0a25f14f469
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-16 00:44:47 +01:00
Matthias Sohn f70b24a601 Prepare post 1.3.0.201202151440-r build
Change-Id: I4d695273e3151c22f2df9a58725cc7ba21ab6043
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-16 00:42:34 +01:00
Matthias Sohn e4ee677dea JGit 1.3.0.201202151440-r
Change-Id: I663208919f297836a9c16bf458e4a43ffaca4c12
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-15 20:56:06 +01:00
Christian Halstrick ed7b322186 Generate conflicts and index updates on file mode changes
Handle more cases for file mode changes. Especially make sure that the
following cases are handled correctly.

Case 1)

  An entry in the working tree, HEAD tree, and merge tree have
  different modes and different content.

  Prior Outcome:
    Dirty working tree content is replaced and file mode
    changes are lost.

  New Outcome:
    Conflict is generated.

Case 2)

  An entry in the index and merge tree have the same content
  but different modes but both modes are file type modes.

  Prior Outcome:
    File mode in working tree is not updated and the working
    directory is dirty.

  New Outcome:
    Index is updated and the working directory is clean.

Bug: 363772
Change-Id: I224602d68228eb419813986807f1eeab77e9c302
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Also-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-13 09:39:05 +01:00
Matthias Sohn de48250da5 Merge branch 'stable-1.3'
* stable-1.3:
  Prepare post 1.3.0.201202121842-rc4 builds
  JGit 1.3.0.201202121842-rc4
  Support gitdir references in working tree .git file
  Support committing submodule updates
  Update iplog tool's README

Change-Id: Id70f4d4b059b03d4fa6fbd9137b81a337e9c48e8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-13 07:34:18 +01:00
Matthias Sohn 3b358ce514 Prepare post 1.3.0.201202121842-rc4 builds
Change-Id: I50e0e6c2bccab5f3da62cbfe976f065169426906
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-13 07:30:00 +01:00
Matthias Sohn 53917539f8 JGit 1.3.0.201202121842-rc4
Change-Id: I82c6c0c175ab6fb4e2113101f36c8d2ddf4a13c1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-13 00:57:43 +01:00
Robin Rosenberg ad9033e43a Revert non-sense logic in IO.readFully
This was introduced in alleged support for autocrlf, but the
logic makes no sense here.

Change-Id: If37f3b90f21f875cee7165e17a17adfda446384d
2012-02-12 20:42:47 +01:00
Kevin Sawicki 2f79cf9900 Support gitdir references in working tree .git file
A '.git' file in a repository's working tree root is now parsed
as a ref to a folder located elsewhere.  This supports submodules
having their repository location outside of the parent repository's
working directory such as in the parent repository's '.git/modules'
directory.

This adds support to BaseRepositoryBuilder for repositories created
with the '--separate-git-dir' option specified to 'git init'.

Change-Id: I73c538f6d845bdbc0c4e2bce5a77f900cf36e1a9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-02-08 23:10:28 +01:00
Tomasz Zarna f1945cac1d Add getters for old and new prefixes in DiffFormatter
Bug: 370318
Change-Id: Iaf9282ba55ee3bb4e2c27fb71c598b308771bf57
2012-02-02 11:59:28 +01:00
Kevin Sawicki 7bde08e1d4 Support committing submodule updates
Use the submodule object id provided by the working
tree iterator

Change-Id: Ibf82f56c04cb9c91b2b309cf0cfa3f638539e23c
2012-01-30 13:37:40 -08:00
Robin Rosenberg 96acc4e5cf Really close output stream when core.autocrlf is true
Change-Id: I8a0d91e908145168c32589600bd1598826511ae3
2012-01-23 00:57:39 +01:00
Kevin Sawicki 97210fd6db Add command support for listing stashed commits
Bug: 309355
Change-Id: I34a8c251b89abcdb67565ca49bee02e5e2113593
Signe-off-by: Chris Aniszczyk <zx@twitter.com>
2012-01-20 09:00:13 -08:00
Matthias Sohn ea56a1ddb2 Merge "Support relative submodule URLs on init/add/sync" 2012-01-18 16:26:42 -05:00
Kevin Sawicki b57845c0cc Support relative submodule URLs on init/add/sync
Interpret submodule URLs that start with './' or '../' as
relative to either the configured remote for the HEAD branch,
or 'origin', or the parent repository working directory if no
remote URL is configured

Bug: 368536
Change-Id: Id4985824023b75cd45cd64a4dd9d421166391e10
2012-01-17 09:35:29 -08:00
Robin Stocker 14cc47ea1a Add BranchTrackingStatus for getting remote tracking status
This is used by EGit change I1e1caca561d1b0a0c194bfc42e64b698f42c6e6a to
show branch status in decoration.

It can also be used for providing the same output as C Git in "git
status".

Change-Id: I8d2b108c89905c3f0496f3d517879596740787c0
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-16 22:33:03 +01:00
Robin Stocker c0f4880e61 Add BranchConfig helper for access to branch config section
Getting the name of the remote-tracking branch given a branch is not so
easy to get right. This class provides a way to do that and could be
used for more branch config related things (e.g. in PullCommand).

Change-Id: I896a2384217936c8b672df8b81c9599f5c350458
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-16 22:18:54 +01:00
Robin Stocker 69d7d1b0b6 Add RevWalkUtils with count(start, end) method
It returns the number of commits that are in start and not in end.
Useful for calculating how much a branch is ahead of another one.

Change-Id: I09f7d9b049beea417da7ff32c9f8bf0d4ed46a7f
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-16 22:05:20 +01:00
Christian Halstrick a9892fba46 Merge "Support more of AutoCRLF" 2012-01-16 10:53:13 -05:00
Robin Rosenberg 03b5416a35 Fix resolution of tree when path is empty
Revision strings that end with a ':' with no trailing path
should return the tree associated with the current ref parsed

Bug: 368370
Change-Id: I7c7617a77bd418bad4e570be2d1e9002ad280762
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2012-01-15 23:56:37 +01:00
Robin Rosenberg e875c905d3 Make sure all bytes are written to files on close, or get an error.
Java's BufferedOutputStream swallows any errors that occur when flushing
the buffer in close().

This class overrides close to make sure an error during the final
flush is reported back to the caller.

Change-Id: I74a82b31505fadf8378069c5f6554f1033c28f9b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-15 11:22:52 +01:00
Robin Rosenberg 02729810f9 Merge "Resolve ~ with no trailing number as the first parent commit" 2012-01-14 20:28:52 -05:00
Matthias Sohn b8830d7bbb Throw API exception when LsRemoteCommand fails with TransportException
In many cases applications want to handle TransportException hence
expose it as an API exception.

Change-Id: I64b885ecfb1a35bd93c89026c6298d1820ba69d0
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-15 01:38:25 +01:00
Kevin Sawicki c963e7aacf Resolve ~ with no trailing number as the first parent commit
This would previously throw a RevisionSyntaxException

Change-Id: I42b4988c7f6c6454e2ebda13914260e25ac1a889
2012-01-14 15:34:18 -08:00
Robin Rosenberg d5c890e0fd Cannot commit -o file with only file permission change
Bug 345076
Change-Id: Ie64039793ab6ba4748731320399f03301b6282ec
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-13 11:24:31 +01:00
Robin Rosenberg 76dd9d1d46 Support more of AutoCRLF
This patch introduces CRLF handling to the DirCacheCheckout and
WorkingTreeIterator supporting the AutoCRLF for add, checkout
reset and status and hopefully some other places that depende
on the underlying logic of the affected API's.

The patch includes test cases for the Status command provided by
Tomasz Zarna for bug 353867.

The core.eol and core.safecrlf options are not yet supported.

Bug: 301775
Bug: 353867
Change-Id: I2280a2dc0698829475de6a662a6c6e80b1df7663
2012-01-10 23:15:52 +01:00
Matthias Sohn 6a582970bf Merge "Provide helper for unlocking a file" 2012-01-10 12:24:49 -05:00
Kevin Sawicki aebfc70cc8 Provide helper for unlocking a file
This will allow recovery from a LockFailedException where
the file associated with an exception is passed to FileUtils.unlock
to attempt an unlock on the file so the operation can be retried

Change-Id: I580166d386126bfb54a318a65253070a6e325936
2012-01-09 08:46:13 -08:00
Tomasz Zarna f78e52b645 Add setter for ProgressMonitor to DiffCommand
Change-Id: I34f8b77a461e165d7d624dbd9a6944feadc57b8e
2012-01-09 15:48:16 +01:00
Stefan Lay 8f742cdd10 Merge "Add options for setting context lines and prefixes to DiffCommand" 2012-01-09 07:06:59 -05:00
Tomasz Zarna 69a5683b82 Add options for setting context lines and prefixes to DiffCommand
Change-Id: I539f3531e94c11c0f0a3e7096c0eb1b1c309898a
2012-01-09 12:13:30 +01:00
Christian Halstrick 885a389832 Merge "Add helper for determining if status is clean" 2012-01-09 06:13:12 -05:00
Matthias Sohn 0f15d656f2 Narrow exceptions declared by LsRemoteCommand
API commands either throw GitAPIException or JGitInternalException.

Also add missing javadoc and reduce nesting of catch blocks.

Change-Id: I9a3b302e1b3f373ee11a977a0e3d6213bfbd3cdf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-01-08 17:15:05 -08:00
Robin Rosenberg 0806c803a9 Merge "Retain executable mode of existing files on Windows" 2012-01-08 16:34:28 -05:00
Matthias Sohn f9726423ab Merge "Use constants from ConfigConstants in CoreConfig" 2012-01-05 10:15:55 -05:00
Kevin Sawicki 3d15298011 Add helper for determining if status is clean
This checks if all collections that Status exposes are
empty or not

Change-Id: I0c342ab70dc36c1fd70acb4f8a924bb207d62f47
2012-01-03 16:48:01 -08:00
Kevin Sawicki 69451b8302 Provide file mode of paths in index from IndexDiff
Change-Id: I1d543e2f721987114cc1e1cb0848c234470df794
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-04 00:27:56 +01:00
Kevin Sawicki 6c959f7702 Use constants from ConfigConstants in CoreConfig
Change-Id: Ic1253498ecdd7545c6b1f114f4c83a3b77273874
2012-01-03 15:24:55 -08:00
Kevin Sawicki c15c46e41e Retain executable mode of existing files on Windows
Currently files in a repository marked as executable will have
that mode unset when modified and committed on systems that
do not support detection of this mode since the working tree
iterator will never report this mode for any entries.

This change updates WorkingTreeIterator to be able
to determine the target file mode to be used for the index
through consideration of the configured WorkingTreeOptions.

Bug: 364956
Change-Id: Iae496baa011b8a59d9329ec73615482b03d34a5a
2012-01-03 15:07:02 -08:00
Kevin Sawicki d57c00e036 Add support for cloning submodules to CloneCommand
Change-Id: Ib1f82206fa14be75e2080f95db9f2d178e876453
2012-01-02 17:32:41 -08:00
Kevin Sawicki dea4511572 Extend TransportCommand in submodule add/update commands
This allows all the settings of a TransportCommand to be
configured on the clone commands that are run by submodule
add/update

Change-Id: I93bfe5a91d430200de8c7f1e32a60cb990aa58ea
2012-01-02 09:40:53 -08:00
Kevin Sawicki 287d17f601 Add submodule command helpers to Git class
Change-Id: I649d96617072db68ab15aa2569836fa783577424
2012-01-02 09:34:25 -08:00
Tomasz Zarna 1a2ca5b811 Skip a number commits before starting to show the commit output
Change-Id: Id2666d897d29b6371f7a6cf241cfda02964b4971
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-01-02 08:40:02 -08:00
Tomasz Zarna 5d95cd9418 Add constant for default name for the Git repo configuration
Change-Id: I5a6ef686c444fb1e46c9f784bad01165471ef372
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-02 13:24:36 +01:00
Tomasz Zarna 617c5d91da Sort translation bundle keys in alphabetical order.
Change-Id: I83e26531ea924178ba43fa82b3c1fe02afd23eca
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-01-02 12:59:05 +01:00
Kevin Sawicki 92c6f2f97b Add comand support for git-submodule
Adds the following commands:
    - Add
    - Init
    - Status
    - Sync
    - Update

This also updates AddCommand so that file patterns added that
are submodules can be staged in the index.

Change-Id: Ie5112aa26430e5a2a3acd65a7b0e1d76067dc545
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2011-12-28 10:33:14 -06:00
Kevin Sawicki 3c7dceec1a Add commit id and parent count to exception message
Bug: 357312
Change-Id: I2f85cf88650594eca7df6aa0e26bea329674f08e
2011-12-27 13:37:42 -08:00
Shawn Pearce 80c5210409 Merge "Only print stack trace to Sytem.err when debug flag is set" 2011-12-27 16:24:36 -05:00
Tomasz Zarna 8f8e43b741 Fix typo in RebaseResult#mySatus
Change-Id: I88d34eec8307231f89343ead06858d1df4ac0886
2011-12-27 21:47:44 +01:00