Commit Graph

1973 Commits

Author SHA1 Message Date
Kevin Sawicki 4535a9e2a3 Throw invalid ref exception instead of invalid remote exception
ReflogCommand command was throwing an incorrect exception type
when an IOException was wrapped and rethrown from the underlying
ReflogReader.  The IOException cause is now provided to the thrown
exception as well.

Change-Id: I9f1842c2d414d3e9c658843f9b448bc18891748e
2011-12-08 11:36:05 -08:00
Kevin Sawicki 47d1616374 Use constant for logs directory
Change-Id: Ie139133bcbe1ca61c85e86b3484f858bc065821f
2011-12-08 11:36:05 -08:00
Shawn Pearce 4e92ae1656 Merge "Set expected old object id to all zeros when head id is null" 2011-12-08 13:09:02 -05:00
Shawn Pearce 580def2a23 Merge "Use System.arraycopy to copy parent object id array" 2011-12-08 13:07:21 -05:00
Shawn Pearce 4c24203e77 Merge "[findBugs] Implement Serializable interface in PlotLane" 2011-12-08 13:06:03 -05:00
Tomasz Zarna eb5df588d8 Add toString() to HunkHeader
Since FileHeader provides toString() method (via DiffEntry) we could add
a similar method to HunkHeader.

Change-Id: I7886e5b8f775fa8e8478ac5af37d90b6ef677d8b
2011-12-08 18:11:01 +01:00
Kevin Sawicki 60563b3478 [findBugs] Implement Serializable interface in PlotLane
This class is referenced by PlotCommit which is Serializable

Change-Id: If79b6a593dc53fbb7c4f0a69a9d0dca02a8cb63c
2011-12-08 08:41:10 -08:00
Dave Borowitz d6172dc0de Add a no-op UploadPackLogger and use it by default
This matches the behavior of the hooks in UploadPack.

Change-Id: I21277e52ee9452237d87084f06bb140dfa6bf608
2011-12-08 08:26:08 -08:00
Robin Rosenberg dfcb43eff1 Add methods for configuring platform emulation
Specifically we support setting system properties for Windows, generic
Unix and current test platform.

Change-Id: Ib02be417c4915350dfec64fda3face1138552871
2011-12-07 23:58:17 +01:00
Kevin Sawicki eb2cfd4552 Use System.arraycopy to copy parent object id array
Change-Id: Iee475584f0a65b8b77610cd277f15295b68dfe80
2011-12-07 10:21:41 -08:00
Kevin Sawicki 2539b1ee09 Set expected old object id to all zeros when head id is null
This will be the case on the initial commit to a repository
and the ref update should expect a non-existent ref

Change-Id: Iaa06e47e6e8cc4a0281c7683b367d4806dd980ea
2011-12-06 18:02:30 -08:00
Robin Rosenberg 9ffbe444f8 Force jgit.sh to use UTF-8 encoding on Mac
For some obscure reason the platform encodng in Java on Macs
is MacRoman. OS X used UTF-8 as the default encoding so set
the encoding property in jgit.sh.

Change-Id: I08182c2f8512f799178cee70bcc28d6ee2b9c2b0
2011-12-07 00:44:46 +01:00
Christian Halstrick 251bc02840 Fix history rendering not to occupy too many lanes
There was a bug in history rendering which caused jgit to use too
many lanes in case lanes get repositioned. Looking at commit
90c11cbaeb in JGit was one example. Vadim
Dmitriev found the problem and the solution.

Bug: 365460
Change-Id: I6024265b7a593dcfd4fc612d0baf6652a0092ff4
Also-by: Vadim Dmitriev <dmgloss@mail.ru>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-12-06 23:10:03 +01:00
Tomasz Zarna 2b3d48acc2 Stream left open in WorkingTreeIterator#filterClean
Change-Id: I17c2709f2613536c02c9ea2977d936b87029ac0d
2011-12-06 10:45:33 +01:00
Shawn O. Pearce cd958ba93c Merge changes I5381e110,I5534b560
* changes:
  Discard request HTTP bodies for status code <400
  Ensure all smart HTTP errors are sent to clients
