Commit Graph

1736 Commits

Author SHA1 Message Date
Shawn O. Pearce 86e4859576 Merge "Work around smart HTTP bugs in C Git" 2012-07-11 14:07:30 -04:00
Robin Stocker a216624ef7 Create parent dir if necessary on checkout
An example where this is necessary is when a whole directory was deleted
and checkout is used to restore a file which was in that directory.

Bug: 372133
Change-Id: I1d45e0a5d2525fe1fdfbf08c9c5c166dd909e9fd
Signed-off-by: Robin Stocker <robin@nibor.org>
2012-07-08 15:15:38 +02:00
Matthias Sohn c0b4b79296 Merge branch 'stable-2.0'
* stable-2.0:
  Improve performance of persisting an index by magnitudes

Change-Id: I880f4d0be81c263b598ee24e8373c6f8cb781c51
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-07-02 22:19:15 +02:00
Christian Halstrick c9e507c0b9 Improve performance of persisting an index by magnitudes
When updating smudged entries use a pathfilter to iterate only over
working tree files which have an associated smudged index entry.

Commit dac66672df introduced that we
check and update smudged entries while persisting a dircache. Before
that commit adding a file to git caused  file i/o for the index file,
the object database (to store new content) and all files we wanted to
add (to read new content). After that commit we have additionally file
i/o for every file in the working tree (even ignored files).
Especially on windows iterating over the working tree can be very
time consuming. This decreased the performance of persisting a dircache
dramatically (I measured factors 4 to 10 while adding a file to linux
kernel repo). One could easily see this effect when dragging&dropping
modified files in a linux kernel repo in the egit staging view.

Change-Id: I568dec77635013cf6bb46f652d3f2b89de041c82
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-06-28 11:06:29 -07:00
Shawn O. Pearce 1c6c73c5a9 Work around smart HTTP bugs in C Git
I have unfortunately introduced a few bugs in the native Git client
over the years. 1.7.5 is unable to send chunked requests correctly,
resulting in corrupt data at the server. Ban this client whenever
it uses chunked encoding with an error message.

Prior to some more recent versions, git push over HTTP failed to
report status information and error messages due to a race within
the client and its helper process. Check for these bad versions and
send errors as messages before the status report, enabling users
to see the failures on their terminal.

Change-Id: Ic62d6591cbd851d21dbb3e9b023d655eaecb0624
2012-06-27 14:11:42 -07:00
Dave Borowitz dc23a7cc42 Make InMemoryRepository pack names globally unique
It was easy to create multiple packs with exactly the same name and
same DfsRepositoryDescription in a test, which can poison the
DfsBlockCache. The javadoc for DfsObjDatabase.newPack() explicitly
says pack names should be unique within an entire DFS, so do this by
making the packId AtomicInteger static.

Arguably, test writers shouldn't be doing things like putting
'new DfsRepositoryDescription("test")' in a setUp() method, but that's
a natural thing to do, and we don't document this restriction
anywhere.

Change-Id: I9477413ab3950d83b7d17e173fbc0a3e064896e3
2012-06-27 13:55:25 -07:00
Shawn Pearce 2d1124b89b Merge "Disable PackParser EOF check if more data expected" 2012-06-27 10:26:40 -04:00
Ian Wetherbee 94f67a9cdc Disable PackParser EOF check if more data expected
The PackParser EOF check is incompatible with the expect data after
pack footer flag, so turn off the EOF check if the expecting data
flag is true.

Change-Id: I697ebd9e1d1eed765d00aecaef955cf978cfd0b9
2012-06-26 16:42:09 -07:00
Dave Borowitz 2444aa231a Use the working tree's .gitmodules in SubmoduleWalk.forIndex()
This was broken in fe1f1b8f8a, which
preferred the index over the working tree when both were present.

Change-Id: I97dcf9a088adcbd0187fa7eec9ef34445ce3a981
Signed-off-by: Kevin Sawicki <kevin@github.com>
2012-06-25 10:46:36 -07:00
Christian Halstrick 1bf5b9c7a8 Merge changes I6b2ce96b,I499f518f
* changes:
  Fix order of deletion for files/dirs in ResolveMerger
  Don't return success on failing paths in ResolveMerger
