Commit Graph

1262 Commits

Author SHA1 Message Date
Shawn O. Pearce 4e187d898a PackFile: Fix copy as-is for small objects
When I disabled validation I broke the code that handled copying small
objects whose contents were below 8192 bytes in size but spanned over
the end of one window and into the next window.  These objects did not
ever populate the temporary write buffer, resulting in garbage writing
into the output stream instead of valid object contents.

Change-Id: Ie26a2aaa885d0eee4888a9b12c222040ee4a8562
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-04 18:56:16 -08:00
Shawn Pearce 8f0d55e334 Merge "PushCommand: Test for update of tracking branch" 2011-03-04 16:55:32 -05:00
Shawn Pearce b9df3e6019 Merge "Fix DirCache re-read." 2011-03-04 10:19:06 -05:00
Shawn Pearce 2d4750ead8 Merge "Use generics in RepositoryFilter constructor" 2011-03-04 10:17:27 -05:00
Robin Rosenberg 3947bd25d9 Fix DirCache re-read.
During unit tests and most likely elsewhere, updates come too fast for
a simple timestamp comparison (with one seconds resolution) to work.
I.e. DirCache thinks it hasn't changed. 

Use FileSnapshot instead which has more advanced logic.

Change-Id: Ib850f84398ef7d4b8a8a6f5a0ae6963e37f2b470
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
2011-03-04 16:00:25 +01:00
Robin Stocker 4fb185ab67 PushCommand: Test for update of tracking branch
Bug 317411 (Push does not update remote tracking branch) is assigned to
JGit. This test verifies that JGit does the right thing.

Bug: 317411
Change-Id: I8f632e3e6c8a4f16a1170b1dba92e8fd3d6267d0
2011-03-04 15:45:18 +01:00
Shawn O. Pearce 25ba407387 Merge changes I52054d7b,If5865ac9
* changes:
  resolve(): Fix wrong parsing of branch "foo-gbed2-dev"
  RemoteRefUpdate: Accept Ref and ObjectId arguments for source
2011-03-04 09:21:59 -05:00
Christian Halstrick 18833252c6 Merge "Adapt to Jetty 7.3 API change coming with Indigo" 2011-03-04 03:32:20 -05:00
Shawn O. Pearce b21c82fdb0 resolve(): Fix wrong parsing of branch "foo-gbed2-dev"
When parsing a string such as "foo-gbed2" resolve() was assuming the
suffix was from git describe output.  This lead to JGit trying to find
the completion for the object abbreviation "bed2", rather than using
the current value of the reference.  If there was only one such object
in the repository, JGit might actually use the wrong value here, as
resolve() would return the completion of the abbreviation "bed2"
rather than the current value of the reference "refs/heads/foo-gbed2".

Move the parsing of git describe abbreviations out of the operator
portion of the resolve() method and into the simple portion that is
supposed to handle only object ids or reference names, and only do the
describe parsing after all other approaches have already failed to
provide a resolution.

Add new unit tests to verify the behavior is as expected by users.

Bug: 338839
Change-Id: I52054d7b89628700c730f9a4bd7743b16b9042a9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-03 16:17:29 -08:00
Shawn O. Pearce 3ee3588b86 RemoteRefUpdate: Accept Ref and ObjectId arguments for source
Applications may already have a Ref or ObjectId on hand that they want
the remote to be updated to.  Instead of converting these into a
String and relying on the parsing rules of resolve(), allow the
application to supply the Ref or ObjectId directly.

Bug: 338839
Change-Id: If5865ac9eb069de1c8f224090b6020fc422f9f12
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-03 15:13:33 -08:00
Matthias Sohn d353107729 Improve readability of timestamps shown by debug-show-dir-cache
The old format is hard to read.

Change-Id: I27f3a7dbd92b26256993d27d5223b743fef70902
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-03 16:19:47 +01:00
Matthias Sohn 3de0df93d4 Enhance debug-show-dir-cache command to show stage
Change-Id: I6fb17ec7f04f8bfaf1253b2ff08200ef9fc51898
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-03 10:56:38 +01:00
Shawn O. Pearce a468cb57c2 PackWriter: Validate reused cached packs
If object reuse validation is enabled, the output pack is going to
probably be stored locally.  When reusing an existing cached pack
to save object enumeration costs, ensure the cached pack has not
been corrupted by checking its SHA-1 trailer.  If it has, writing
will abort and the output pack won't be complete.  This prevents
anyone from trying to use the output pack, and catches corruption
before it can be carried any further.

