Kevin Sawicki [Wed, 21 Mar 2012 17:50:16 +0000 (10:50 -0700)]
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>
Kevin Sawicki [Mon, 12 Mar 2012 17:00:52 +0000 (10:00 -0700)]
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>
Shawn O. Pearce [Thu, 15 Mar 2012 14:57:56 +0000 (07:57 -0700)]
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>
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.
Kevin Sawicki [Wed, 14 Mar 2012 00:01:42 +0000 (17:01 -0700)]
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>
Shawn O. Pearce [Tue, 13 Mar 2012 18:10:33 +0000 (11:10 -0700)]
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.
* 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
Markus Duft [Mon, 12 Mar 2012 13:54:56 +0000 (14:54 +0100)]
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.
Kevin Sawicki [Sat, 10 Mar 2012 18:26:10 +0000 (10:26 -0800)]
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.
Kevin Sawicki [Sat, 10 Mar 2012 18:02:58 +0000 (10:02 -0800)]
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.
Markus Duft [Fri, 9 Mar 2012 12:36:53 +0000 (13:36 +0100)]
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).
Shawn O. Pearce [Thu, 8 Mar 2012 03:51:12 +0000 (19:51 -0800)]
Use readString() to trim trailing LF from first line
The fetch-pack/upload-pack stream usually has an LF at the
end of the first "want" line. Trim this when checking to
see if side-band or side-band-64k was used.
Perform the same trim for send-pack/receive-pack, as it is
harmless in this context to ignore an LF just before doing
an error report.
* 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
Dave Borowitz [Wed, 7 Mar 2012 19:56:56 +0000 (11:56 -0800)]
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.
Tomasz Zarna [Tue, 6 Mar 2012 21:43:25 +0000 (22:43 +0100)]
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>
Shawn O. Pearce [Mon, 5 Mar 2012 23:42:18 +0000 (15:42 -0800)]
Ignore /target
Maven seems to be creating target/antrun/build-main.xml.
This isn't a tracked file. Elsewhere we blanket ignore
/target inside of each plugin/component directory so do
the same at the top level.
Change-Id: Id799ac6da65e6789e48e28efbdb455153b34ff2e Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Kevin Sawicki [Tue, 6 Mar 2012 01:22:22 +0000 (17:22 -0800)]
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.
Tomasz Zarna [Mon, 5 Mar 2012 11:59:10 +0000 (12:59 +0100)]
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.
Matthias Sohn [Fri, 2 Mar 2012 23:53:00 +0000 (00:53 +0100)]
Include eclipse.inf
Commit 9169e7f9ec281740b6d55586d91a82e4ea6d7399 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>
Kevin Sawicki [Fri, 2 Mar 2012 23:01:13 +0000 (15:01 -0800)]
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.
Matthias Sohn [Fri, 2 Mar 2012 08:09:39 +0000 (09:09 +0100)]
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>
Dave Borowitz [Wed, 8 Feb 2012 22:30:04 +0000 (14:30 -0800)]
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.
Dave Borowitz [Mon, 27 Feb 2012 19:54:19 +0000 (11:54 -0800)]
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.
Dave Borowitz [Wed, 15 Feb 2012 19:10:52 +0000 (11:10 -0800)]
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.
Dave Borowitz [Tue, 7 Feb 2012 23:16:40 +0000 (15:16 -0800)]
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.
Kevin Sawicki [Wed, 29 Feb 2012 23:07:37 +0000 (15:07 -0800)]
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.
Marc Strapetz [Tue, 21 Feb 2012 14:18:08 +0000 (15:18 +0100)]
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.
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>
Matthias Sohn [Mon, 13 Feb 2012 06:33:43 +0000 (07:33 +0100)]
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>
Kevin Sawicki [Wed, 8 Feb 2012 22:10:28 +0000 (23:10 +0100)]
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>
Tomasz Zarna [Fri, 20 Jan 2012 23:15:03 +0000 (00:15 +0100)]
Workaround incompatible refactoring in Jetty 7.6.0
In Jetty 7.6 package org.eclipse.jetty.http.security was renamed to
org.eclipse.jetty.util.security [1] breaking compatibility.
Compare docs for the package in 7.5.4 [2] and missing part in 7.6.0 [3].
To fix until we switch to Jetty 8, restrict the maximum version to 7.6.0
exclusive.