2012-06-25 03:08:03 -04:00
Matthias Sohn 3d98c3f0f3 Add toString() to simplify debugging rebase steps
Change-Id: Id1508c5f007a6a6680928992a1c7524c266a9ce4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-24 01:00:31 +02:00
Robin Stocker 14ff22fd74 Ignore empty lines when parsing git-rebase-todo
When starting a rebase with C Git, there may be empty lines in the
git-rebase-todo file. Before this change, JGit would fail to parse the
file with e.g. the following exception:

  JGitInternalException: Unknown or unsupported command "
  #", only "pick" is allowed.

This happened when there was an empty line just before the comments,
because the nextSpace would be the one from the comment. Now the empty
lines are ignored by checking for nextSpace < ptr outside of the loop.

Change-Id: I94ad299f367c846e7729c74f49c6b8f93f75ae81
Signed-off-by: Robin Stocker <robin@nibor.org>
2012-06-23 16:38:54 +02:00
Robin Stocker e623db0f87 Fix order of deletion for files/dirs in ResolveMerger
Before, the paths to delete were stored in a HashMap, which doesn't have
a particular order. So when e.g. both the file "a/b" and the directory
"a" were to be deleted, it would sometimes try to delete "a" first. This
resulted in a failed path because File#delete() fails when a directory
isn't empty.

With this change, an ArrayList is used for storing the paths to delete.
The list contains the paths in a top-down order, as defined by the order
of processEntry. When the files are deleted, the list is iterated in
reverse, ensuring that all files of a directory are deleted before the
directory itself.

Bug: 354099
Change-Id: I6b2ce96b3932ca84ecdfbeab457ce823c95433fb
Signed-off-by: Robin Stocker <robin@nibor.org>
2012-06-23 16:32:34 +02:00
Robin Stocker 028434e4f5 Don't return success on failing paths in ResolveMerger
ResolveMerger#mergeImpl() was only returning false (= failed) when there
were unmerged paths. In the case when there were only failing paths, it
returned true.

Because MergeCommand looks at the return value for determining if the
merge failed, it would fall into the successful case there, where it
should instead return a MergeResult with MergeStatus.FAILED.

This change adds a test case for this and makes the ResolveMerger return
false when there are failing paths.

This was discovered while working on fixing bug 354099 and is needed for
its test case.

Bug: 354099
Change-Id: I499f518f6289ef93e017db924b2aa857f2154707
Signed-off-by: Robin Stocker <robin@nibor.org>
2012-06-23 16:32:34 +02:00
Robin Rosenberg b0349227e4 Make clear method on StoredConfig public
EGit needs this to be able to revert unsaved changes.

Change-Id: I50cc8056aaff47fef6080970866962e3eb634e29
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-21 01:07:36 +02:00
Shawn Pearce ec18666e27 Merge "Refactor TransportHttp for long-polling" 2012-06-16 15:31:26 -04:00
Shawn Pearce 8712926958 Merge "ReceivePack supports InputStream data after pack" 2012-06-16 15:28:19 -04:00
Christian Halstrick 80113c7bb6 Fix resource leaks due to unclosed repositories
Whenever a call to JGit returns a Repository the caller should make sure
to call close() on it if he doesn't need it anymore. Since instances of
Repository contain e.g. open FileOutputStreams (for pack files)
forgetting to close the repository can lead to resource leaks.

This was the reason why dozens of the JUnit tests failed on Windows
with "Can't delete file ...." errors. 

In LocalDiskRepositoryTestCase.tearDown() we tried to delete the
repositories we used during tests which failed because we had open
FileOutputStreams.

Not only the obvious cases during Clone or Init operations returned
Repositories, but also the new SubModule API created repository
instances. In some places we even forgot to close submodule repositories
in our internal coding.

To see the effects of this fix run the JGit JUnit tests under Windows.
On other platforms it's harder to see because either the leaking
resources don't lead to failing JUnit tests (on Unix you can delete
files with open FileOutputStreams) or the java gc runs differently and
cleans up the resources earlier.