2011-12-05 15:38:41 -05:00
Christian Halstrick 9e1b64bd3e Fix History rendering
There was the possibility that during history rendering we draw a lane
"trough" a passed commit. Vadim Dmitriev found that out in bug 335818. 
I added the needed check to that block of code where it was missing.

Bug: 335818
Change-Id: Ic944193b2aca55ff3eb0235d46afa60b7896aa0f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-12-04 18:16:08 +01:00
Robin Rosenberg ef32ab428f Merge "Always close the GZIPOutputStream to release Deflater" 2011-12-02 17:38:05 -05:00
Shawn Pearce 9fc04272e6 Merge "Fix History rendering" 2011-12-02 10:02:49 -05:00
Shawn Pearce e0f2be968b Merge "Add percent-encoding of reserved characters in URIish" 2011-12-02 10:01:22 -05:00
Robin Rosenberg 00514bde50 Add percent-encoding of reserved characters in URIish
We do this for the the names that have an explicit scheme and
do it both ways. The URIish is parsed before decoding. Only
a few special characters are encoded for the path part of the
URI, i.e. space, non-ASCII and control characters. The percent
encoding is assumed to be a stream encoding so we interpret it
as UTF-8.

Change-Id: I82d1910df9472e21d7212a2b984ff7d8fb2cbf0f
2011-12-02 15:50:09 +01:00
Christian Halstrick df8511eeea Fix History rendering
There was the possibility that during history rendering we draw a lane
"trough" a passed commit. Vadim Dmitriev found that out in bug 335818. 
I added the needed check to that block of code where it was missing.

Bug: 335818
Change-Id: Ic944193b2aca55ff3eb0235d46afa60b7896aa0f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-12-02 14:27:51 +01:00
Tomasz Zarna 7017c697fa Allow to list tags with org.eclipse.jgit.pgm.Tag
Change-Id: I79c284a720935814aef9767156106833f983bb8b
2011-12-02 14:25:48 +01:00
Shawn O. Pearce db00632db7 Discard request HTTP bodies for status code <400
The HTTP RFCs require a server to fully consume the request body before
it can return a non-error status code, which is any code below 400.

JGit returns most Git level errors inside of an HTTP 200 OK response,
and sometimes this happens before the entire request was consumed from
the servlet container. In such cases the body must be skipped or read
until EOF is reached, ensuring the HTTP keep-alive semantics will work
for the next request on the same TCP connection.

HTTP status codes >= 400 may be returned without consuming the body,
and a servlet container must set "Connection: close" in the response
headers when this happens, since the state of the request body is not
well defined with an early abort.

With the introduction of sendError() in GitSmartHttpTools there are
only a handful of locations that need to worry about the request body
being consumed, so sprinkle the call in as necessary.

Change-Id: I5381e110585f780c01a764df8e27c80aacf5146e
2011-12-01 16:01:13 -08:00
Shawn O. Pearce ac6cda955c Ensure all smart HTTP errors are sent to clients
Error messages are typically short, below the 32 KiB in-memory buffer
size of the SmartOutputStream. When an error is queued up for sending
to a client and an exception is thrown up into the servlet handler we
discarded the message and sent nothing to the client, as the messages
were stuck inside of the SmartOutputStream buffer.

Hoist the creation of the output stream above the invocation of try
block of the service, and use close() in the few catch blocks that
assume there are buffered messages ready for transmission. This will
ensure errors from unpacking a stream in ReceivePack are sent off to
a client correctly, as previously these were causing no status report
to arrive at the client side as the data was stuck in the buffer.

Change-Id: I5534b560697731121f48979ae077aa7c95b8e39c
2011-12-01 16:01:11 -08:00
Shawn O. Pearce 0d61707f12 Always close the GZIPOutputStream to release Deflater
The stream must be closed to ensure the native resources associated
with its internal Deflater instance are cleaned up early, instead of
waiting for GC to identify the dead object and finialize it.

