Commit Graph

571 Commits

Author SHA1 Message Date
Stefan Lay 7e1b2466e3 Do not catch Exception in test cases
Exception handling is already done by JUnit.

Change-Id: Ia25d768c311d384d728f281aced92f598e5e2041
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-07-06 23:10:52 +02:00
Christian Halstrick 18e10b41c9 Merge "Add lookup to remote config if the refSpec is not explicitly set" 2011-07-06 04:14:49 -04:00
Stefan Lay e2815f0121 Add lookup to remote config if the refSpec is not explicitly set
If no refSpec is explicitly set, the PushCommand should first check the
remote config and then as a fallback use the current behavior.


Change-Id: I2bc648abc517b1d01b2de15d383423ace2081e72
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-07-04 13:20:51 +02:00
Shawn O. Pearce 826fb260a3 TemporaryBuffer: Fix reading from in-memory InputStream
I had the conditions wrong here, causing the in-memory InputStream
to always appear to be at EOF.

Change-Id: I6811d6187a34eaf1fd6c5002550d631decdfc391
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-06-24 12:37:58 -07:00
Chris Aniszczyk 2cebb7dbc7 Add ReflogCommand
Adds a git-reflog command and associated tests.

Bug: 347859
Change-Id: Iba146ac842cc9ca0be43d3381b4082c9e92bf56f
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-06-22 18:32:50 -05:00
Chris Aniszczyk 65606dc086 Refactor out ReflogEntry
It's useful to have ReflogEntry refactored out so it can be
used by clients via the JGit API.

Change-Id: I03044df9af9f9547777545b7c9b93bdf5f8b7cb5
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-06-20 10:25:50 -05:00
Marc Strapetz 929862f322 Fix IndexOutOfBoundsException when parsing PersonIdent
IndexOutOfBoundsException could occur when parsing
PersonIdent for which no name is present, as part of a
RevCommit (nameB > 0).
2011-06-14 16:56:48 +02:00
Matthias Sohn f1713abcdc Prepare 1.1.0 builds
Change-Id: I4cf017cd567543846839612ab3ace6d26233e01d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-06-06 01:24:32 +02:00
Matthias Sohn f0d62fc609 Merge branch 'stable-1.0'
* stable-1.0:
  Prepare post v1.0.0.201106011211-rc3 builds
  JGit v1.0.0.201106011211-rc3
  Remove incubation marker
  blame: Compute the origin of lines in a result file
2011-06-02 01:45:50 +02:00
Matthias Sohn ada903085d Prepare post v1.0.0.201106011211-rc3 builds
Change-Id: I4dec8eba7e35858aef65fcc10f91fad3fe5b52b9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-06-01 18:55:11 +02:00
Matthias Sohn 81371d385b JGit v1.0.0.201106011211-rc3
Change-Id: I574a05200471c431b3a02ac6ff208dc6aa90f539
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-06-01 18:22:44 +02:00
Matthias Sohn f5f1536f3f Remove incubation marker
Change-Id: I6018ce0cd3b7c8137e137848fe1f04551b257538
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-05-31 22:53:53 +02:00
Shawn O. Pearce a390456047 blame: Compute the origin of lines in a result file
BlameGenerator digs through history and discovers the origin of each
line of some result file.  BlameResult consumes the stream of regions
created by the generator and lays them out in a table for applications
to display alongside of source lines.

Applications may optionally push in the working tree copy of a file
using the push(String, byte[]) method, allowing the application to
receive accurate line annotations for the working tree version.  Lines
that are uncommitted (difference between HEAD and working tree) will
show up with the description given by the application as the author,
or "Not Committed Yet" as a default string.