Change-Id: If89d0d4e429d9f4c86f14de6c0020902705153e6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-02 12:49:00 -08:00
Shawn O. Pearce 1b2062fe37 PackWriter: Avoid CRC-32 validation when feeding IndexPack
There is no need to validate the object contents during
copyObjectAsIs if the result is going to be parsed by unpack-objects
or index-pack.  Both programs will compute the SHA-1 of the object,
and also validate most of the pack structure.  For git daemon
like servers, this work is already done on the client end of the
connection, so the server doesn't need to repeat that work itself.

Disable object validation for the 3 transport cases where we know
the remote side will handle object validation for us (push, bundle
creation, and upload pack).  This improves performance on the server
side by reducing the work that must be done.

Change-Id: Iabb78eec45898e4a17f7aab3fb94c004d8d69af6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-02 12:23:58 -08:00
Shawn O. Pearce bd6853e90a PackWriter: Position tags after commits
Annotated tags need to be parsed by many viewing tools, but putting
them at the end of the pack hurts because kernel prefetching might
not have loaded them, since they are so far from the commits they
reference.

Position tags right behind the commits, but before the trees.
Typically the annotated tag set for a repository is very small,
so the extra prefetch burden it puts on tools that don't need
annotated tags (but do need commits and trees) is fairly low.

Change-Id: Ibbabdd94e7d563901c0309c79a496ee049cdec50
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01 10:07:08 -08:00
Shawn O. Pearce 26dffbe04d PackWriter: Refactor object writing loop
This simple refactoring makes it easier to pre-process each of the
object lists before its handed into the actual write routine.

Change-Id: Iea95e5ecbc7374f6bcbb43d1c75285f4f564d09d
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01 10:07:08 -08:00
Shawn O. Pearce 751c329b35 PackWriter: Don't reuse commit or tag deltas
JGit doesn't generate deltas for commit or tag objects when it packs
a repository from scratch.  This is an explicit design decision that
is (mostly) justified by the fact that these objects do not delta
compress well.

Annotated tags are made once on stable points of the project history,
it is unlikely they will ever appear again with sufficient common
text to justify using a delta over just deflating the raw content.
JGit never tries to delta compress annotated tags and I take the
stance that these are best stored as non-deltas given how frequently
they might be accessed by repository viewers.

Commits only have sufficient common text when they are cherry-picked
to forward-port or back-port a change from one branch to another.
Even in these cases the distance between the commits as returned
by the log traversal has to be small enough that they would both
appear in the delta search window at the same time in order to
delta compress one of the messages against the other.  JGit never
tries to delta compress commits, as it requires a lot of CPU time
but typically does not produce a smaller pack file.

Avoid reusing deltas for either of these types when constructing a
new pack.  To avoid killing performance during serving of network
clients, UploadPack disables this code change by allowing PackWriter
to reuse delta commits.  Repositories that were already repacked by
C Git will not have their delta commits decompressed and recompressed
on the fly during object writing, saving server-side CPU resources.

Change-Id: I749407e7c5c677e05e4d054b40db7656cfa7fca8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01 10:07:08 -08:00
Shawn O. Pearce 67b064fc9f PackWriter: Do not delta compress already packed objects
This is a tiny optimization to how delta search works.  Checking for
isReuseAsIs() avoids doing delta compression search on non-delta
objects already stored in packs within the repository.  Such objects
are not likely to be delta compressable, as they were already delta
searched when their containing pack was generated and they were
not delta compressed at that time.  Doing delta compression now is
unlikely to produce a different result, but would waste a lot of CPU.

The isReuseAsIs() flag is checked before isDoNotDelta() because it
is very common to reuse objects in the output pack.  Most objects
get reused, and only a handful have the isDoNotDelta() bit set.
Moving the check earlier allows the loop to more quickly skip
through objects that will never need to be considered.

Change-Id: Ied757363f775058177fc1befb8ace20fe9759bac
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01 10:07:08 -08:00
Shawn O. Pearce bf1b970de1 Paper bag fix BatchingProgressMonitor alarm queue
The alarm queue threads were started with an empty task body, which
meant the thread started and terminated immediately, leaving the
queue itself with no worker.

