Commit Graph

1362 Commits

Author SHA1 Message Date
Christian Halstrick eac2dc18f1 Allow InitCommand to run on existing git repos
To be more consistent with what native git does we should allow
to run the InitCommand also on existing git repos.

Change-Id: I833637842631b37dce96ed9729b3a6ed24054056
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-03-29 15:10:33 +02:00
Christian Halstrick c8b698abb9 Merge "Do not categorize merge failures as 'abnormal'" 2011-03-29 04:23:56 -04:00
Philipp Thun 475672866a Fix possible NPE in DirCache.isModified()
The snapshot field of a DirCache object for a newly created repository
can be null. This fix prevents a NPE when isModified() is called in
such a situation.

Change-Id: I61a1b45db2d60fdcc0f87373ac6fd75ac4c4a202
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-28 17:54:24 +02:00
Philipp Thun 761b9285f0 Do not categorize merge failures as 'abnormal'
This change contains a simple renaming. Instead of using the
expression 'abnormal failure', we just treat this kind of situation
as 'failure'. This is specific enough as conflicts are already handled
separately.

Change-Id: I535acdc7d022543ed0f5ac6151b09a6985f4ef38
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-28 16:01:44 +02:00
Shawn Pearce 23967441fc Merge "Detaching HEAD when checking out the same commit." 2011-03-27 16:55:54 -04:00
Shawn Pearce 6e10c1da00 Merge "Fix: possible IndexOutOfBoundsException in ReflogReader" 2011-03-27 16:48:45 -04:00
Shawn Pearce fc5d521e4b Merge "Registering the Checkout command and fixed a typo." 2011-03-27 16:46:39 -04:00
Sasa Zivkov 3a86868c08 Detaching HEAD when checking out the same commit.
Detaching HEAD didn't work in some corner checkout cases.  If, for example,
HEAD is symbolic ref to refs/heads/master, refs/heads/master is ref to commit
c0ffee... then:

    checkout c0ffee...

would leave the HEAD unchanged.

The same symptom occurs when checking out a remote tracking branch or a tag
that references the same commit as refs/heads/master.

In the above case, the RefUpdate class didn't have enough information to decide
if the update needed to detach symbolic ref because it dealt only with new/old
objectIDs. Therefore, this fix introduced the RefUpdate.detachingSymbolicRef
flag.

Bug: 315166
Change-Id: I085c98b77ea8f9104a213978ea0d4ac6fd58f49b
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2011-03-25 15:02:49 +01:00
Matthias Sohn 5152ed8e2e Prevent NPE during fetch and push via SSH
Bug: 340928
Change-Id: I870b77eeffa70a57891d7253a06ad7d44d808ee4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-24 19:01:50 -07:00
Philipp Thun 0b5ad24915 Introduce FAILED result for RebaseCommand
In case an underlying cherry-pick fails due to uncommitted changes, a
RebaseCommand shall fail and roll-back changes.

Change-Id: Ic22eb047fb03ac2c8391f777036b7dbf22a1b061
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-24 12:24:23 +01:00
Sasa Zivkov 13fffa7513 Registering the Checkout command and fixed a typo.
The Checkout command line command was added to JGit but it wasn't
registered in the list of available commands.
Additionally, the 'force' option was named '---force' (triple '-').

Change-Id: I259773932fa9aec3bb29e215740e67c834566f6f
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2011-03-24 11:22:17 +01:00
Mathias Kinzler 55b7bd247e Merge "Introduce CherryPickResult" 2011-03-24 03:18:32 -04:00
Christian Halstrick c160293d71 Add status command to GIT api
Allow users of the GIT api to get to know the state of their
workingtree and index by adding a status command. The implementation
is mainly a wrapper around IndexDiff class. Better support for multiple
stages in the index (conflict situations) is still missing. An
appropriate change to IndexDiff and StatusCommand will come in a
subsequent commit.