Change-Id: I6d4f637b0d4af20ff4d501db091548696373a58a
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-16 00:19:51 +02:00
Ian Wetherbee b1e4d6bca2 ReceivePack supports InputStream data after pack
When receiving a pack, data buffered after the pack can restored
to the InputStream if the stream supports mark and reset.

Change-Id: If04915c32c91be28db8df7e8491ed3e9fe0e1608
2012-06-15 15:16:36 -07:00
Ian Wetherbee 2adc572628 Refactor TransportHttp for long-polling
Split Service into MultiRequestService (fetch, push) and
LongPollService (upcoming publish-subscribe).

Change-Id: Ice373d3dee63c395490d2707473ccf20a022e5cf
2012-06-15 12:20:54 -07:00
Dave Borowitz fe1f1b8f8a Read .gitmodules config from the tree in SubmoduleWalk
It is not always appropriate to use the .gitmodules file from the
working tree, for example if reading the modules at a specific commit.
And sometimes it is impossible, as in a bare repository.

When using the static factory methods, automatically set up the
appropriate root tree so lazy loading of the config file reads from
the appropriate place. Leave the current behavior of looking in the
working tree as a fallback for the case where walking the index.

Change-Id: I71b7ed3ba16c80b0adb8c5fd85b5c37fd4aef8eb
2012-06-15 11:43:22 -07:00
Dave Borowitz 458f64c6ea Add a release() method to SubmoduleWalk
We need a way to release the underlying TreeWalk. Also, use this
method to release walks from the static factory methods on error or
when submodules are not found.

Change-Id: I6bedc2db78bcd577aef2cfe6715bb981a26dcfd7
2012-06-15 11:43:22 -07:00
Tomasz Zarna 2656ac1b5a Add "--squash" option to MergeCommand
CQ: 6570
Bug: 351806
Change-Id: I5e47810376419264ecf4247b5a333af5c8945080
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-15 08:59:41 +02:00
Tomasz Zarna c4087af65d Remove unused import of ObjectInserter in ResolveMerger
Change-Id: I415894418f6fbe922c61294b21e15eee64e8a806
2012-06-15 08:35:46 +02:00
Shawn Pearce 9af5f1888e Merge "Add Transport URI constructor without a repository" 2012-06-15 01:53:45 -04:00
Shawn Pearce c25ea295e0 Merge "Fix UnionInputStream.read to be more Java-like" 2012-06-15 01:27:43 -04:00
Ian Wetherbee 590e8f44e6 Fix UnionInputStream.read to be more Java-like
Relax the read() method to not block until exactly "len" bytes have
been read. Instead, return when one or more bytes have been read, up
to "len", so UnionInputStream more closely resembles InputStream's
read() method.

Change-Id: I3f632be8eb85a4a0baf27c9f067c8d817162de2b
2012-06-14 22:23:48 -07:00
Shawn O. Pearce b3dbf1981b Use only a single ObjectInserter in ResolveMerger
The base class supplies an ObjectInserter to its implementations
by way of the getObjectInserter method. Tracking a second inserter
instance doesn't match with the expected behavior.

Change-Id: I78996bd06ef9028c8aa2e4e192ff647c43da847d
2012-06-14 18:43:52 -07:00
Shawn O. Pearce 90f984c71f Define ObjectInserter.Filter to wrap another ObjectInserter
Filter supports wrapping another ObjectInserter. By default all
methods are delegated to the wrapped inserter. Implementors may
override methods selectively for altered behavior.

The instance that is wrapped may be determined dynamically by code,
supporting lazy allocation of the delegate, or other patterns like
object pooling.

Change-Id: I7b2613d09e73f94e675bad33afbb693f6a7f3df6
2012-06-14 12:49:57 -07:00
Shawn O. Pearce d0e4943df1 Allow applications to pass ObjectInserter to Merger
Gerrit Code Review needs to control which inserter is used by a
Merger. Allow the application to set the inserter before calling
merge, giving callers more direct control over how objects will
be created.

