Commit Graph

1865 Commits

Author SHA1 Message Date
Shawn Pearce 234b4e0432 Merge "Break the dependency on RevObject when creating a newObjectToPack()." 2013-03-04 20:12:35 -05:00
Shawn Pearce 374406ac46 Merge "Fix RefUpdate performance for existing Refs" 2013-03-04 19:11:08 -05:00
Shawn Pearce 22625cd1d8 Merge "Fix corrupted CloneCommand bare-repo fetch-refspec (#402031)" 2013-03-04 17:53:02 -05:00
Colby Ranger be7a135e94 Break the dependency on RevObject when creating a newObjectToPack().
Update the ObjectReuseAsIs API to support creating new
ObjectToPack with only the AnyObjectId and Git object type. This is
needed to support the future pack index bitmaps, which only contain
this information and do not want the overhead of creating a temporary
object for every ObjectId.

Change-Id: I906360b471412688bf429ecef74fd988f47875dc
2013-03-04 14:43:22 -08:00
Colby Ranger 8d4f227c13 Merge "Remove the unused method PackFile.hasExt()." 2013-03-04 17:30:27 -05:00
Colby Ranger 1512d0ab4e Remove the unused method PackFile.hasExt().
It will be used in a future change, so just include it with that change.

Change-Id: I7db28d86f8e8b282a403acd9a4c4defaae828f94
2013-03-04 14:16:36 -08:00
Roberto Tyley a46b042905 Fix corrupted CloneCommand bare-repo fetch-refspec (#402031)
CloneCommand has been creating fetch refspecs like this on bare clones:

[remote "origin"]
        url = ssh://example.com/my-repo.git
        fetch = +refs/heads/*:refs/heads//*

As you can see, the destination ref pattern has a superfluous slash.

It looks like this behaviour has always been the case for CloneCommand,
at least since cc2197ed when code catering to bare-clone fetch refspecs
was added. That was released with JGit v1.0 almost 2 years ago, so
there will probably be some bare repos in the wild which will have been
cloned with JGit and have these corrupted refspecs.

The effect of the corrupted fetch refspec is quite interesting. Up to
and including JGit 2.0, the corrupt refspec was tolerated and fetches
would work as intended with no indication to the user that anything was
amiss. With JGit 2.1, a change was introduced which made JGit less
tolerant, and fetches now attempt to update the non-existing ref
"refs/heads//master". No exception is raised, but the real ref -
"refs/heads/master" - is not updated.

This behaviour was noticed by a user of Agit (which does bare clones by
default and recently updated from JGit v2.0 to v2.2), reported here:

https://github.com/rtyley/agit/issues/92


If you run C-Git fetch on a bare-repo cloned by JGit, it flat-out
rejects the refspec (checked against v1.7.10.4):

fatal: Invalid refspec '+refs/heads/*:refs/heads//*'

Incidentally, C-Git does not create an explicit fetch refspec at all
when performing a bare clone - the full remote config generated by C-Git
looks like this:

[remote "origin"]
        url = ssh://example.com/my-repo.git

Using JGit on such a repository works fine, so omitting the fetch
refspec entirely is also an option.

Change-Id: I14b0d359dc69b8908f68e02cea7a756ac34bf881
2013-03-04 00:03:20 +00:00
Roberto Tyley f1dea3e279 Fix RefUpdate performance for existing Refs
No longer invoke the expensive RefDatabase.isNameConflicting() check on
updating existing refs, reducing batch ref update time by ~97%.

The RefDirectory implementation of isNameConflicting() is quite
slow (it has to do an expensive loose-ref scan) but it's only necessary
to perform this check on ref update if the ref is being *created* - if
the ref already exists, we can already guarantee that it does not
conflict with any other refs.

C-Git seems to use a similar condition before making the
is_refname_available() check:

https://github.com/git/git/blob/v1.8.1.4/refs.c#L1660-L1670

As an example of the effects on performance, here's a simple timing
experiment using The BFG to remove one file from the JGit repo:

---
$ wget http://repo1.maven.org/maven2/com/madgag/bfg-repo-cleaner/1.0.1/bfg-1.0.1.jar
$ git clone --mirror https://git.eclipse.org/r/p/jgit/jgit.git
$ java -jar bfg-1.0.1.jar -D make_jgit.sh jgit.git
....
Updating references:    100% (5760/5760)
...Ref update completed in 148,949 ms.

BFG run is complete!
---

The execution time for the run is completely dominated by the batch ref
update at the end. Repeating the experiment with BFG v1.0.2 (using JGit
patched with this change), the refs update is dramatically reduced:

---
Updating references:    100% (5760/5760)
...Ref update completed in 4,327 ms.
---

Change-Id: I9057bc4ee22f9cc269b1cc00c493841c71527cd6
2013-03-01 21:49:58 +00:00
Shawn Pearce 178d55c24d Merge "Improve the documentation of the ByteArraySet used by PathFilterGroup" 2013-02-28 19:21:59 -05:00
Colby Ranger 4a317a1790 Include supported extensions in PackFile constructor.
Previously a PackFile class was assumed to only support a .pack and .idx
file. Update the constructor to enumerate the supported extensions for
the pack file. This will allow the bitmap code to only be executed if
the bitmap extension file is known to exist.

Change-Id: Ie59041dffec5f60d7ea2771026ffd945106bd4bf
2013-02-28 11:35:07 -08:00
Gustaf Lundh 212fb3071c Fix while boundries in DateRevQueue.add()
In add(), "low" will never equals "first". This fact
should be reflected in the code.

Change-Id: I5cab51374e67bd2d3301e5d9dac47c4259b5e562
2013-02-25 18:30:03 +01:00
Shawn Pearce 9613b04d81 Merge "Performance fixes in DateRevQueue" 2013-02-25 11:50:21 -05:00
Gustaf Lundh 84afea9179 Performance fixes in DateRevQueue
When a lot of commits are added to DateRevQueue, the
sort-on-insertion approach is very heavy on CPU cycles.

One approach to fix this was made by Dave Borowitz:
https://git.eclipse.org/r/#/c/5491/

But using Java's PriorityQueue seems to have brought some
extra overhead, and the desired performance could not be
reached.

This fix takes another approach to the insertion problem,
without changing the expected behaviour or bringing extra
memory overhead:

If we detect over 1000 commits in the DateRevQueue, a
"seek-index" is rebuilt every 1000th added commit.

The index keeps track of every 100th commit in the
DateRevQueue. During insertions, it will be used for a
preliminary scanning (binary search) of the queue, with
the intention of helping add() find a good starting point
to start walking from. After finding this starting point,
add() will step commit-by-commit until the correct
insertion place in the queue is found (today, the queue
is expected to be sorted at all times).

When applied to repositories with many refs, this approach
has proven to bring huge performance gains and scales quite
well.

For instance, in a repository with close to 80000 refs,
we could cut down the time a typical Gerrit replication
of 1 commit would take (just a push from JGit's point of
view) from 32sec down to 3.5sec.

Below you see some typical times to add a specific amount
of commits (with random commit times) to the DateRevQueue
and the difference the preliminary seek-index makes:

Commits | Index | No Index
   1024     8ms        8ms
   2048    13ms        9ms
   4096     5ms       59ms
   8192    11ms      595ms
  16384    22ms     3058ms
  32768    64ms    13811ms
  65536   201ms    62677ms
 131072   783ms   331585ms

Only one extra reference is needed for every 100 inserted
commits (and only when we see more than 1000 commits in
the queue), so the memory overhead should be negligible.

Various index-stepping values were tested, and 100 seemed to
scale very well and be effective from start.

In the future, it should probably be dynamic and based on
the number of refs in the queue, but this should serve well
as a starting point.

Note: While other fundamentally different data structures may
be more suitable, the DateRevQueue is extremely central to
many of the Git core operations. This approach was chosen,
since the effect of the patch is easy to predict in conjuction
with the current implementation. A totally new data structure
will make it harder to predict behaviour in many common and
uncommon cases (in terms of breaking ties, memory usage, cost
when using few elements, object creation/disposing overhead,
etc).

Change-Id: Ie7b99f40eacf6324bfb4716d82073adeda64d10f
2013-02-25 12:36:29 +01:00
George C. Young ab99b78ca0 Implement recursive merge strategy
Extend ResolveMerger with RecursiveMerger to merge two tips
that have up to 200 bases.

Bug: 380314
CQ: 6854
Change-Id: I6292bb7bda55c0242a448a94956f2d6a94fddbaa
Also-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Chris Aniszczyk <zx@twitter.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-22 23:51:50 +01:00
Robin Rosenberg 78606404de Improve the documentation of the ByteArraySet used by PathFilterGroup
Change-Id: I2ba7a67e8e1596aa6c33a9caddee03a6be48f008
2013-02-22 23:21:57 +01:00
Colby Ranger 95ef1e83d0 Fix off by one error in PackReverseIndex.
The last 32bit offset is at Integer.MAX_VALUE.

Change-Id: Idee8be3c7887e1d0c8339ff94aceff36dbf000db
2013-02-20 22:59:35 -08:00
Matthias Sohn c033f016c9 Merge branch 'stable-2.3'
* stable-2.3:
  Prepare 2.3.2-SNAPSHOT builds
  JGit v2.3.1.201302201838-r
  Accept Change-Id even if footer contains not well-formed entries
  Fix false positives in hashing used by PathFilterGroup

Change-Id: I5882aa3b482d6bcd40a45bed51e5ab03f018a5bc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-21 02:34:17 +01:00
Matthias Sohn 49ec6c1b3b Prepare 2.3.2-SNAPSHOT builds
Change-Id: I51a8a53194928416b1aef1f3fce0ce66aadceca4
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-21 02:13:15 +01:00
Matthias Sohn 63dceceb0e JGit v2.3.1.201302201838-r
Change-Id: I0d79873137ad4042ecc2a0210fe1f6305608b851
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-21 01:00:08 +01:00
Matthias Sohn 301df23d9b Merge "Accept Change-Id even if footer contains not well-formed entries" into stable-2.3 2013-02-20 18:35:44 -05:00
Stefan Lay 3b41fcbd96 Accept Change-Id even if footer contains not well-formed entries
Instead of only looking for a Change-Id in the last section if it 
consists only of well-formed "key: value" lines replace the last
occurrence of a valid Change-Id line in the last section. Some tools
require footer lines e.g. without a colon.

Gerrit doesn't accept Change-Id lines in the footer if the Change-Id
line doesn't start at the beginning of the line.

Bug: 400818
Change-Id: Icce54872adc8c566994beea848448a2f7ca87085
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-20 23:49:43 +01:00
Robin Stocker 5d7b722f6e Fix false positives in hashing used by PathFilterGroup
The ByteArraySet failed to check the length of the entry correctly leading
to matches where no match should be.

Bug: 401249
Change-Id: I925bc48d9cafcdf13e1a797bb09fc2555eb270c5
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2013-02-20 00:37:57 +01:00
Matthias Sohn ba6ae0c7ec Prepare 2.4.0-SNAPSHOT builds
Change-Id: I4ab2baeb5d598d40d5dadfccdfe75152a1b9b7bf
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-14 00:59:25 +01:00
Matthias Sohn 647acec3d9 Merge branch 'stable-2.3'
* stable-2.3:
  Prepare post 2.3.0.201302130906 builds
  JGit v2.3.0.201302130906
  Replace explicit version by property where possible
  Add better documentation to DirCacheCheckout
  Prepare post 2.3rc1 builds
  JGit v2.3.0.201302060400-rc1

Change-Id: I5a7626014dc38e7623937a4241dbf8a6db05c1f9
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-13 23:12:40 +01:00
Matthias Sohn 9a5f4b46cc Prepare post 2.3.0.201302130906 builds
Change-Id: Ia11b4000557d0cf235c4e33cda4539cab25fef47
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-13 23:08:30 +01:00
Matthias Sohn 19d6cadeff JGit v2.3.0.201302130906
Change-Id: If2e5fcbc01c2a7f058ef13d60b0bba5f77300d52
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-13 15:24:41 +01:00
Robin Rosenberg 8a9074fe21 Implement core.checkstat = minimal
There is a huge performance issue when using both JGit (EGit) and Git
because JGit does not fill all dircache stat fields with the values Git
would expect. As a result thereof Git would typically revalidate a large
number of tracked files. This can take several minutes for large
repositories with many large files.

Since 1.8.2 Git will restrict stat checking to the size and whole second
part of the modification time stamp, if core.statinfo is set to
"minimal".

As JGit checks only size and modification time this is close to what
JGit already does. To make the match perfect ignore the sub-second part
of the modification time stamp if core.statinfo = minimal.

Change-Id: I8eaff1858a891571075a86db043f9d80da3d7503
2013-02-10 17:29:58 +01:00
Dave Borowitz 51d0e1f26e Fix Config.fromText to not skip a last line with no newline
Change-Id: Id6da6ff19296410806282bb7419fd8455e8c5475
2013-02-08 11:36:50 -08:00
Robin Rosenberg 3a4ebc0c24 Really handle annotated tags in MergeCommand
Repository.peel() must be called to ensure a tag is really peeled.

Change-Id: I83e25f09fad3ad55a3ffe41ab4758f249b7ac9f9
2013-02-08 07:27:37 +01:00
Christian Halstrick 1c4ee41dc0 Add better documentation to DirCacheCheckout
Change-Id: I282b702d9e4cb19063d8e9503604538f80e955b7
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2013-02-07 00:05:39 +01:00
Matthias Sohn e9cf705c6e Prepare post 2.3rc1 builds
Change-Id: I5c7daa5a735bfc2ecb9adc11c392b94d235102b6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-06 16:10:20 +01:00
Matthias Sohn ea060dd8e7 JGit v2.3.0.201302060400-rc1
Change-Id: Id1f1d174375f7399cee4c2eb23368d4dbb4c384a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-06 14:12:51 +01:00
Robin Stocker 60d538fe51 Add getConflictingNames to RefDatabase
This has the same logic as isNameConflicting, but instead of only
returning a boolean, it returns a collection of names that conflict.

It will be used in EGit to provide a better message to the user when
validating a ref name, see Ibea9984121ae88c488858b8a8e73b593195b15e0.

Existing implementations of isNameConflicting could be rewritten like
this:

  return !getConflictingNames(name).isEmpty();

But I'm not sure about that, as isNameConflicting can be implemented in
a faster way than getConflictingNames.

Change-Id: I11e0ba2f300adb8b3612943c304ba68bbe73db8a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-02-06 08:48:54 +01:00
Robin Rosenberg aae08070c6 Merge "Extract method to output the first header line of a git diff" 2013-02-02 15:06:22 -05:00
Tobias Pfeifer 2c40482d0f Fixed problems occuring when changing user in gerrit configuration
Bug: 399238
Change-Id: I255634bc9b3681f292190051daed22a4771d6e57
Signed-off-by: Tobias Pfeifer <to.pfeifer@sap.com>
2013-02-01 16:05:31 +01:00
Robin Rosenberg 878e78b307 Fix stash apply using merge logic
Instead of the complicated strange stuff, implement staah
apply as cherry-pick.

Provided there are no conflicts and it is requested that
the index should be applied, perform yet another cherry-pick,
but discard tha results thereof it that would result in conflicts.

Bug: 376035
Change-Id: I553f3a753e0124b102a51f8edbb53ddeff2912e2
2013-01-30 11:38:19 -05:00
Tobias Pfeifer 0d09b1cab7 Extract method to output the first header line of a git diff
In order to be able to determine the range of the first header line
(e.g. "diff --git a/file1 b/file2") in subclasses, the code that formats
the first header line is extracted.

Required by egit's change: Ia61398146c0336ab332234f24d341561292554db

Change-Id: I9dd5eb964ed8b6869745c3162159b7425ac2c44a
Signed-off-by: Tobias Pfeifer <to.pfeifer@sap.com>
2013-01-30 13:27:50 +01:00
Robin Rosenberg eb60932930 Fix Check for FF_ONLY merges again
Added more FF-mode tests

Change-Id: I33eed5737d9411cc1cf214da62ce719916a1b736
2013-01-29 08:05:00 +01:00
Robin Rosenberg 83032e9f66 Merge "Check for FF_ONLY merges correctly" 2013-01-28 19:02:18 -05:00
Robin Rosenberg ee413067fd Merge changes Ife0cc2da,If38507ef
* changes:
  Speed up PathFilterGroup for large sets of paths
  Add test case for PathFilterGroup
2013-01-28 19:00:00 -05:00
Robin Rosenberg 642ff2cd7d Check for FF_ONLY merges correctly
Bug: 398192
Change-Id: I1253c0ea0632185bbf9f77e32f13ba5842a6e18e
2013-01-29 00:48:56 +01:00
Colby Ranger aa2db859ea Merge "Reduce memory held and speed up DfsGarbageCollector." 2013-01-22 18:55:36 -05:00
Colby Ranger 7fbd6588be Reduce memory held and speed up DfsGarbageCollector.
getObjectList() returns a list of ObjectToPack. These can hold on to a
lot of memory. Furthermore, binary searching for objects in a sorted
array can be slow. Improve the speed and reduce the memory by creating a
copy of the ObjectId and inserting it into an ObjectIdOwnerMap.

Change-Id: Ib5aa5b7447e05938b47fa55812a87b9872c20ea7
2013-01-22 15:25:15 -08:00
Robin Stocker 75ddf2a0f4 Enable marking entries using TreeFilters in DiffEntry
This adds a new optional TreeFilter[] argument to DiffEntry.scan. All
filters will be checked during the scan to determine if an entry should
be "marked" with regard to that filter.

After having called scan, the user can then call isMarked(int) on the
entries to find out whether they matched the TreeFilter with the passed
index.

An example use case for this is in the file diff viewer of EGit's
History view, where we'd like to highlight entries that are matching the
current filter.

See EGit change I03da4b38d1591495cb290909f0e4c6e52270e97f.

Bug: 393610
Change-Id: Icf911fe6fca131b2567514f54d66636a44561af1
Signed-off-by: Robin Stocker <robin@nibor.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2013-01-23 00:24:54 +01:00
Matthias Sohn 86759c23c2 Merge "Fix NPE FS_Win32 when looking up git executable and home directory avoiding redundant code" 2013-01-22 08:28:49 -05:00
Robin Rosenberg 522fc6a9c6 Speed up PathFilterGroup for large sets of paths
The ByteArraySet is a distorted copy of ObjectIdSubclassMap.

Bug: 397185
Change-Id: Ife0cc2da6cc46431be94a6b14f64f6adbe983afb
2013-01-21 15:54:56 +01:00
Robin Rosenberg 910a69d4c8 Merge "Improve handling of checkout conflicts" 2013-01-20 14:01:38 -05:00
Robin Rosenberg 9f7b97c90a Merge changes I7e7fae12,I87ecca00
* changes:
  Add conflicts message before footer
  Only replace the ChangeId in the footer, not in the body
2013-01-19 11:54:21 -05:00
Stefan Lay 215a74eceb Add conflicts message before footer
In case of a conflict during cherry-pick or revert the commit message
was amended after the footer. This made the footer invalid. Many users
do not understand that they have to edit the commit message in order to
make it valid again.

Change-Id: I7e7fae125129e2a0d8950510550acda766531835
Bug: 367416
2013-01-19 11:38:33 -05:00
Stefan Lay 1ca7c581a3 Only replace the ChangeId in the footer, not in the body
Additionally expose methods to find the first footer line and to find
the position of the ChangeId footer in the commit message in order to
enable reuse of these methods introduced for the fix.

Change-Id: I87ecca009ca3bff1ca0de3c436ebd95736bf5a10
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2013-01-19 17:37:09 +01:00