Bug: 337296
Change-Id: Idb390375a68611853c1c903299ec678c89b081dc
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-03-23 11:08:21 -05:00
Roland Schulz ccd3d83719 Create RemoteSession interface
The RemoteSession interface operates like a simplified version of
java.lang.Runtime with a single exec method (and a disconnect
method). It returns a java.lang.Process, which should begin execution
immediately. Note that this greatly simplifies the interface for
running commands. There is no longer a connect method, and most
implementations will contain the bulk of their code inside
Process.exec, or a constructor called by Process.exec. (See the
revised implementations of JschSession and ExtSession.)
Implementations can now configure their connections properly without
either ignoring the proper use of the interface or trying to adhere
to an overly strict interface with odd rules about what methods are
called first.  For example, Jsch needs to create the output stream
before executing, which it now does in the process constructor. These
changes should make it much easier to add alternate session
implementations in the future.

Also-by: John D Eblen <jdeblen@comcast.net>
Bug: 336749
CQ: 5004
Change-Id: Iece43632086afadf175af6638255041ccaf2bfbb
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-03-23 10:48:08 -05:00
Philipp Thun a21e508a31 Introduce CherryPickResult
In order to distinguish cherry-pick failures caused by conflicts vs.
'abnormal failures' (e.g. due to unstaged changes or a dirty
worktree), a CherryPickResult class is introduced and returned by
CherryPickCommand.call() instead of a RevCommit. This new class is
similar to MergeResult and RebaseResult. The CherryPickResult contains
all necessary information, e.g. paths causing the cherry-pick (a merge
called within, respectively) to fail. This allows callers to better
react on failures.

Change-Id: I5db57b9259e82ed118e4bf4ec94463efe68b8c1f
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-03-23 10:24:14 +01:00
Robin Stocker 770c733687 PullCommand: Use short ref name in merge message
Add a test case for PullCommand for the successful merge case and test
that the short ref name is used.

Change-Id: I16cbbc88595f73e5512f984e67f93f87ee0fe242
Signed-off-by: Robin Stocker <robin@nibor.org>
2011-03-22 19:46:18 +01:00
Marc Strapetz a327770433 Fix: possible IndexOutOfBoundsException in ReflogReader
java.lang.IndexOutOfBoundsException
at java.nio.ByteBuffer.wrap(ByteBuffer.java:352)
at org.eclipse.jgit.util.RawParseUtils.decodeNoFallback(RawParseUtils.java:913)
at org.eclipse.jgit.util.RawParseUtils.decode(RawParseUtils.java:880)
at org.eclipse.jgit.util.RawParseUtils.decode(RawParseUtils.java:839)
at org.eclipse.jgit.storage.file.ReflogReader$Entry.<init>(ReflogReader.java:102)
at org.eclipse.jgit.storage.file.ReflogReader.getReverseEntries(ReflogReader.java:183)
at org.eclipse.jgit.storage.file.ReflogReader.getReverseEntries(ReflogReader.java:162)

Change-Id: I22a18bc7193962e5018c40a75337f9976b585c40
2011-03-22 17:33:45 +01:00
Philipp Thun dcf7bd9a8f Improve MergeResult
Add paths causing abnormal merge failures (e.g. due to unstaged
changes) to the MergeResult returned by MergeCommand. This helps
callers to better handle (e.g. present) merge results.

Change-Id: Idb8cf04c5cecfb6a12cb880e16febfc3b9358564
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-21 12:33:58 +01:00
Philipp Thun dcefc660f1 Refactor test cases
This change moves commonly used methods into the RepositoryTestCase
base class.

Change-Id: I56a46c31ee1661c7ce22eb755ab23da8bc9f5da2
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-21 09:40:14 +01:00
Chris Aniszczyk a62abbe180 Merge "PackWriter: Collect stats by object type" 2011-03-19 12:33:19 -04:00
Chris Aniszczyk 9cde331c2b Merge "BlockList: Micro-optimize appending from another BlockList" 2011-03-19 12:32:19 -04:00
Chris Aniszczyk 817d1a334b Merge "PackFile: Cache the packName string" 2011-03-18 17:28:05 -04:00
Shawn O. Pearce bb1956e647 PackWriter: Collect stats by object type
Frequently enough I'm wondering how much of a pack is commits vs.
trees, and the total line doesn't really tell us this because its
a gross total from the pack. Computing the counts per object type
is simple during packing, as PackWriter already has everything in
memory broken up by object type.  Its virtually free to get these
values and track them.