Change-Id: I3c527a493db4659e95289ff3077cffb9e32336cf
2012-06-14 12:42:39 -07:00
Ian Wetherbee 242716092f Add Transport URI constructor without a repository
Let a Transport instance be opened with only a URI, for use in the
upcoming publish-subscribe feature.

Change-Id: I391c60c10d034b5c1c0ef19b1f24a9ba76b17bb5
2012-06-14 11:52:10 -07:00
Matthias Sohn 9000351909 Prepare 2.1.0 builds
Change-Id: I4aad3efdd435d8d5eb53c84a8d38132acce97c25
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-14 00:45:13 +02:00
Matthias Sohn 221554e35f Merge branch 'stable-2.0'
* stable-2.0:
  Prepare post v2.0.0.201206130900-r builds
  JGit v2.0.0.201206130900-r
  Add org.eclipse.jgit.pgm.feature to enable consumption via p2
  Do not set core.autocrlf when creating repo

Change-Id: Ifdd71a6bc14d9c79f4433ebc3b53bf0042a4d4c8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-14 00:20:48 +02:00
Matthias Sohn 2f27d5ae12 Prepare post v2.0.0.201206130900-r builds
Change-Id: I51b1bbed35288c5285b3d6860efba97d58de5a1c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-14 00:19:30 +02:00
Tomasz Zarna 55f42a8c1d Fix GitDateFormatter javadoc.
Change-Id: I627bdc387754a626ed8b1839494c05dfd5950d11
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-14 00:06:30 +02:00
Matthias Sohn aacd4f721b JGit v2.0.0.201206130900-r
Change-Id: I685e09b3e37d68614df1b5cc5f687a65cd6eb82d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-13 15:03:59 +02:00
Robin Rosenberg 2853c61f12 Do not set core.autocrlf when creating repo
core.autorlf defaults to false, but can be set in the user or 
"system" config files. Note that EGit/JGit may not know
where the "system" config file is located.

Also fix pgm's ConfigTest which depends on default repository
configuration.

Bug: 382067
Change-Id: I2c698a76e30d968e7f351b4f5a2195f0b124f62f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-12 13:56:42 +02:00
Shawn O. Pearce 65f6e06b8d Merge branch 'stable-2.0'
By Robin Rosenberg (6) and others
via Gerrit Code Review @ Eclipse.org (2) and Matthias Sohn (1)
* stable-2.0:
  Prepare next 2.0.0-SNAPSHOT builds
  JGit v2.0.0.201206060730-rc3
  Remove Jetty p2 repository from Maven build
  Get rid of warnings about empty statments
  Removed unused parameters from private methods
  cleanup: Remove unused declarations
  Make FS OS X detection work for OpenJDK
  Use working tree iterator to compare file modes
  Further cleanup of exceptions in Git API
  Update build to use Tycho 0.15.0
  Throw formal CheckoutConflictException on hard reset
  Configure maven-source-plugin execution in parent POM
  Support gitdir: refs in BaseRepositoryBuilder.findGitDir
  Relax RevisionSyntaxException to an IllegalArgumentException

Change-Id: I05727693e0c9e762d4fc220ceadcd5a5bfb11d0d
2012-06-07 11:38:23 -07:00
Matthias Sohn f2d9a5ed31 Prepare next 2.0.0-SNAPSHOT builds
Change-Id: I0d55b390502b3da139ab0d15a6cf3d05774d8ad9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-06 13:57:32 +02:00
Matthias Sohn 1cb135ebfb JGit v2.0.0.201206060730-rc3
Change-Id: I12f8800b74228e71c77f0fb82c250c154d06369f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-06 13:27:54 +02:00
Markus Duft 8672c43ae3 Make DirCacheCheckout update timestamps in the index.
This updates the timestamp of files that are not touched during
checkout. Otherwise the timestamp will always be zero, causing the
IndexDiffFilter to always calculate the checksum of file contents.

Change-Id: I18047f5725f22811bb4194ca1d3a3cac56074183
2012-06-06 13:14:14 +02:00
Christian Halstrick 87c5588853 Merge "Use working tree iterator to compare file modes" into stable-2.0 2012-06-06 06:43:20 -04:00
Robin Rosenberg e251355897 Get rid of warnings about empty statments
In HtttpAuthMethod there were comments, but not in a style
that Eclipse recognizes.