Change-Id: Ic31b5df563f19404ed4682556999f4332aa61562
2011-11-30 17:45:41 -08:00
Shawn O. Pearce cea935ab1b Fix HTTP unit tests
I modified the way errors are returned, and this particular test is
now getting a different access denied response. The new text happens
to be what I intended to have here, so update the test.

Change-Id: I53f8410ca0a52755d80473cd5cbcdb4d8502febf
2011-11-30 17:40:10 -08:00
Christian Halstrick 2238fc9358 Merge "RepositoryState: add method canAmend" 2011-11-30 04:55:58 -05:00
Shawn Pearce e9f20c982a Merge "Always checkout master when it matches the advertised HEAD" 2011-11-28 21:59:52 -05:00
Shawn Pearce 47ef4db6bb Merge "Update maven plugin versions" 2011-11-28 21:51:31 -05:00
Shawn Pearce 5e5640ff62 Merge "Implement Serializable interface in ReflogEntry" 2011-11-28 21:50:40 -05:00
Kevin Sawicki b4ff1e1e03 Remove calls to printStackTrace in catch blocks
Change-Id: I7a4179f10a4841e80b6546e1e7662cab71eac5e9
2011-11-28 18:07:52 -08:00
Matthias Sohn 8375d17c00 Update maven plugin versions
Change-Id: I7400e08a1059f57c85a53aebe2719f81c00f58e8
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-29 01:16:47 +01:00
Kevin Sawicki 7ed1ef953c Implement Serializable interface in ReflogEntry
Change-Id: Idf798dd3981bef3dc9e17c13c12809f89089e96f
2011-11-28 16:14:21 -08:00
Kevin Sawicki 899114f63c Always checkout master when it matches the advertised HEAD
This parallels the CGit behavior of always using refs/heads/master
when it matches the remote advertised HEAD commit.

Change-Id: I5a5cd1516b58d116e334056aba1ef7990697ec30
2011-11-28 11:00:15 -08:00
Jens Baumgart 99ec987e68 RepositoryState: add method canAmend
The method canAmend was added to RepositoryState. It returns true if
amending the HEAD commit is allowed in the current repository state.

Change-Id: Idd0c4eea83a23c41340789b7b877959b457d951e
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
2011-11-28 10:46:16 +01:00
Shawn Pearce d497c2ac2d Merge "Reset SSH connection and credentials on "Auth fail"" 2011-11-26 19:24:09 -05:00
Matthias Sohn 430395a669 Reset SSH connection and credentials on "Auth fail"
When SSH user/password authentication failed this may have been caused
by changed credentials on the server side. When the SSH credentials of a
user change the SSH connection needs to be re-established and
credentials which may have been stored by the credentials provider
need to be reset in order to enable prompting for the new credentials.

Bug: 356233
Change-Id: I7d64c5f39b68a9687c858bb68a961616eabbc751
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-27 01:16:49 +01:00
Kevin Sawicki 241e03be9d Don't iterate over advertised refs when HEAD is null
Moves the check from inside the loop to outside the loop
and returns immediately if the HEAD advertisded ref is null

Change-Id: I539da6cafb4f73610b8e00259e32bd4d57f4f4cc
2011-11-26 14:47:21 -08:00
Matthias Sohn b4495d1005 Merge "tools/release: Handle v1.0.0.201106090707-r-NN-gdeadbeef" 2011-11-24 08:34:50 -05:00
Shawn Pearce 3d76a805ee Merge "Adapt merge message to C Git for remote-tracking branch" 2011-11-23 18:09:06 -05:00
Shawn O. Pearce 6ec174bfba Merge changes I828ac2de,I80e5b7cf
* changes:
  Add utilities for smart HTTP error handling
  Strip leading slashes in RepositoryFilter
2011-11-23 18:08:28 -05:00
Robin Stocker 8456cb3f2b Adapt merge message to C Git for remote-tracking branch
Commit 13931236b9ee2895a98ffdbdacbd0f895956d8a8 in C Git (2011-11-02)
changed the message format:

-Merge remote branch 'origin/foo'
+Merge remote-tracking branch 'origin/foo'

This change does the same in EGit to be consistent.