Change-Id: Id5e6b1902ea909c72f103a0fbca5d8bc316f9ab3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-18 11:31:12 -07:00
Shawn O. Pearce 62fe7c7313 BlockList: Micro-optimize appending from another BlockList
Simple variant of addAll() that knows how to copy large segments
quickly using System.arraycopy() rather than looping through with
an Iterator object.

Change-Id: Icb50a8f87fe9180ea28b6920f473bb9e70c300f1
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-18 09:11:56 -07:00
Shawn O. Pearce 48fb404a3f PackFile: Cache the packName string
Instead of computing this on every request, compute it once and
hold onto the result. This improves performance for LocalCachedPack
which does a lot of tests against the pack name string.

Change-Id: I3803745e3a5dda7b5f0faf39aae9423e2c777e7f
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-18 09:11:47 -07:00
Philipp Thun bf05108d0b Abort merge when file to be checked out is dirty
In case a file needs to be checked out (from THEIRS) during a merge
operation, it has to be checked if the worktree version of this file
is dirty. If this is true, merge shall fail.

Change-Id: I17c24845584700aad953c3d4f2bea77a0d665ec4
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-18 17:04:50 +01:00
Christian Halstrick 28ffed2307 Merge "Refactor ResolveMerger" 2011-03-18 11:34:15 -04:00
Philipp Thun fdb0a34abf Refactor ResolveMerger
1. Perform an explicit check for untracked files.
2. Extract 'dirty checks' into separate methods
3. Clean up comments.
4. Tests: also check contents of files not affected by merge.

Change-Id: Ieb089668834d0a395c9ab192c555538917dfdc47
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-18 13:33:36 +01:00
Mathias Kinzler 264d3141a3 Merge "Moved tests for commit -o option to own test class" 2011-03-18 02:58:19 -04:00
Christian Halstrick 26f907a6cb Moved tests for commit -o option to own test class
We test the -o option of the commit command very accurate by
writing tests for each line of a decision table. In order to
still be able to point new jgit users to the CommitAndLogCommandTest
to find out how to use log() and commit() I factored out these 1200
lines of very specific tests into their own class.

Change-Id: Icf7c517f790a8fa79c8afd9b7f4a2805cf79196e
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-03-18 07:54:35 +01:00
Chris Aniszczyk a443043080 Add path filtering to LogCommand
Bug: 340049
Change-Id: I825b93b3412a3041aca225962fc8463a8f180650
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-03-17 14:47:41 -05:00
Shawn O. Pearce 04f7acb7e7 Assume refs of alternates are reachable during fetch
When fetching from a remote peer, consider all of the refs of any
alternate repository to be reachable locally, in addition to the refs
of the local repository.  This mirrors the push protocol and may avoid
unnecessary object transfer when the local repository is empty, but
its alternate and the remote share a lot of common history.

Junio C Hamano recently proposed a similar change to C Git's fetch
client, in order to work around a performance bug I identified when
fetching between two repositories that actually shared the same
alternate repository on the local system.

Change-Id: Iffb0b70e1223901ce2caac3b87ba7e0d6634d265
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-17 10:54:15 -07:00
Shawn O. Pearce c9a6980a42 UploadPack: Report invalid want lines with ERR
Instead of aborting hard with a server-side exception, report an error
to the client with "ERR %s" in a context where the client is expecting
ACK/NAK.  Older clients will report this text to the user, but newer
ones know how to format this message in a more user-friendly way.

Change-Id: I1879b38988ba66f648c069c10dbfa14c3f34adb2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-17 10:53:19 -07:00
Shawn O. Pearce b0a29c3fcf Handle "ERR %s" when ACK/NAK is expected
If the remote peer replies with "ERR %s" instead of "ACK %s common" or
"NAK" during ancestor negotiation in the fetch-pack/upload-pack
protocol, treat that as an exception that aborts processing with the
error text as supplied by the remote system.