Change-Id: I64f55b27143f8badcefbb419d3951f2a26b87d5f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-06 09:44:39 +02:00
Robin Rosenberg 4e5944fbf8 Removed unused parameters from private methods
Change-Id: I60bc03b9550ccd2350918e6328276ec9839748d5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-06 09:44:18 +02:00
Robin Rosenberg 4321f9353f cleanup: Remove unused declarations
Change-Id: I3b54cb9f73cb433c71a441a11ddc74cfecdaa1dc
2012-06-06 01:43:44 +02:00
Shawn O. Pearce 73cdb08af6 Merge changes Iee9af8d5,I8e1674f0,If5a6fcc5,I3bb28e4d
* changes:
  Use BatchRefUpdate for tracking refs in FetchProcess
  Batch reference updates together for storage
  Expose ReceiveCommand.updateType to check for UPDATE_NONFASTFORWARD
  Reject non-fast-forwards earlier in BaseReceivePack
2012-06-05 19:31:57 -04:00
Robin Rosenberg 20c33e6b0c Make FS OS X detection work for OpenJDK
OpenJDK sets the os.name system.property to "Darwin", while Apple's
version says "Mac OS X".

Change-Id: If08f8e7b8ef94ec00023a3f78bbf502ebd9699fb
2012-06-06 01:14:19 +02:00
Kevin Sawicki 59a98b49d2 Use working tree iterator to compare file modes
Add isModeDifferent method to WorkingTreeIterator
that compares mode with consideration of the
core.filemode setting in the config.

Bug: 379004
Change-Id: I07335300d787a69c3d1608242238991d5b5214ac
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2012-06-05 08:23:04 -07:00
Robin Rosenberg b61d35e848 Further cleanup of exceptions in Git API
- Translate internal exceptions to corresponding API exception
- Do not catch GitAPI exceptions internally to an internal
exception. Just pass them to caller
- Mention thrown exceptions in javadoc

Change-Id: I9044cf86d2b0bcc8b63b7cc016e1bf0055a62053
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-05 16:55:39 +02:00
Kevin Sawicki 108e2bc6e4 Throw formal CheckoutConflictException on hard reset
This will allow calling classes to have access to the
conflicts that occurred during the attempted checkout.

Even though setFailOnConflict(false) is called on the
DirCacheCheckout a CheckoutConflictException can still
be thrown if cleanup fails.

Change-Id: Iea7ad3176a1b0e8606a643de8945e276718eb3ce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-05 15:49:55 +02:00
Kevin Sawicki 2a18bb304c Support gitdir: refs in BaseRepositoryBuilder.findGitDir
This allows findGitDir to be used for repositories containing
a .git file with a gitdir: ref to the repository's directory
such as submodule repositories that point to a folder under the
parent repository's .git/modules folder

Change-Id: I2f1ec7215a2208aa90511c065cadc7e816522f62
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-06-04 09:15:35 -07:00
Christian Halstrick 8a0169727f Merge "Relax RevisionSyntaxException to an IllegalArgumentException" into stable-2.0 2012-06-04 11:05:32 -04:00
Christian Halstrick 0f84b86e01 fix PackWriter excluded objects handling
PackWriter supports excluding objects from being written to the pack.
You may specify a PackIndex which lists all those objects which should
not go into the new pack. This feature was broken because not all
commits have been checked whether they should be excluded or not. For
other object types the exclude algorithm worked. This commit adds the
missing check.

Change-Id: Id0047098393641ccba784c58b8325175c22fcece
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-06-04 07:52:36 -07:00
Shawn Pearce bc7817c943 Merge "Only increment mod count if packed-refs file changes" into stable-2.0 2012-06-04 10:44:10 -04:00
Robin Rosenberg 0da46186e5 Relax RevisionSyntaxException to an IllegalArgumentException
Change-Id: Ide46eeb6cddcf3111f7c237ba8425a0854a90bfd
2012-06-04 16:32:16 +02:00
Stefan Lay f0df18ff4f Add lazy loading of body for tags to PlotWalk
This change is required by egit's lazy loading of the body in the
history view when the walk is started with setRetainBody(false).