Change-Id: I2a9b5fe9c2bdff4a5e0f7ec7ad41a54b41a4ddd6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-03-01 10:07:08 -08:00
Chris Aniszczyk 268ccbebe3 Merge "ProgressMonitor: Refactor to use background alarms" 2011-03-01 12:05:59 -05:00
Chris Aniszczyk da4fe45356 Merge "Show notes in Log CLI command - Part 2" 2011-03-01 11:13:00 -05:00
Sasa Zivkov 3e1a5081d6 Show notes in Log CLI command - Part 2
This change fixes issues identified in the commit
5f3d577e5a.

Change-Id: Idbd935f5f60ad043faa0d4982b3e101ef7c07d60
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
2011-03-01 09:29:35 +01:00
Shawn O. Pearce 68ab451d39 ProgressMonitor: Refactor to use background alarms
Instead of polling the system clock on every update(1) method call,
use a scheduled executor to toggle a volatile once per second until
the task is done.  Check the volatile on each update(int), looking
to see if output should occur.

This limits progress output to either once per 1% complete, or once
per second.  To save time during update calls the timer isn't reset
during each 1% of output, which means we may see one unnecessary
output trigger if at least 1% completed during the one second of the
alarm time.

Change-Id: I8fdd7e31c37bef39a5d1b3da7105da0ef879eb84
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-28 19:36:56 -08:00
Matthias Sohn ab949602ce Adapt to Jetty 7.3 API change coming with Indigo
Indigo comes with Jetty 7.3 bringing some API changes. This still
works with Jetty 7.1.6 shipped with Helios.

Change-Id: If4f9d6ef6b45c94f8bb097f8b02c10317b47547b
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-01 02:04:07 +01:00
Matthias Sohn 2fba1e65e1 Fix NPE on checkout of remote tracking branch
Checkout of remote tracking branch failed when no local branch
existed. Also enhance RepositoryTestCase to enable checking index
state of another test repository.

Bug: 337695
Change-Id: Idf4c05bdf23b5161688818342b2bf9a45b49f479
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-03-01 00:21:14 +01:00
Shawn O. Pearce bda1e8fab9 Merge branch 'stable-0.11'
* stable-0.11:
  JGit 0.11.3
  Fix NullPointer when pulling from a deleted local branch
  smart-http: Fix recognition of gzip encoding
  Fix processing of broken symbolic references in RefDirectory
  CreateBranchCommand: Wrong existence check
  Qualify post 0.11.1 builds

Conflicts:
	org.eclipse.jgit.console/META-INF/MANIFEST.MF
	org.eclipse.jgit.console/pom.xml
	org.eclipse.jgit.http.server/META-INF/MANIFEST.MF
	org.eclipse.jgit.http.server/pom.xml
	org.eclipse.jgit.http.test/META-INF/MANIFEST.MF
	org.eclipse.jgit.http.test/pom.xml
	org.eclipse.jgit.iplog/META-INF/MANIFEST.MF
	org.eclipse.jgit.iplog/pom.xml
	org.eclipse.jgit.junit.http/META-INF/MANIFEST.MF
	org.eclipse.jgit.junit.http/pom.xml
	org.eclipse.jgit.junit/META-INF/MANIFEST.MF
	org.eclipse.jgit.junit/pom.xml
	org.eclipse.jgit.packaging/org.eclipse.jgit.feature/feature.xml
	org.eclipse.jgit.packaging/org.eclipse.jgit.feature/pom.xml
	org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/feature.xml
	org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/pom.xml
	org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/feature.xml
	org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/pom.xml
	org.eclipse.jgit.packaging/org.eclipse.jgit.updatesite/pom.xml
	org.eclipse.jgit.packaging/pom.xml
	org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
	org.eclipse.jgit.pgm/pom.xml
	org.eclipse.jgit.test/META-INF/MANIFEST.MF
	org.eclipse.jgit.test/pom.xml
	org.eclipse.jgit.ui/META-INF/MANIFEST.MF
	org.eclipse.jgit.ui/pom.xml
	org.eclipse.jgit/META-INF/MANIFEST.MF
	org.eclipse.jgit/META-INF/SOURCE-MANIFEST.MF
	org.eclipse.jgit/pom.xml
	pom.xml

Change-Id: I08067c028666f194687943a574512f5bc5ca9552
2011-02-25 17:24:55 -08:00
Shawn O. Pearce 03f78fc3bc UnpackedObject: Fix readSome() when initial read is short
JDK7 changed behavior slightly on some InputStream types, resulting in
the first read being shorter than the count requested.  That caused us
to overwrite the earlier part of the buffer with later data, as the
offset index wasn't updated in the loop.