This matches behavior with "ERR %s" during the advertisements, which
is also a way for the remote to abort processing.

Change-Id: I2fe818e75c7f46156744ef4f703c40173cbc76d0
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-17 10:51:31 -07:00
Shawn O. Pearce 00a5040147 PacketLineIn: Reuse internal lineBuffer for small strings
Most "ACK %s continue", "ACK %s common", "NAK" strings that are read
by the readACK() method and readString() are shorter than the
lineBuffer already available.  Reuse that buffer when reading from
the network stream and converting to a string with RawParseUtils to
avoid unnecessary temporary byte array allocations.

Change-Id: Ibc778d9f7721943a065041d80fc427ea50d90fff
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-17 10:48:05 -07:00
Shawn Pearce 5aab335f45 Merge "Expose if name or email is based on a guess" 2011-03-17 13:45:52 -04:00
Jens Baumgart fd963a9180 CommitCommand: add option to insert a change id
An option to insert a change id into the commit message was added
to CommitCommand.
This change is a prerequisite for removing GitIndex from EGit.

Change-Id: Iff9e26a8aaf21d8224bfd6ce3c98821c077bcd82
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-03-17 18:15:41 +01:00
Mathias Kinzler 6e2e7280d0 Merge "Remove deprecated Repository.mapTree" 2011-03-17 07:07:15 -04:00
Matthias Sohn 157a996e1d Expose if name or email is based on a guess
This enables applications to differentiate between explicitly set
configuration parameters and best effort attempts to guess these
parameters from the operating system.

Change-Id: I67cc4099238a40c6dca795e64f0155ced6008ef1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-16 16:23:14 +01:00
Philipp Thun c0112f97a1 Use parent directory in InitCommand if directory is "."
If no directory is set before executing an InitCommand, the current
directory (".") is used by default. By calling File.getParentFile() we
get the actual directory this points to. Using this directory makes it
easier to read paths.

Change-Id: I6245941395dae920e4f90b8985be6ef3cce570d3
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-16 01:36:56 +01:00
Chris Aniszczyk 8aef29c114 Merge "Improve native Git transport when following repository" 2011-03-15 12:03:38 -04:00
Shawn O. Pearce f18e1fd1d1 TransportProtocol: Allow null Repository in canHandle()
This allows callers to determine if a URI is supported, before
worrying about the local repository.

Suggested-by: Dariusz Luksza <dariusz@luksza.org>
Change-Id: Ifc76a4ba841f2e2e7354bd51306b87b3b9d7f6ab
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-03-15 10:11:01 -05:00
Chris Aniszczyk dffc50267e Merge "FS: Allow cloning an FS instance" 2011-03-15 11:09:16 -04:00
Chris Aniszczyk 786707fdfe Merge "FS: Allow userHome to be set and cached" 2011-03-15 11:05:37 -04:00
Chris Aniszczyk aa5f9ecdf2 Merge "FS: Allow gitPrefix to be set and cached" 2011-03-15 11:00:08 -04:00
Chris Aniszczyk e16e976e04 Merge "FS: Overload detect() with no arguments" 2011-03-15 10:57:58 -04:00
Shawn O. Pearce 74a129328e PushCommand: Allow adding any reference string
The simplified form of add(String) makes it easier for applications
to pass down user input and allow PushCommand to convert it to the
internal RefSpec object.

Change-Id: Ibd2e95852db0e52ea4a36032942c4c42a7fb4261
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-15 09:53:23 -05:00
Shawn O. Pearce 506ab8caa5 PushCommand: Add utilities for --all, --tags
The --all flag on the command line implies using refs/heads/* as
a push specification. Add this to the standard command object.

The --tags flag on the command line implies using refs/tags/* as
a push specification. Add this to the standard command object.

Change-Id: Iaef200b17cce77604548dbfb15cf2499b10687b5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-15 09:49:10 -05:00
Chris Aniszczyk 599a55e447 Merge "PushCommand: Default to pushing HEAD" 2011-03-15 10:01:04 -04:00
Chris Aniszczyk 582fb91f92 Merge "PushCommand: Set force-update in-place" 2011-03-15 10:00:33 -04:00