Change-Id: I7d9c5afa95771dbfe6079b5f89a10b248fee0172
Signed-off-by: Robin Stocker <robin@nibor.org>
2011-11-23 17:03:21 +01:00
Kevin Sawicki c3fe50bb18 Guard against null branch in PullCommand
Throw a NoHeadException when Repository.getFullBranch
returns null

Bug: 351543
Change-Id: I666cd5b67781508a293ae553c6fe5c080c8f4d99
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-22 16:29:28 -08:00
Kevin Sawicki 900bdbac5b Support adding all refs to LogCommand
Bug: 353310
Change-Id: Ifa2e7ed58c7f2bdfe3aafbd500b5a38c1f94c2ec
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-22 16:14:30 -08:00
Shawn O. Pearce 867087bb11 Add utilities for smart HTTP error handling
The GitSmartHttpTools class started as utility functions to help report
useful error messages to users of the android.googlesource.com service.

Now that the GitServlet and GitFilter classes support filters before a
git-upload-pack or git-receive-pack request, server implementors may
these routines helpful to report custom messages to clients.  Using the
sendError() method to return an HTTP 200 OK with error text embedded in
the payload prevents native Git clients from retrying the action with a
dumb Git or WebDAV HTTP request.

Refactor some of the existing code to use these new error functions and
protocol constants.  The new sendError() function is very close to being
identical to the old error handling code in RepositoryFilter, however we
now use the POST Content-Type rather than the Accept HTTP header to check
if the client will accept the error data in the response body rather than
using the HTTP status code.  This is a more reliable way of checking for
native Git clients, as the Accept header was not always populated with the
correct string in older versions of Git smart HTTP.

Change-Id: I828ac2deb085af12b6689c10f86662ddd39bd1a2
2011-11-22 15:51:14 -08:00
Shawn O. Pearce 9d311b3333 Strip leading slashes in RepositoryFilter
If removing the leading slash results in an empty string, return
with an HTTP 404 error before trying to use the RepositoryResolver.
Moving this into a loop ahead of the length check ensures there is
no empty string passed into the resolver.

Change-Id: I80e5b7cf25ae9f2164b5c396a29773e5c7d7286e
2011-11-22 15:19:02 -08:00
Shawn Pearce d8497abe78 Merge "Provide merge result when revert command fails" 2011-11-22 14:26:08 -05:00
Sasa Zivkov 1fbe688f51 maxObjectSizeLimit for receive-pack.
ReceivePack (and PackParser) can be configured with the
maxObjectSizeLimit in order to prevent users from pushing too large
objects to Git. The limit check is applied to all object types
although it is most likely that a BLOB will exceed the limit.  In all
cases the size of the object header is excluded from the object size
which is checked against the limit as this is the size of which a BLOB
object would take in the working tree when checked out as a file.
When an object exceeds the maxObjectSizeLimit the receive-pack will
abort immediately.

Delta objects (both offset and ref delta) are also checked against the
limit. However, for delta objects we will first check the size of the
inflated delta block against the maxObjectSizeLimit and abort
immediately if it exceeds the limit. In this case we even do not know
the exact size of the resolved delta object but we assume it will be
larger than the given maxObjectSizeLimit as delta is generally only
chosen if the delta can copy more data from the base object than the
delta needs to insert or needs to represent the copy ranges. Aborting
early, in this case, avoids unnecessary inflating of the (huge) delta
block.

Unfortunately, it is too expensive (especially for a large delta) to
compute SHA-1 of an object that causes the receive-pack to abort.
This would decrease the value of this feature whose main purpose is to
protect server resources from users pushing huge objects.  Therefore
we don't report the SHA-1 in the error message.

Change-Id: I177ef24553faacda444ed5895e40ac8925ca0d1e
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-11-22 17:43:00 +01:00
Kevin Sawicki 2d63c481f7 Provide merge result when revert command fails
This allows callers to determine why the revert
did not complete successfully

Change-Id: Ie44bb8523cac388b63748bc69ebdd3c3a3665d06
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-11-21 17:14:11 -08:00
Shawn Pearce 3ee3811afb Merge "Add missing '' characters around quoted variables" 2011-11-18 19:11:47 -05:00