Change-Id: I9291ba8c34c8744bc009b1bd302ed28bfa4e9476
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2012-06-04 01:20:38 +02:00
Robin Rosenberg 76514a3450 Remove obsolete GitlinksNotSupportedException
Change-Id: Idddd86818858b229e68b4a46597fc67547bcce17
2012-05-31 23:46:06 +02:00
Kevin Sawicki 058c74d8ad Update ORIG_HEAD when resetting
Write the old object id from the RefUpdate to the
ORIG_HEAD file after the update completes.

Add two new convenience methods to Repository to read
and write the ORIG_HEAD reference similar to the methods
for reading/writing CHERRY_PICK_HEAD and MERGE_HEAD.

Bug: 375525
Change-Id: I120b3b2cd3b1ddae88fce435285bae15cbf96f5e
2012-05-31 21:52:31 +02:00
Matthias Sohn 9bd9d9a698 Prepare next 2.0.0-SNAPSHOT builds
Change-Id: Iffc57d6b25dafb72272d1957116c19ab45ba2c54
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-31 01:39:57 +02:00
Matthias Sohn 4aa550f7cc JGit v2.0.0.201205301645-rc2
Change-Id: Ic4f84f1a11c93863c229c0089f2e4edc7c7a36b7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-30 23:08:15 +02:00
Robin Rosenberg 4e1454ded6 Git API does not declare GitAPIException call() and related cleanups
All commands should throw a GitAPIException so new exceptions can be
added without breaking the builds of old code, i.e. anyone that calls
a Git API should catch GitAPIException and not just the currently known
exceptions.

Now the only checked exceptions on Git API calls are GitException and
subclasses of it. New checked exceptions that are subclasses of
GitException may be added without breaking the API.

Javadoc for GitAPIException is declared on GitCommand and
inherited to subclasses. JGitInternalException is not explicitly
documented anymore.

Unfortunately this change itself breaks the API. The intention is
that it shall be possible to add new checked subclasses of
GitAPIException without breaking the API.

Bug: 366914
EGit-Change-Id: I50380f13fc82c22d0036f47c7859cc3a77e767c5
Change-Id: I50380f13fc82c22d0036f47c7859cc3a77e767c5
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-30 22:08:49 +02:00
Robin Rosenberg 629e7cd926 Merge "Retain file length and mod time when doing a mixed reset" into stable-2.0 2012-05-30 15:57:04 -04:00
Robin Rosenberg 875247e24b Merge "Update smudged entries when writing index" into stable-2.0 2012-05-30 15:56:30 -04:00
Matthias Sohn 59d2ef9470 Enable loading history until a given commit
This is needed to allow jumping to a selected commit when loading
history incrementally.

Change-Id: Id3b97d88d3b4b2d67561b11f8810cb88fe040823
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-30 10:26:21 +02:00
Kevin Sawicki 91f5ce3a15 Only increment mod count if packed-refs file changes
Previously if a packed-refs file was racily clean then there
was a 2.5 second window in which each call to getPackedRefs
would increment the mod count causing a RefsChangedEvent to be
fired since the FileSnapshot would report the file as modified.

If a RefsChangedListener called getRef/getRefs from the
onRefsChanged method then a StackOverflowError could occur
since the stack could be exhausted before the 2.5 second
window expired and the packed-refs file would no longer
report being modified.

Now a SHA-1 is computed of the packed-refs file and the
mod count is only incremented when the packed refs are
successfully set and the id of the new packed-refs file
does not match the id of the old packed-refs file.

Change-Id: I8cab6e5929479ed748812b8598c7628370e79697
2012-05-28 14:06:12 -07:00
Kevin Sawicki 531db82f38 Retain file length and mod time when doing a mixed reset
Previously the index was cleared and updated with a new tree.