Fix the loop to increment offset by the number of bytes read in this
iteration, so the next read appends to the buffer rather than doing an
overwrite.

Bug: 338119
Change-Id: I222fb2f993cd9b637b6b8d93daab5777ef7ec7a6
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-25 17:20:14 -08:00
Robin Rosenberg ba77150040 Use generics in RepositoryFilter constructor
Change-Id: I461786baffab15515365ead1d9c350a1880443ea
2011-02-25 23:12:05 +01:00
Chris Aniszczyk 7e1f18c079 Merge "RevWalk: Don't release during inMergeBase()" 2011-02-24 11:23:47 -05:00
Shawn Pearce 2c9a192505 Merge "Fix formatting of pom.xml" 2011-02-24 10:29:47 -05:00
Matthias Sohn e0a8398f1f FetchCommand: do not set a null credentials provider
FetchCommand now does not set a null credentials provider on
Transport because in this case the default provider is replaced with
null and the default mechanism for providing credentials is not
working.

Change-Id: I44096aa856f031545df39d4b09af198caa2c21f6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-24 16:05:05 +01:00
Matthias Sohn 8d000bd578 Fix formatting of pom.xml
Change-Id: I508def09cb2d4e5bd27b412f4ad5d43984388749
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-24 16:04:33 +01:00
Shawn O. Pearce e757975fcd RevWalk: Don't release during inMergeBase()
In bc1af8459e ("RevWalk: Don't reset ObjectReader when stopping") we
stopped releasing the reader when the current log traversal is over.
This should have also been applied to the merge base logic that is
buried within MergeGenerator, but got missed.

Change-Id: I8328f43f02cba06fd545e22134872e781b9d4d36
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-24 06:55:25 -08:00
Shawn Pearce 2902c7679b Merge "Respect core.excludesfile to enable global ignore rules " 2011-02-23 18:08:50 -05:00
Matthias Sohn e703b6c640 Respect core.excludesfile to enable global ignore rules
Also use FS.resolve() to properly resolve files from path strings.

Bug: 328428 (partial fix)
Change-Id: I41d94694f220dcb85605c9acadfffb1fa23beaeb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-23 23:44:50 +01:00
Shawn O. Pearce 7505b93546 PackWriter: Add missing timers to Statistics
We did not record the time spent on the object reuse search or the
object size lookup, both of which occur between the counting phase and
the compressing phase.  If there are enough objects involved, these
times can be significant so its worth timing them and recording it.

Change-Id: I89084acfc598bb6533d75d90cb8de459f0ed93be
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-23 11:56:19 -08:00
Sasa Zivkov 5f3d577e5a Show notes in Log CLI command
Support for --no-standard-notes and --show-notes=REF options is added
to the Log command. The --show-notes option can be specified more than
once if more than one notes branch should be used for showing notes.

The notes are displayed from note branches in the order how the note
branches are specified in the command line. However, the standard note,
from the refs/notes/commits, is always displayed as first unless
the --no-standard-notes options is given.

Change-Id: I4e7940804ed9d388b625b8e8a8e25bfcf5ee15a6
Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
2011-02-23 09:32:23 -06:00
Shawn O. Pearce 977446e5da PackWriter: Fix total delta count
The total delta count is supposed to include reused deltas, not
just newly created deltas.

Change-Id: I98cbdcef80d59714a4f62ff322e7b709b08b6d26
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-22 17:00:05 -08:00
Shawn O. Pearce 561549d766 Merge "Create empty GIT_DIR/hooks directory" 2011-02-22 10:46:09 -05:00
Shawn Pearce 5bf3df5e1d Merge "Fix potential NullPointerException in PlotCommit" 2011-02-22 10:45:51 -05:00
Shawn O. Pearce 6444e60d0e Create empty GIT_DIR/hooks directory
Bug: 337801
Change-Id: I5e0c4d838a211509fb4cc7e048dba6efaec15d5c
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-22 07:38:51 -08:00
Mathias Kinzler 9953e2a39e Fix potential NullPointerException in PlotCommit
Change-Id: Ib7f661a259561251e74337fa233036e041c42423
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
2011-02-22 09:11:42 +01:00
Matthias Sohn 989149736a JGit 0.11.3
Change-Id: I0a3d4d4400e7643c43d64bf60e566d533b5dcee1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-21 00:59:47 +01:00
Stefan Lay 68064ed339 Fix NullPointer when pulling from a deleted local branch
A checked Exception is thrown instead.

