Commit Graph

2281 Commits

Author SHA1 Message Date
Colby Ranger b777d7797d Implement wasDeltaAttempted() in DfsObjectRepresentation.
In DFS, everything is stored in a pack but only objects in a pack with
source GC or UNREACHABLE_GARBAGE have had delta compression attempted.
Expose the PackSource setter and getter on DfsPackDescription in order
to implement wasDeltaAttempted.

Change-Id: Ie949f321147ad870f1c3f23b552343bbbda32152
2012-08-13 15:54:06 -07:00
Colby Ranger b77ba04976 Do not delta compress objects that have already tried to compress.
If an object is in a pack file already, delta compression will not
attempt to re-compress it. This assumes that the previous
packing already performed the optimal compression attempt, however,
the subclasses of StoredObjectRepresentation may use other heuristics
to determine if the stored format is optimal.

Change-Id: I403de522f4b0dd2667d54f6faed621f392c07786
2012-08-13 14:29:28 -07:00
Christian Halstrick 02113f7411 Merge "Allow JGit to read C Git rebase state" 2012-08-13 09:43:42 -04:00
Markus Duft 1e75941410 Make CheckoutCommand pass modified files through result
This change makes CheckoutCommand pass the list of modified files
through the OK result, enabling outside world to react in a smaller
scope (for example refresh only resources containing the modified
files).

Change-Id: I53c50ee09bc0d3ff501bdc25196e52e739c3f1f9
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-08-07 21:40:21 -07:00
Robin Rosenberg 993fcac2d3 Allow JGit to read C Git rebase state
C Git prefixes the time stamp in the author script with a "@"

Change-Id: I140b29519acc101da78296eef562368fc6b61135
2012-08-07 16:49:45 +02:00
Matthias Sohn e9c811d0d0 Allow detection of case insensitive file systems
Change-Id: I03f59d07bcc3338ef8d392cbd940799186ca03bd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2012-08-06 21:34:57 +02:00
Jevgeni Zelenkov 803debd7be Ensure a directory exists before trying to create/merge a file into it.
Since git doesn't keep track of empty directories, they should be
created first. Test case included demonstrates that using
StashApplyCommand(). Bugfix is applied to the DirCacheCheckout class,
because StashApplyCommand() uses it internally to apply a stash.

Change-Id: Iac259229ef919f9e92e7e51a671d877172bb88a8
Signed-off-by: Jevgeni Zelenkov <jevgeni.zelenkov@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-08-06 08:59:28 +02:00
Robin Rosenberg d08b35532a Merge "Fix PlotCommit for commits with duplicate parents" 2012-08-05 06:51:27 -04:00
Robin Rosenberg b2f911bb69 Fix PlotCommit for commits with duplicate parents
JGit allows to create commits which have duplicate parents: e.g. a
commit X has first parent Y and second parent Y. Such commits are not
handled correctly by PlotCommit leading to wrong display of the history
in EGit. In such cases there is a never ending passing line drawn beside
all commits younger than the commit with duplicate parents. This commit
fixes this by explicitly checking for duplicate parents.

In a different commit we should fix JGit not to create commits with
duplicate parents. I think native git also doesn't allow such commits,
although history display in native git (gitk, git log --graph) is not
damaged by such commits.

Change-Id: Ie3019ef613a507023958bea27b1badc3b8950279
2012-08-05 12:50:06 +02:00
Shawn Pearce 7c1e175de8 Merge "Update the README file to refer to the EDL rather than BSD license." 2012-08-01 17:29:04 -04:00
Robin Rosenberg f84fb60f02 Update the README file to refer to the EDL rather than BSD license.
The wordings of the two license are the same. This change is there
to make this file consistent with the LICENSE file.