Applications may also run the BlameGenerator in reverse mode using the
reverse(AnyObjectId, AnyObjectId) method instead of push().  When
running in the reverse mode the generator annotates lines by the
commit they are removed in, rather than the commit they were added in.
This allows a user to discover where a line disappeared from when they
are looking at an older revision in the repository.  For example:

  blame --reverse 16e810b2..master -L 1080, org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/RefDirectoryTest.java
           (                                              1080)   }
  2302a6d3 (Christian Halstrick 2011-05-20 11:18:20 +0200 1081)
  2302a6d3 (Christian Halstrick 2011-05-20 11:18:20 +0200 1082)   /**
  2302a6d3 (Christian Halstrick 2011-05-20 11:18:20 +0200 1083)    * Kick the timestamp of a local file.

Above we learn that line 1080 (a closing curly brace of the prior
method) still exists in branch master, but the Javadoc comment below
it has been removed by Christian Halstrick on May 20th as part of
commit 2302a6d3.  This result differs considerably from that of C
Git's blame --reverse feature.  JGit tells the reader which commit
performed the delete, while C Git tells the reader the last commit
that still contained the line, leaving it an exercise to the reader
to discover the descendant that performed the removal.

This is still only a basic implementation.  Quite notably it is
missing support for the smart block copy/move detection that the C
implementation of `git blame` is well known for.  Despite being
incremental, the BlameGenerator can only be run once.  After the
generator runs it cannot be reused.  A better implementation would
support applications browsing through history efficiently.

In regards to CQ 5110, only a little of the original code survives.

CQ: 5110
Bug: 306161
Change-Id: I84b8ea4838bb7d25f4fcdd540547884704661b8f
Signed-off-by: Kevin Sawicki <kevin@github.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-31 14:09:30 -05:00
Shawn O. Pearce 690c268c79 Merge branch 'stable-1.0'
* stable-1.0:
  DHT: Support removing a repository name
  DHT: Fix thread-safety issue in AbstractWriteBuffer
  jgit.sh: Implement pager support
  Change EditList to extend ArrayList
  Ensure the HTTP request is fully consumed
  Make sure test repositories are closed
  Fix CloneCommand not to fetch into remote tracking branches when bare
  Update Eclipse IP log for 1.0

Change-Id: I6340d551482e1dda01f82496296d2038b07fa68b
2011-05-31 09:15:11 -07:00
Shawn O. Pearce 67a1a0993f Ensure the HTTP request is fully consumed
Some servlet containers require the servlet to read the EOF marker
from the input stream before a response can be output if the stream
is using "Transfer-Encoding: chunked"... which is typical for any
sort of large push to a repository over smart HTTP.

Ensure the EOF is always read by the PackParser when it is handling
the stream, and fail fast if there is more data present than expected
since this does indicate a protocol error.

Also ensure the EOF is read by UploadPack before it starts to output
a partial response using packing progress meters.

Change-Id: I131db9dea20b2324cb7c3272a814f21296bc64bd
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-05-31 08:58:45 -07:00
Christian Halstrick c1525e2aa5 Make sure test repositories are closed
Some repositories created during tests are not added to the 'toClose'
list in LocalDiskRepositoryTestCase. Therefore when the tests end
we may have open FileHandles and on Windows this may cause the
tests to fail because we can't delete those files.

This is fixed by adding the possibility to explicitly add
repositories to the list of repos which are closed automatically.

Change-Id: I1261baeef4c7d9aaedd7c34b546393bfa005bbcc
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-05-31 08:58:45 -07:00
Christian Halstrick cc2197ed9c Fix CloneCommand not to fetch into remote tracking branches when bare
When cloning into a bare repository we should not create remote
tracking branches (e.g refs/remotes/origin/testX). Branches of the
remote repository should but fetched into into branches of the same
name (e.g refs/heads/testX). Also add the noCheckout option which
would prevent checkout after fetch.

Change-Id: I5d4cc0389f3f30c53aa0065f38119af2a1430909
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-05-31 08:58:45 -07:00
Abhishek Bhatnagar b04be93344 CleanCommand: add the ability to do a dry run
Change-Id: I7b81a7e34a771951e2e7b789b080b2bfb8656e5c
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-31 09:15:07 -05:00
Robin Rosenberg 802f84650d Fix GitConstructionTest teardown
The teardown faile on Windows because the repos were not closed.

Change-Id: I16cf5645558680029682f898386b061796948237
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-05-30 22:39:04 +02:00
Chris Aniszczyk aa05559fd6 Merge "Let RefDirectory use FileSnapShot to handle fast updates" 2011-05-25 09:46:49 -04:00
Stefan Lay 05fa1713da Add a DiffFormatter which calculates a patch-id
Adds a class which can be used to calculates a SHA1 of the diff
associated with a patch, similar to git patch-id.

In this version whitespace is not ignored.

Change-Id: I421d15ea905e23df543082786786841cbe3ef10d
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-24 18:08:47 -05:00
Abhishek Bhatnagar 7d380e9c5e Add CleanCommandTest and fix CleanCommand
Bug: 334767
Change-Id: I0a836451ceb668f943b1f353dc65420157810b23
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-24 17:32:19 -05:00
Christian Halstrick 2302a6d3ce Let RefDirectory use FileSnapShot to handle fast updates
Since this change may affect performance and memory consumption on every
access to a loose ref I explicitly made it a RFC to collect opinions.

Previously RefDirectory.scanRef() was not detecting an update of a
loose ref when the update didn't changed the modification time of
the backing file. RefDirectory cached loose refs and the way to detect
outdated cache entries was to compare lastmodification timestamp on the
file representing the ref. If two updates to the same ref happen faster
than the filesystem-timer granularity (for linux this is 2 seconds)
there is the possiblity that we don't detect the update.

Because of this bug EGit's PushOperationTest only works with 2 second
sleeps inside.

This change let RefDirectory use FileSnapshot to detect such situations.
FileSnapshot helps to remember when a file was last read from disk and
therefore enables to decide when to load a file from disk although
modification time has not changed.

Change-Id: I03b9a137af097ec69c4c5e2eaa512d2bdd7fe080
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-23 14:48:10 -05:00
Kevin Sawicki 16e810b2ec Add shortening of note ref names to NoteMap
Change-Id: I224190bbb41c7cbea38388d0148ecc6dc68f3a14
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-05-23 11:39:33 -07:00
Shawn Pearce c25c60061d Merge "Remove rebase temporary files on checkout failure" 2011-05-23 11:33:49 -04:00
Ketan Padegaonkar 3344b93c84 Add GitAddTask
Change-Id: Ia9a3c9f4728e13d1e62f530b1d843d09afb4eb42
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-23 08:39:40 -05:00
Bernard Leach cf846cfb0b Remove rebase temporary files on checkout failure
A checkout conflict during rebase setup should leave the repository
in SAFE state which means ensuring that the rebase temporary files
need to be removed.

Bug: 346813
Change-Id: If8b758fde73ed5a452a99a195a844825a03bae1a
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-23 08:24:30 -05:00
Chris Aniszczyk 40fa75feb4 Add LsRemoteCommandTest
Bug: 343801
Change-Id: I4a91d93428bbf7f74033fcea5823266fa52d7a0c
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-19 14:45:21 -05:00
Bernard Leach 5ec4977bb5 Create a MergeResult for deleted/modified files
Change Ia2ab4f8dc95020f2914ff01c2bf3b1bc62a9d45d added merge
support for when OURS or THEIRS was simultaneously deleted
and modified.  That changeset however did not add create an
entry in the conflicts table so clients would see a CONFLICTING
result but getConflicts() would return null.

This change creates a MergeResult for the conflicting file.

Bug: 345684
Change-Id: I52acb81c1729b49c9fb3e7a477c6448d8e55c317
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-19 09:22:25 -05:00
Bernard Leach 37fe0988b2 Add reset with paths support to ResetCommand
Bug: 338701
Change-Id: Id7cbce47131b459e632ddc2c9a94628c7d0b75cd
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-19 09:04:09 -05:00
Ketan Padegaonkar f953a35e9a Fix NPE in URIish when parsing an empty URI
Change-Id: Id1c42dc9843f62c581b9904b02150de53cf7777c
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-19 08:58:17 -05:00
Bernard Leach e3c4610c74 Add tests for change If203ce5
Bug: 344779
Change-Id: I1628984479d93665bf4987d6a4ff8e67ad73eb36
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-18 11:43:57 -05:00
Piotr Janik 7449b9a297 Fix path filtering in LogCommand
Bug: 346257
Change-Id: Ib897e1b4962162da9670164479a844aeea7dfcd1
Signed-off-by: Piotr Janik <janikpiotrek@gmail.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-18 10:35:25 -05:00
Robin Rosenberg d781554b79 Merge "Optimize MergeAlgorithm if ours or theirs is empty" 2011-05-17 08:54:18 -04:00
Christian Halstrick 0461ff4f0c Optimize MergeAlgorithm if ours or theirs is empty
Previously when merging two contents with a non-empty base and one of
the contents was empty (size == 0) and the other was modified there
was a potentially expensive calculation until we finally always come
to the same result -> the complete non-deleted content should collide
with the empty content.

This proposal adds an optimization to detect empty input content and
to produce the appropriate result immediatly.

Change-Id: Ie6a837260c19d808f0e99173f570ff96dd22acd3
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-05-17 10:59:17 +02:00
Shawn O. Pearce c2b87d59a0 Fix diff bug on inserted line
For the following patch on the linux 2.6.32 tag:
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -685,6 +685,7 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sc

 static void check_spread(struct cfs_rq *cfs_rq, struct sched_entity *se)
 {
+#if 0
 #ifdef CONFIG_SCHED_DEBUG
        s64 d = se->vruntime - cfs_rq->min_vruntime;

@@ -694,6 +695,7 @@ static void check_spread(struct cfs_rq *cfs_rq, struct
sched
        if (d > 3*sysctl_sched_latency)
                schedstat_inc(cfs_rq, nr_spread_over);
 #endif
+#endif
 }

 static void

JGit produced an incorrect diff, attempting to add a new "}" instead
of the new "#endif" at the end of the hunk. This was caused by a prior
fix for bug 328895 where we wanted to "slide" a diff down in the file
when adding a new method/function and want to show the closing curly
brace as being added after the new method, rather than added onto the
end of the prior function or method just before the insertion point.

Bug: 345956
Change-Id: I32b9e24f1e2980258b1b39dd1807919ab1c5f9b2
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-05-16 11:28:23 -07:00
Shawn Pearce 4b4df4ccf8 Merge "Fix diff when first text is the start of the other" 2011-05-15 15:17:52 -04:00
Robin Rosenberg 51a5cc7f1a Fix diff when first text is the start of the other
The problem occurred when the first text ends in the middle
of the last line of the other text and the first text has no
end of line.

Bug: 344975
Change-Id: I1f0dd9f8062f2148a7c1341c9122202e082ad19d
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-05-15 20:34:05 +02:00
Chris Aniszczyk 24ce43de0c Merge "Add test for reflog part of ResetCommand" 2011-05-13 18:05:58 -04:00
Robin Rosenberg e9311e526c Add test for reflog part of ResetCommand
The reflog message fix was done in
I4f1c3cd6b2cf543be213f061afb94223062dde51

Change-Id: I44817ccf4bf226ed3e4ce6fb2d923e88788221dd
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-05-13 23:45:54 +02:00
Robin Stocker a31590ff63 RevertCommand: Add "." after reverted commit id
This makes the message look the same as in C Git (the "."):

  This reverts commit <sha1>.

Change-Id: I4c254c122277b127e7b039c0d1c7f7a0d691530d
Signed-off-by: Robin Stocker <robin@nibor.org>
2011-05-13 13:39:54 +02:00
Matthias Sohn c05c6f3327 Formatter for relative dates
Change-Id: I78b307177c68c578e10101a0ee7b6306880a08f7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-05-09 14:46:38 +02:00
Stefan Lay 05bb92980b Fix getHumanishName broken for windows paths
Since d1718a the method getHumanishName was broken on windows since
the URIish is not normalized anymore. For a path like
"C:\gitRepositories\egit" the whole path was returned instead of
"egit".

Bug: 343519
Change-Id: I95056009072b99d32f288966302d0f8188b47836
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-05-06 10:42:51 +02:00
Bernard Leach 298486a7c3 IndexDiff: conflicting files aren't properly shown
Before this change any files in the conflicting set would
also be listed in the the other IndexDiff Sets which is
confusing.  With this change a conflicting file will not
be included in any of the other sets.

Change-Id: Ife9f2652685220bcfddc1f9820423acdcd5acfdc
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-05 13:48:57 -05:00
Robin Stocker 7546e3b4c5 Fix "into" part of merge message for HEAD
Merging into a non-master branch would result in the following message:

  Merge branch 'a' into HEAD

Now the merge message is correct:

  Merge branch 'a' into b

Change-Id: I488f97190e4c1711c23a7a3cbd64f8b13a87bbac
Signed-off-by: Robin Stocker <robin@nibor.org>
2011-05-05 17:50:44 +02:00
Bernard Leach 98b019f4bd Implemented merge for parallel delete/modification
Duplicates cgit behaviour for merging the case where
OURS is deleted and THEIRS is modified as well as
OURS is modified and THEIRS id deleted.

Change-Id: Ia2ab4f8dc95020f2914ff01c2bf3b1bc62a9d45d
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-05-03 12:11:52 -05:00
Stefan Lay f2a146d033 Merge "Add path support to checkout command." 2011-05-03 11:39:11 -04:00
Kevin Sawicki ec92f8f59e Add path support to checkout command.
Change-Id: I89e8edfc6dd87d5bf8fd08704df2432720084330
Signed-off-by: Kevin Sawicki <kevin@github.com>
2011-05-03 08:07:15 -07:00
Matthias Sohn f9d7b0d21e Qualify post-0.12 builds
Change-Id: I70fe2671321efb5c3d271121ce00299533d1b388
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-05-03 00:19:54 +02:00
Matthias Sohn d085a8954f Merge branch 'stable-0.12'
* stable-0.12:
  JGit 0.12.1
2011-05-03 00:11:47 +02:00
Matthias Sohn b2b58feba7 JGit 0.12.1
Change-Id: Ia6e58b466fa3ef7ddd61b40f2ad44141fe8786c4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-05-02 18:24:45 +02:00
Shawn O. Pearce b9691b94a3 Merge branch 'stable-0.12'
* stable-0.12:
  Fix sorting of names in RefDirectory
  Make running static checks configurable in maven build
  Add constants for gerrit change id configuration
2011-04-21 15:41:10 -07:00
Shawn O. Pearce 33e65ec691 Fix sorting of names in RefDirectory
RefDirectory did not correctly follow the contract of RefList.  The
contract says if you use add() method of RefList builder, you MUST
sort() it afterwards, and later every other method assumes that list
is properly sorted (especially the binary search in the find() and
get() methods).  Instead RefDirectory class tried to scan the refs
recursively while sorting every folder in the process before
processing and did not call sort().

For example, when scanning the contents of refs/tags project1 string
is smaller than project1-*, so it will recursively go into the folder
and add these tags first and only then will add project-* ones. This
will result in a broken list (any project1-* string is less than
project1/* one, but they all appear after them in the list), that's
why binary search will fail making loose RefList and the whole local
RefMap completely unusable.

Change-Id: Ibad90017e3b2435b1396b69a22520db4b1b022bb
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-04-21 12:40:26 -07:00
Bernard Leach 1a867d10b9 Added support to IndexDiff to return information on conflicts
Change-Id: I43c13eb72a44f80135c93525fce0c0280b0e64a2
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-04-19 17:11:01 -05:00
Leonard Broman 09be3948cd Hande latin-1 encoding
Bug: 342259
Change-Id: Ie285b8819b5ea6f9892ebafc4ebbd9c6d091d1fe
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-04-11 11:55:55 -05:00
Chris Aniszczyk e109529d6f Add NotesCommand to the JGit API
Bug: 334765
Change-Id: Ie0fb79671e7a741eb85651f507b8ade930bfcc20
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-04-10 21:25:14 -05:00
Matthias Sohn ea0f2f9e39 Create all test data in trash folder
This ensures that all test data is separated from project sources and
cleaned up after the test. Previously the cloned bare test repository
was created in org.eclipse.jgit.test/ and not deleted after the test
run.

Change-Id: I55110442e365fc8fe610f1c372f72a71ee6e1412
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-04-10 01:02:29 +02:00
Robin Stocker 5dbef3fa51 Add "Conflicts" section to merge message on conflict
The same as with cherry-pick, the commit message of a merge should
include a "Conflicts" section when the merge resulted in conflicts.

Change-Id: I6261dc898262322924af5ca1bef841a654b0df55
Signed-off-by: Robin Stocker <robin@nibor.org>
2011-04-06 22:57:49 +02:00
Robin Stocker 6e10aa42e9 Add CHERRY_PICK_HEAD for cherry-pick conflicts
Add handling of CHERRY_PICK_HEAD file in .git (similar to MERGE_HEAD),
which is written in case of a conflicting cherry-pick merge.

It is used so that Repository.getRepositoryState can return the new
states CHERRY_PICKING and CHERRY_PICKING_RESOLVED. These states, as well
as CHERRY_PICK_HEAD can be used in EGit to properly show the merge tool.

Also, in case of a conflict, MERGE_MSG is written with the original
commit message and a "Conflicts" section appended. This way, the
cherry-picked message is not lost and can later be re-used in the commit
dialog.

Bug: 339092
Change-Id: I947967fdc2f1d55016c95106b104c2afcc9797a1
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-04-06 13:28:10 -05:00
Stefan Lay fbf35fea4e Add parameters for timeout and branches to clone
The timeout is also used in the FetchCommand called by the
CloneCommand. 

The possibility to provide a list of branches to fetch initially is a
feature offered by EGit. To implement it here is a prerequisite for
EGit to be able to use the CloneCommand.

Change-Id: I21453de22e9ca61919a7c3386fcc526024742f5f
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-04-06 15:00:22 +02:00
Stefan Lay 792b93bc62 Try to checkout branch after cloning
When no branch was specified in the clone command, HEAD pointed to a
commit after clone. Now the clone command tries to find a branch which
points to the same commit and checks out this branch.

Bug: 339354
Change-Id: Ie3844465329f213dee4a8868dbf434ac3ce23a08
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
2011-04-06 14:58:48 +02:00
Christian Halstrick 12d7e3af1a Merge "Add open(File) and wrap(Repository) to Git" 2011-04-02 03:38:07 -04:00
Christian Halstrick 82372d36f8 Add open(File) and wrap(Repository) to Git
When a new Git instance for an exisiting git repository should be
created there are two use-cases: either the application has already a
Repository instance in hand or the application knows where the
repository resides in the filesystem. Two methods are added to
explicitly support these use-cases: wrap(Repository db) and open(File
gitDir)

Change-Id: I2970e4aa8d4602cb1298f01e5b76bf0f96c492e5
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2011-04-02 09:33:45 +02:00
Shawn O. Pearce c261b28f67 RefDirectory: Use FileSnapshot for packed-refs
Instead of tracking the length and modification time by hand, rely
on FileSnapshot to tell RefDirectory when the $GIT_DIR/packed-refs
file has been changed or should be re-read from disk.

Change-Id: I067d268dfdca1d39c72dfa536b34e6a239117cc3
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-04-01 17:49:09 -05:00
Shawn Pearce a4c142286e Merge changes I2c8e917a,Ica9e50c0
* changes:
  Do not normalize URIishes
  Use Ignore to bypass unused test
2011-04-01 15:20:37 -04:00
Robin Rosenberg d1718a34d3 Do not normalize URIishes
We used to normalize URI's since it seems simple. This however causes
inconsistencies to the user and to out tests. Just pass backslashes
through and make sure our parser can handle them.

Bug: 341062
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Change-Id: I2c8e917a086faabcd8749160c2acc9dd05a42838
2011-03-28 07:41:48 +02:00
Robin Rosenberg 73602c448c Use Ignore to bypass unused test
Change-Id: Ica9e50c0d512865d217f55bf0d100f27878031b9
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-03-28 07:41:45 +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
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
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
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
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 9cde331c2b Merge "BlockList: Micro-optimize appending from another BlockList" 2011-03-19 12:32:19 -04: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
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
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 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
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 ed2a8b5acf Merge "CloneCommand: add a test to ensure we fetch all tags" 2011-03-15 09:57:32 -04:00
Chris Aniszczyk 317d8e2e8d Merge "PackWriter: Rename getObjectsNumber to getObjectCount" 2011-03-14 18:09:40 -04:00
Chris Aniszczyk 92078473aa CloneCommand: add a test to ensure we fetch all tags
Bug: 326611
Change-Id: Ibf9a7caa84d99f39fca88bebc10c03b01955146d
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-03-14 17:02:29 -05:00
Jens Baumgart 9830baf48d CommitCommand: set correct Reflog message when amending
Change-Id: I2322d31b09ca63bdcee50e90340e326467dc5021
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-03-14 15:51:31 -05:00
Shawn O. Pearce 7a9bf1e2e0 PackWriter: Rename getObjectsNumber to getObjectCount
This better matches with PackFile and CachedPack's methods
that return the same value.

Change-Id: Idb9b7c71d2048dd2344a62c2cde20b4e34529ab7
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-14 08:01:52 -07:00
Shawn O. Pearce 65f9a6e58b Fix dumb transport push
PackWriter incorrectly returned 0 from getObjectsNumber() when the
pack has not been written yet. This caused dumb transports like
amazon-s3:// and sftp:// to abort early and never write out a pack,
under the assumption that the pack had no objects.

Until the pack header is written to the output stream, compute the
current object count each time it is requested. Once the header is
started, use the object count from the stats object.

Change-Id: I041a2368ae0cfe6f649ec28658d41a6355933900
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-14 08:01:51 -07:00
Shawn O. Pearce bd970007be ObjectIdOwnerMap: More lightweight map for ObjectIds
OwnerMap is about 200 ms faster than SubclassMap, more friendly to the
GC, and uses less storage: testing the "Counting objects" part of
PackWriter on 1886362 objects:

  ObjectIdSubclassMap:
    load factor 50%
    table: 4194304 (wasted 2307942)
    ms spent 36998 36009 34795 34703 34941 35070 34284 34511 34638 34256
    ms avg 34800 (last 9 runs)

  ObjectIdOwnerMap:
    load factor 100%
    table: 2097152 (wasted 210790)
    directory: 1024
    ms spent 36842 35112 34922 34703 34580 34782 34165 34662 34314 34140
    ms avg 34597 (last 9 runs)

The major difference with OwnerMap is entries must extend from
ObjectIdOwnerMap.Entry, where the OwnerMap has injected its own
private "next" field into each object. This allows the OwnerMap to use
a singly linked list for chaining collisions within a bucket. By
putting collisions in a linked list, we gain the entire table back for
the SHA-1 bits to index their own "private" slot.

Unfortunately this means that each object can appear in at most ONE
OwnerMap, as there is only one "next" field within the object instance
to thread into the map. For types that are very object map heavy like
RevWalk (entity RevObject) and PackWriter (entity ObjectToPack) this
is sufficient, these entity types are only put into one map by their
container.  By introducing a new map type, we don't break existing
applications that might be trying to use ObjectIdSubclassMap to track
RevCommits they obtained from a RevWalk.

The OwnerMap uses less memory. Each object uses 1 reference more (so
we're up 1,886,362 references), but the table is 1/2 the size (2^20
rather than 2^21). The table itself wastes only 210,790 slots, rather
than 2,307,942. So OwnerMap is wasting 200k fewer references.

OwnerMap is more friendly to the GC, because it hardly ever generates
garbage. As the map reaches its 100% load factor target, it doubles in
size by allocating additional segment arrays of 2048 entries. (So the
first grow allocates 1 segment, second 2 segments, third 4 segments,
etc.)  These segments are hooked into the pre-allocated directory of
1024 spaces. This permits the map to grow to 2 million objects before
the directory itself has to grow. By using segments of 2048 entries,
we are asking the GC to acquire 8,204 bytes in a 32 bit JVM. This is
easier to satisfy then 2,307,942 bytes (for the 512k table that is
just an intermediate step in the SubclassMap). By reusing the
previously allocated segments (they are re-hashed in-place) we don't
release any memory during a table grow.

When the directory grows, it does so by discarding the old one and
using one that is 4x larger (so the directory goes to 4096 entries on
its first grow). A directory of size 4096 can handle up to 8 millon
objects. The second directory grow (16384) goes to 33 million objects.
At that point we're starting to really push the limits of the JVM
heap, but at least its many small arrays. Previously SubclassMap would
need a table of 67108864 entries to handle that object count, which
needs a single contiguous allocation of 256 MiB. That's hard to come
by in a 32 bit JVM. Instead OwnerMap uses 8192 arrays of about 8 KiB
each. This is much easier to fit into a fragmented heap.

Change-Id: Ia4acf5cfbf7e9b71bc7faa0db9060f6a969c0c50
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-13 16:39:30 -07:00
Shawn O. Pearce 305a8ac45f Make the supported Transports extensible and discoverable
The new TransportProtocol type describes what a particular Transport
implementation wants in order to support a connection.  3rd parties
can now plug into the Transport.open() logic by implementing their
own TransportProtocol and Transport classes, and registering with
Transport.register().

GUI applications can help the user configure a connection by looking
at the supported fields of a particular TransportProtocol type, which
makes the GUI more dynamic and may better support new Transports.

Change-Id: Iafd8e3a6285261412aac6cba8e2c333f8b7b76a5
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-13 16:23:56 -07:00
Philipp Thun a490afedba Add -o option to commit command
This change adds the --only/ -o option to the commit command.

Change-Id: I44352d56877f8204d985cb7a35a2e0faffb7d341
Signed-off-by: Philipp Thun <philipp.thun@sap.com>
2011-03-11 14:25:46 +01:00