The reason for throwing an Exception is that the state of the
repository is inconsistent in this case: There is a merge
configuration containing a non-existing local branch. Ideally the
deletion of a local branch should also delete the corresponding
merge configuration.

Bug: 337315
Change-Id: I8ed57d5aaed60aaab685fc11a8695e474e60215f
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-21 00:54:02 +01:00
Shawn O. Pearce bd1c1156a0 smart-http: Fix recognition of gzip encoding
Some clients coming through proxies may advertise a different
Accept-Encoding, for example "Accept-Encoding: gzip(proxy)".
Matching by substring causes us to identify this as a false positive;
that the client understands gzip encoding and will inflate the
response before reading it.

In this particular case however it doesn't.  Its the reverse proxy
server in front of JGit letting us know the proxy<->JGit link can
be gzip compressed, while the client<->proxy part of the link is not:

  client <-- no gzip --> proxy <-- gzip --> JGit

Use a more standard method of parsing by splitting the value into
tokens, and only using gzip if one of the tokens is exactly the
string "gzip".  Add a unit test to make sure this isn't broken in
the future.

Change-Id: Ib4c40f9db177322c7a2640808a6c10b3c4a73819
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-21 00:51:11 +01:00
Marc Strapetz 57d13c047f Fix processing of broken symbolic references in RefDirectory
Change-Id: Ic1ceb9c99dca2c69e61ea0ef03ec64f13714b80a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-21 00:48:48 +01:00
Mathias Kinzler c893b1f75f CreateBranchCommand: Wrong existence check
Bug: 337044
Change-Id: I89224719712c1f1ab80ea34280139dfeb00be3d0
Signed-off-by: Mathias Kinzler <mathias.kinzler@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-21 00:44:31 +01:00
Matthias Sohn 5998e474c4 Qualify post 0.11.1 builds
Change-Id: I48cca12fcc6212fbe6c42109e44e4a2dc20ecada
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2011-02-21 00:42:57 +01:00
Shawn O. Pearce 8f865bfffe PackWriter: Hoist and cluster reference targets
Many source browsers and network related tools like UploadPack need
to find and parse the target of all branches and annotated tags
within the repository during their startup phase.  Clustering these
together into the same part of the pack file will improve locality,
reducing thrashing when an application starts and needs to load
all of these into memory at once.

To prevent bottlenecking basic log viewing tools that are scannning
backwards from the tip of a current branch (and don't need tags)
we place this cluster of older targets after 4096 newer commits
have already been placed into the pack stream.  4096 was chosen as
a rough guess, but was based on a few factors:

  - log viewers typically show 5-200 commits per page
  - users only view the first page or two

  - DHT can cram 2200-4000 commits per 1 MiB chunk
    thus these will fall into the second commit chunk (roughly)

Unfortunately this placement hurts history tools that are scanning
backwards through the commit graph and completely ignored tags or
branch heads when they started.

An ancient tagged commit is no longer positioned behind its first
child (its now much earlier), resulting in a page fault for the
parser to reload this cluster of objects on demand.  This may be
an acceptable loss.  If a user is walking backwards and has already
scanned through more than 4096 commits of history, waiting for the
region to reload isn't really that bad compared to the amount of
time already spent.

If the repository is so small that there are less than 4096 commits,
this change has no impact on the placement of objects.

Change-Id: If3052e430d305e17878d94145c93754f56b74c61
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-18 18:15:26 -08:00
Shawn O. Pearce 19037e8cfc PackWriter: Parse tag target objects in a batch
If the underlying storage has a high latency per SHA-1 lookup
(e.g. the DHT support we are working on), parsing each wanted
annotated tag object back to its underlying commit is too slow,
its a sequential lookup for each tag.  With hundreds of tags in
a repository this takes far too long.

Instead queue up a list of the tags whose objects need to be found,
and then locate all of those in one parseAny batch.  This works
for the common case of annotated tag to single tree or commit.
For the less often used tag->tag->commit, it at least gets us
one level parsed in the larger batch before we have to go back to
sequential lookups.

Change-Id: I94beef3f14281406f15c8cf9fa02d83faf102a19
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2011-02-18 18:15:25 -08:00