Change-Id: I7c9d7a8f3622dd4099ca311af3dd032034bf56c0
2012-08-01 23:25:20 +02:00
Robin Rosenberg 0ec1db820d Merge "Fix resolving of relative file URIs in TransportLocal" 2012-07-29 18:31:39 -04:00
Robin Rosenberg 958a517c86 Merge "Garbage collector for FileRepositories" 2012-07-29 10:16:22 -04:00
Christian Halstrick 4c3f017a77 Garbage collector for FileRepositories
Implements a garbage collector for FileRepositories. Main ideas are
copied from the garbage collector for DFS based repos
(DfsGarbageCollector). Added functionalities are
- pruning loose objects
- handling of the index
- packing refs
- handling of reflogs (objects referenced from reflog will not be
pruned/)

These are features of a GC which are not handled in this change and
which should come with subsequent changes:
- unpacking packed objects into loose objects (to support that pruning
packed objects doesn't delete them until they are older than two weeks)
- expiration of reflogs
- support for configuration parameters (e.g. gc.pruneExpire)

Change-Id: I14ea5cb7e0fd1b5c50b994fd77f4e05bfbb9d911
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2012-07-29 15:43:50 +02:00
Shawn O. Pearce 0be3b0f70e Merge "Expose some DFS APIs as public or protected" 2012-07-29 01:01:35 -04:00
Shawn O. Pearce 3534fa9c61 Expose some DFS APIs as public or protected
Expose class DfsReader and method DfsPackFile.hasObject() as public.
Applications may want to be able to inquire about some details of
the storage of a repository. Make this possible by exposing some
simple accessor methods.

Expose method DfsObjDatabase.clearCache() as protected, allowing
implementing subclasses to dump the cache if necessary, and force
it to reload on a future request.

Change-Id: Ic592c82d45ace9f2fa5f8d7e4bacfdce96dea969
2012-07-27 06:59:32 -07:00
Robin Stocker beee7b86af Fix resolving of relative file URIs in TransportLocal
A configured remote url like "../repo" works with C Git.

In JGit, it only worked if Java's current working directory happened to
be the local repository working directory.

Change-Id: I33ba3f81b37d03cf17ca7ae25a90774a27e7e02b
Signed-off-by: Robin Stocker <robin@nibor.org>
2012-07-27 12:05:13 +02:00
Robin Rosenberg d47403ea94 Merge "[findBugs] Make ChunkKey serializable" 2012-07-26 17:21:51 -04:00
Christian Halstrick 778fdfaec1 Again teach ResolveMerger to create more correct DirCacheEntry's
Currently, after a merge/cherry-pick/rebase, all index entries are
smudged as the ResolveMerger never sets entry lengths and/or
modification times. This change teaches it to re-set them at least for
things it did not touch. The other entries are then repaired when the
index is persisted, or entries are checked out.

The first attempt to get this in was commit
3ea694c252 which has been reverted.
Since then some fixes to ResolveMerger and a few more tests have
been added which check situations where the index is not matching
HEAD before we merge.

Change-Id: I648fda30846615b3bf688c34274c6cf4bc857832
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Also-by: Markus Duft <markus.duft@salomon.at>
2012-07-26 16:20:38 +02:00
Shawn Pearce d87e56addd Merge "Revert "Teach ResolveMerger to create more correct DirCacheEntry's"" 2012-07-25 10:59:32 -04:00
Shawn Pearce 955b024995 Revert "Teach ResolveMerger to create more correct DirCacheEntry's"
This reverts commit 3ea694c252

Merges with unmodified subtrees are broken with this commit present.
Back it out until a fixed version can be supplied.
2012-07-24 20:07:48 -04:00
Robin Rosenberg c010c93694 Support [<ref>]@{upstream} revision syntax
Resolves into a ref name corresponding to the named (or current)
branch's upstream ref.

Change-Id: I98df46cedb498724cf14343fbb168f24ff667929
2012-07-20 08:29:10 +02:00
Robin Rosenberg 2a2362fbb3 Support parsing previous checkout as a revision expresion.
Repository.resolve can only return an ObjectId and will
continue to do so, but another method, simplify(), will
be able to return a branch name for some cases.

Previous checkouts can be specified as @{-n}, where n is an
integer speifying the n:th previous branch. The result
is the branch name, unless the checkout was a detached head,
in which case the object id is returned. Since the result
is a branch it may be followed by a references to the reflog,
such as @{-1}@{1} if necessary.

A simple expression like "master" is resolved to master in
simplify, but anything starting with refs gets resolved to
its object id, even if it is a branch.

A symbolic ref is resolved to its leaf ref, e.g. "HEAD" might
be resolved to "master".

Change-Id: Ifb815a1247ba2a3e2d9c46249c09be9d47f2b693
2012-07-20 08:20:48 +02:00
Robin Rosenberg 7f7a3f9b78 Merge "Teach ResolveMerger to create more correct DirCacheEntry's" 2012-07-19 09:26:23 -04:00
Markus Duft 3ea694c252 Teach ResolveMerger to create more correct DirCacheEntry's
Currently, after a merge/cherry-pick/rebase, all index entries are
smudged as the ResolveMerger never sets entry lengths and/or
modification times. This change teaches it to re-set them at least for
things it did not touch. The other entries are then repaired when the
index is persisted, or entries are checked out.

Change-Id: I0944f2017483d32043d0d09409b13055b5609a4b
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2012-07-19 10:30:59 +02:00
Shawn O. Pearce 189a01b617 show: Implement command line show for any object
Change-Id: I4dea84428d48b3de0e187c510b766f965323b21b
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2012-07-18 00:31:47 +02:00
Tomasz Zarna aeb28b1f3e Fix "description" in o.e.jgit.source.feature/feature.properties
Currently, update manager displays the comment message (starting with
"###...") which should not be part of the description.

Change-Id: I1c748cd5987b30f25aca3ca8eb593448bcf128ae
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2012-07-17 00:37:03 +02:00
Robin Rosenberg f82d1cb5c0 Allow a @ without branch in revision syntax
No branch before @ is interpreted as the currently checked out branch.
For detached heads it would be HEAD, but normally it is the branch
that HEAD refers to.

Change-Id: I051a1724fa390b8212e8986ba832b1347a20371e
2012-07-16 23:56:51 +02:00
Markus Duft 3c09e980cb Make ApplyCommand create missing parent directories for new files
Otherwise applying will fail with a FileNotFoundException, because
File.createNewFile() fails with missing parents.

Contains change & according test.

Change-Id: I970522b549b8bb260ca6720da11f12c57ee8a492
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
2012-07-16 09:04:30 -07:00
Christian Halstrick 0e285fbb8c Merge "Rename local variables in Repository.resolve" 2012-07-16 04:09:12 -04:00
Robin Stocker c4a4f851b7 [findBugs] Make ChunkKey serializable
It's used in DhtMissingChunkException, which is serializable.

Change-Id: I2b76bc1bc373efd44214be4598a03c62c681a200
Signed-off-by: Robin Stocker <robin@nibor.org>
2012-07-15 18:05:15 +02:00
Tomasz Zarna 75b60afe41 Typo in CLIText#unknownMergeStratey, should be #unknownMergeStrategy
Change-Id: I4d4aa59723d6422ff755165e45f368da76d309ab
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2012-07-14 15:15:31 +02:00
Robin Rosenberg 981720d150 Rename local variables in Repository.resolve
This is to prepare for extension. The new names better reflect
the content of the variables.

Change-Id: Ic2b4741ab33223aa7f239915d9138b254890bf7b
2012-07-13 18:45:24 +02:00
Robin Rosenberg 130925b879 Get rid of warning about possible NullPointerException
Do this by using one of the two references that are dependent
of checkReferencedIsReachable.

Change-Id: I4f16916c62ed8ea434013925f49fb03fe57b7d7e
2012-07-13 18:28:23 +02:00
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
Shawn Pearce 3c29bf0941 Merge "Serve 403 from RepositoryFilter on ServiceMayNotContinueException" 2012-06-21 10:45:41 -04: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