Now the commit being reset to and the index are iterated over
in a tree walk and the current index mod time and file length
are copied over to the new dir cache entry being written if
the object ids are the same.

Change-Id: Iaf9e624efb0bf90f9e05fcb0587dde4dec50000c
2012-05-28 14:01:37 -07:00
Kevin Sawicki dac66672df Update smudged entries when writing index
Overload DirCache.lock to take a repository that is
used for updating smudged index entries with information
from the repository's working tree.

New unit tests are also added for updating smudged index
entries on reset, checkout, and commit.

Change-Id: I88689f26000e4e57e77931e5ace7c804d92af1b6
2012-05-28 14:01:14 -07:00
Dariusz Luksza 1bec1f2fae Ensure resetting on commit id
When reset command was called with tag name as parameter the resulting
HEAD was set to the tag's SHA-1 which is a bug. This patch ensures that
repository.resolve() call always returns commit id.

Change-Id: I219b898c620a75c497c8652dbf4735fd094c4d7c
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-23 16:18:33 +02:00
Shawn O. Pearce 3da13473f7 Use BatchRefUpdate for tracking refs in FetchProcess
If there are a lot of references to modify, using BatchRefUpdate can
save time if the underlying storage is able to combine these updates
together. This should speed up initial clone or fetch into an empty
repository, as some projects can have hundreds of release tags, or
hundreds of branch heads.

Change-Id: Iee9af8d5fa19080077d88357c18853540936e940
2012-05-22 20:39:59 -07:00
Shawn O. Pearce 17be66acdb Batch reference updates together for storage
clone, fetch and push can all update multiple references in a single
command invocation. Rather than performing sequential iteration
of each reference change inside of the application code, push this
down into the reference database where the implementation can take
advantage of the batch size and optimize itself.

For the local filesystem implementation the obvious optimization
is to write a packed-refs file when the repository is completely
empty. The initial clone, fetch or push into the destination may
have hundreds of new references. Writing all of these as loose
files is not efficient. This optimization is not implemented in
this commit and is left as an exercise for the reader to supply
in a future commit to JGit.

To make the API changes simple, define the BatchRefUpdate type and
implementation using the existing sequential behavior.

Change-Id: I8e1674f091e05e24e3ff56ccbc687a6d18a6a61e
2012-05-22 16:45:06 -07:00
Shawn O. Pearce d8d649a43e Expose ReceiveCommand.updateType to check for UPDATE_NONFASTFORWARD
When a command's type is UPDATE, JGit might not yet be sure if it
is a fast-forward or not. Expose a utility method to compute the
exact type by performing the merge base test, allowing the type
to be switched to UPDATE_NONFASTFORWARD if old ObjectId is not
contained in new ObjectId.

BaseReceivePack already does this test when validating the incoming
command list, so provide a package level backdoor to set the type
and avoid needing to redo the merge test later.

Change-Id: If5a6fcc50dc4d6f96e9bb0bb7bba15ebe8b86377
2012-05-22 16:28:34 -07:00
Shawn O. Pearce 04fa307a70 Reject non-fast-forwards earlier in BaseReceivePack
If BaseReceivePack has setAllowNonFastForwards(false) configured
(such as by receive.denynonfastforwards), automatically reject
any command that attempts a non-fast-forward update before it goes
further in processing.

This matches with other checks in validateCommands(), such as the
early failure of delete attempts when isAllowDeletes() is false.

Change-Id: I3bb28e4dd6d17cb31ede09eb84ceb67cdb17ea5d
2012-05-22 16:28:34 -07:00
Robin Rosenberg 1953ae6aee Smudge index entries on first write (too), as well when reading
That happens when the index and a new file is created within the same
second and becomes a problem if we then modify the newly created file
within the same second after adding it to the index. Without smudging
JGit will, on later reads, think the file is unchanged.

The accompanying test passed with the smuding on read.

Change-Id: I4dfecf5c93993ef690e7f0dddb3f3e6125daae15
2012-05-21 10:48:40 -07:00
Dariusz Luksza 28d48b87ad Don't swallow JSchException "Auth fail" exception
"Auth fail" exception was swallowed during retrying, this leads to
"Session down" exception during clone operation with invalid SSH keys.

Bug: 336795
Change-Id: Id8d9e83b10f4f2a01e0cf89819190bb23a04a2b9
Signed-off-by: Dariusz Luksza <dariusz@luksza.org>
2012-05-16 07:55:03 +02:00
Dave Borowitz 37307af6b4 Enable call chaining on LsRemoteCommand methods
Change-Id: I706332386415892d7a964b241442832ad79fa223
2012-05-14 11:52:48 -07:00
Dave Borowitz cc37cb777e Factor a base class out of ReceivePack
We are working on a publish/subscribe based git protocol, and we want to
reuse several parts of the ReceivePack-like code for reading commands
and processing a pack. In this new implementation, the connection
management will be very different, in particular, there may be multiple
packs received on a single open connection. So, hoist out as much as we
can from ReceivePack, mostly just leaving behind the single-connection
version in that class.

Change-Id: I5567aad6ae77951f73f59c1f91996d934ea88334
2012-05-14 11:41:25 -07:00
Tomasz Zarna ef98c3ec86 Cleanup MergeResult constructors
'mergeStrategy' should be 5th argument, after 'mergeStatus'. Pass
'description' if available.

Change-Id: I97cebfe5d7db6247fe899075d917b82955906f85
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-05-10 18:23:56 -07:00
Matthias Sohn c394d05a47 Add missing @since tags to mark API added in 2.0
Change-Id: I0a86ce0e393dfde9bb27f0b29e036e76c856396e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-05-10 18:17:24 -07:00
Kevin Sawicki d72a459f93 Remove throws IOException declaration on filterClean
This method only creates an EolCanonicalizingInputStream
which does not throw an IOException and so the throws
declaration on the method is unneeded.

Change-Id: Icae8b80006c5e3ffcf3b69790a1a45c505be0f05
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-10 00:33:03 +02:00
Kevin Sawicki a9133e55a4 Add Object type to Comparable implements declaration
This removes unchecked warnings when a List of
AnyObjectId objects or any of its subclasses are
passed to Collections.sort such as in PackWriter

Change-Id: I806732cee24349c75c0357a655df55b070f2f213
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-10 00:32:47 +02:00
Kevin Sawicki e3335cfa6b Remove 4 unboxed warnings
Use Integer.intValue to explicitly convert to an int

Change-Id: I1135ed01af4e274b26d6b07d1a50f48ef0a30d91
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-10 00:32:27 +02:00
Kevin Sawicki 6ebc477c0b Make output stream optional in DiffCommand
Use the NullOutputStream.INSTANCE value when the
configured output stream is null or the command is
configured to only show name and status.

Also only set the context and prefix options if
formatting is actually being performed.

Bug: 377157
Change-Id: I333cfcc82ee746f3c6a8e94c09dcc803ffbb4b3a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-05-10 00:19:04 +02:00
Kevin Sawicki c403d0b187 Compare modes before comparing ids in ResolveMerger
Comparing ids can be more expensive so do the cheap
mode check first and short circuit the id comparison
when modes are non-equal

Change-Id: I671eda51c74a411cc27de9d6077cc76e816ebe2b
2012-05-09 14:31:59 -07:00
Kevin Sawicki 17fb542e9e Remove 86 boxing warnings
Use Integer, Character, and Long valueOf methods when
passing parameters to MessageFormat and other places
that expect objects instead of primitives

Change-Id: I5942fbdbca6a378136c00d951ce61167f2366ca4
2012-05-08 21:42:53 -07:00
Kevin Sawicki e4effd25c5 Remove unnecessary boxing SuppressWarnings annotation
Change-Id: Id8a6d9f96860742f9094efdb4f31a952be7d3025
2012-05-08 20:42:19 -07:00
Kevin Sawicki 6f432673c1 Remove unneeded catch block and null checks
The catched exception was just rethrown and the
null check of the locked dir cache was unneeded if
the assignment was done outside the try block.

Change-Id: If2ee1f3eff3849f8da51eab825057fc56e166a94
2012-05-04 14:37:40 -07:00
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