Commit Graph

4071 Commits

Author SHA1 Message Date
Christian Halstrick 69cd6f5864 Introduce FS.execute() to execute a command defined by a ProcessBuilder
Change-Id: I2ad2c71ad30b969455bdea89637b8e996b1dad8c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-18 00:28:45 +01:00
Christian Halstrick 6389948a81 Add an attribute accessor to CanonicalTreeParser and use it in Treewalk
When checking out a branch we need to access the attributes stored
in the tree to be checked out. E.g. directly after a clone we checkout
the remote HEAD. In this case index and workingtree are still empty.
So we have to search the tree to be checked out for attributes.

Change-Id: I6d96f5d095ed2e3c259d4b12124e404f5215bd9f
2015-11-18 00:28:45 +01:00
Arthur Daussy 12280c02db Adds the git attributes computation on the treewalk
Adds the getAttributes feature to the tree walk. The computation of
attributes needs to be done by the TreeWalk since it needs both a
WorkingTreeIterator and a DirCacheIterator.

Bug: 342372
CQ: 9120
Change-Id: I5e33257fd8c9895869a128bad3fd1e720409d361
Signed-off-by: Arthur Daussy <arthur.daussy@obeo.fr>
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
2015-11-18 00:28:45 +01:00
Andrey Loskutov 2f6959d9f3 Make jgit annotations accessible to other plugins
Other plugins which want to use JGit nullness annotations in their code
cannot do this if the annotations aren't part of the published API.

Unfortunately it looks like although Eclipse JDT allows to use custom
nullness annotation types per project, it does not understand if those
annotations are used mixed with other nullness annotations in other
projects. E.g. EGit can either configure JGit annotations for NPE
analysis and so "understand" nullness from JGit API but so it loses the
ability to use any other nullness annotations to annotate its own code.

Change-Id: Ieeeb578c2fe35223a7561d668dce8e767dc89ef0
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2015-11-17 12:50:01 -05:00
Andrey Loskutov 864d3899ad Fixed typo in preferences: NonByDefault -> NonNullByDefault
Change-Id: I6ef5fbdb57e7cba010ad23cb3f6af02891e7fe78
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2015-11-17 18:23:59 +01:00
Andrey Loskutov f1405a337a Added jgit own NonNull annotation type
The annotation is required for example in Repository case (patch
follows), where almost all non-void return methods return Nullable
except few returning NonNull. I definitely do not favor this style, but
it is a nightmare to clients to guess if the null check is needed or
not.

Change-Id: Ib2a778a246c6d84b7c32565f54df2385b59f6498
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
2015-11-17 18:23:59 +01:00
Christian Halstrick d45ee99546 Merge "Fix MissingObjectException in RenameDetector" 2015-11-17 03:27:55 -05:00
Matthias Sohn 4acff5a59e Handle InternalError during symlink support detection on Windows
When JGit tries to detect symlink support the attempt to create a
symlink may fail with a java.lang.InternalError. This was reported for a
case where the application using JGit runs in Windows XP compatibility
mode using Oracle JDK 1.8. Handle this by assuming symlinks are not
supported in this case.

Bug: 471027
Change-Id: I978288754dea0c6fffd3457fad7d4d971e27c6c2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-15 22:56:55 +01:00
Matthias Sohn 070bf8d15f Merge branch 'stable-4.1'
* stable-4.1:
  Prepare 4.1.2-SNAPSHOT builds
  JGit v4.1.1.201511131810-r
  Fallback exactRef: Do not ignore symrefs to unborn branch
  RefDirectory.exactRef: Do not ignore symrefs to unborn branch

Change-Id: I66afb303f355aad8a7eaa7a6dff06de70ae9c490
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-14 00:59:36 +01:00
Matthias Sohn 3e2aff196e Prepare 4.1.2-SNAPSHOT builds
Change-Id: I1d1c4d918f2260c866c4392c1abea1e40a1de962
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-14 00:53:45 +01:00
Matthias Sohn 3cb5f11398 JGit v4.1.1.201511131810-r
Change-Id: If0246daab39fa279c30874549b198e7aa917bc62
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-14 00:09:54 +01:00
Jonathan Nieder 7dcb50a04a Fallback exactRef: Do not ignore symrefs to unborn branch
When asked to read a symref pointing to a branch-yet-to-be-born (such
as HEAD in a newly initialized repository), getRef and getRefs provide
different results.

	getRef: SymbolicRef[HEAD -> refs/heads/master=00000000]
	getRefs and getAdditionalRefs: nothing

exactRef should match the getRef behavior: it is meant to be a
simpler, faster version of getRef that lets you search for a ref
without resolving it using the search path without other semantic
changes.  But the fallback implementation of exactRef relies on getRefs
and produces null for this case.

Luckily the in-tree RefDatabase implementations override exactRef and
get the correct behavior.  But any out-of-tree storage backend that
doesn't inherit from DfsRefDatabase or RefDirectory would still return
null when it shouldn't.

Let the fallback implementation use getRef instead to avoid this.
This means that exactRef would waste some effort traversing the ref
search path when the named ref is not found --- but subclasses tend to
override exactRef for performance already, so in the default
implementation correctness is more important.

Bug: 478865
Change-Id: I60f04e3ce3bf4731640ffd2433d329e621330029
2015-11-12 14:59:51 -05:00
Rüdiger Herrmann e18444de30 Fix MissingObjectException in RenameDetector
When attempting to determine the size of a blob that does not exist,
the RenameDetector throws a MissingObjectException.

The fix is to return a size of zero if the size is requested for a blob
id that doesn't exist.

Bug: 481577
Change-Id: I4e86276039c630617610cc51d0eefa56d7d3952f
Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
2015-11-12 15:56:36 +01:00
Matthias Sohn 2645140678 Merge "Merge branch 'stable-4.2'" 2015-11-12 05:38:04 -05:00
Matthias Sohn ca74150cb0 Merge branch 'stable-4.2'
* stable-4.2:
  Prepare post 4.2-m1 builds
  JGit v4.2.0.201511101648-m1

Change-Id: Idef8f81a82e2625e4b46141fae74975227f3ab7d
2015-11-12 08:53:11 +01:00
Jonathan Nieder 797f94d331 RefDirectory.exactRef: Do not ignore symrefs to unborn branch
When asked to read a symref pointing to a branch-yet-to-be-born (such
as HEAD in a newly initialized repository), DfsRepository and
FileRepository return different results.

FileRepository:

	exactRef("HEAD") => null

DfsRepository:

	exactRef("HEAD") => SymbolicRef[HEAD -> refs/heads/master=00000000]

getRef("HEAD") returns the same as DfsRepository's exactRef in both
backends.

The intended behavior is the DfsRepository one: exactRef() is supposed
to be like getRef(), but more exact because it doesn't need to
traverse the search path.

The discrepancy is because DfsRefDatabase implements exactRef()
directly with the intended semantics, while RefDirectory uses a
fallback implementation built on top of getRefs().  getRefs() skips
symrefs to an unborn branch.

Override the fallback implementation with a correct implementation
that is similar to getRef() to avoid this.  A followup change will fix
the fallback.

Change-Id: Ic138a5564a099ebf32248d86b93e2de9ab3c94ee
Reported-by: David Pursehouse <david.pursehouse@sonymobile.com>
Improved-by: Christian Halstrick <christian.halstrick@sap.com>
Bug: 478865
2015-11-11 10:56:39 -08:00
Jonathan Nieder 61efddf761 Merge "Revert "Remove PackWriter.Statistics and other deprecated classes"" 2015-11-10 20:20:45 -05:00
Jonathan Nieder 1fa6f3a750 Revert "Remove PackWriter.Statistics and other deprecated classes"
This reverts commit bbcbcab8d3.
These classes were part of the public API and should not be removed
until JGit 5.0.

Change-Id: Ife4bee69f82151de6ef8ea1a4c6c146d91bbf0d5
2015-11-10 20:14:01 -05:00
Matthias Sohn 35109dc66c Prepare post 4.2-m1 builds
Change-Id: I20e5eadc243ea375948ceca8c99441605c45ad95
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-11 00:31:45 +01:00
Matthias Sohn 3a93c8bdca JGit v4.2.0.201511101648-m1
Change-Id: I659e9e95a96797f78f23669cfc5946c6b2d9c088
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-10 22:48:00 +01:00
Jonathan Nieder 3eb272edac Merge "Remove PackWriter.Statistics and other deprecated classes" 2015-11-10 15:57:29 -05:00
Terry Parker bbcbcab8d3 Remove PackWriter.Statistics and other deprecated classes
These classes make improper use of internal classes in the public API
and were replaced by corresponding classes in the JGit 4.1 release.

Change-Id: I3d474210e49089aa788314b4e08f505f0d26619b
Signed-off-by: Terry Parker <tparker@google.com>
2015-11-09 18:55:18 -08:00
Matthias Sohn a74ff164e4 Silence API errors for new methods added to BitmapBuilder
These API changes were introduced in f523f21e and 73474466.

BitmapBuilder is an interface to be implemented by implementors of this
interface. According to OSGi semantic versioning rules breaking API
changes require update of the minor version only if implementors of the
API have to be adapted and the changes do not affect clients of the API.

Change-Id: If45d204181ea9bc788b6b57693ca17b1847564c7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-10 00:59:40 +01:00
Matthias Sohn b37d77997c Add missing javadoc to bitmap index classes
Change-Id: Ib9fd230c9465a719df53cfcb314d8b5015743928
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-10 00:50:55 +01:00
Jonathan Nieder deb853cb69 Merge changes from topic 'nullable'
* changes:
  Update dependencies to use the JGit-internal @Nullable
  Use the JGit-internal @Nullable annotation
  Add a JGit-internal Nullable type
2015-11-09 18:04:22 -05:00
Jonathan Nieder 86af34e150 Make BitmapIndexImpl.CompressedBitmap public
PackWriterBitmapPreparer (which is in another package) is already well
aware of the mapping between EWAHCompressedBitmaps and the
higher-level CompressedBitmap objects of the BitmapIndexImpl API.
Making the CompressedBitmap type public makes the translation more
obvious and wouldn't break any abstractions that aren't already
broken.  So expose it.

This is all under org.eclipse.jgit.internal so there are no API
stability guarantees --- we can change the API if internals change
(for example if some day there are bitmaps spanning multiple packs).

In particular this means the confusing toBitmap helper can be removed.

Change-Id: Ifb2e8804a6d5ee46e82a76d276c4f8507eaa2a4c
2015-11-09 17:40:05 -05:00
Terry Parker ca3ea18371 Update dependencies to use the JGit-internal @Nullable
Update the project-specific Eclipse settings to replace the use of the
org.eclipse.jdt.annotation.Nullable class the new JGit-specific
@Nullable annotation. I verified that Eclipse reports errors when the
return value of a method annotated with
@org.eclipse.jgit.annotations.Nullable is dereferenced without a null
check.

Also remove the Maven and MANIFEST.MF dependencies on
org.eclipse.jdt.annotation.

Eclipse null analysis uses three annotations: @Nullable, @NonNull and
@NonNullByDefault. All three are updated in this patch because it is
invalid to set the Eclipse preferences to empty values. So far only
@Nullable has been introduced in org.eclipse.jgit.annotations.

My personal preference is to follow the advice in Effective Java and
avoid the null-return idiom, and to avoid passing null values in
general. This sets the expectation is that arguments and return types
are assumed non-null unless otherwise documented. If that is the
expectation, then consistent application of @NonNull is redundant and
hurts readability by cluttering the code, obscuring the occasional
@Nullable annotation that really requires attention.

If the JGit community decides there is value in using the @NonNull and
@NonNullByDefault annotations we can add them--this change configures
Eclipse to use them.

Change-Id: I9af1b786d1b44b9b0d9c609480dc842df79bf698
Signed-off-by: Terry Parker <tparker@google.com>
2015-11-09 14:27:52 -08:00
Terry Parker 6ddb8e703b Use the JGit-internal @Nullable annotation
Update existing @Nullable uses to use the JGit-internal version of the
annotation. 

Change-Id: I95234ffad4c3110f9597fbd3a2760f653e22ecf7
Signed-off-by: Terry Parker <tparker@google.com>
2015-11-09 14:27:52 -08:00
Terry Parker 3a3bb2ce29 Add a JGit-internal Nullable type
Commit 847b3d1 enabled annotation-based NPE analysis to JGit.

In so doing, it introduced a new dependency on the org.eclipse.jdt that
is undesirable. Follow Gerrit's lead by adding an internal Nullable type
(see
https://gerrit.googlesource.com/gerrit/+/stable-2.11/gerrit-common/src/main/java/com/google/gerrit/common/Nullable.java).

The javax.annotations.Nullable class uses a retention policy of RUNTIME,
whereas the org.eclipse.jdt.annotation.Nullable class used a policy of
CLASS. Since I'm not aware of tools that make use of the annotation at
runtime I chose the CLASS policy. If in the future there is a benefit to
retaining the annotations in the running binary we can update this
class.

Change-Id: I63dc8f9a6dc46b517cbde211bb5e2f8521a54d04
Signed-off-by: Terry Parker <tparker@google.com>
2015-11-09 14:27:47 -08:00
Jonathan Nieder 683bd09092 Make BitmapIndexImpl.CompressedBitmap, CompressedBitmapBuilder static
A CompressedBitmap represents a pair (EWAH bit vector, PackIndex
assigning bit positions to git objects).  The bit vector is a member
field and the PackIndex is implicit via the 'this' reference to the
outer class.

Make this clearer by making CompressedBitmap a static class and
replacing the 'this' reference by an explicit field.

Likewise for CompressedBitmapBuilder.

Change-Id: Id85659fc4fc3ad82034db3370cce4cdbe0c5492c
Suggested-by: Terry Parker <tparker@google.com>
2015-11-09 13:32:04 -08:00
Jonathan Nieder 087b5051ff Skip redundant 'OR-reuse' step in tip commit bitmap setup
When creating bitmaps during gc, the bitmaps in tipCommitBitmaps are
built in setupTipCommitBitmaps using the following procedure:

 0. create a bitmap ('reuse') that lists all ancestors of commits
    whose existing bitmaps will be reused.  I will call this the
    reused part of history.

 1. initialize a bitmap for each of the pack's "want"s by taking
    a copy of the 'reuse' bitmap and setting the bit corresponding
    to the one wanted commit.

 2. walk through ancestors of wants, excluding the reused part of
    history.  Add parents of visited commits to bitmaps that have
    those commits.

 3. AND-NOT each tipCommitBitmap against the 'reuse' bitmap

 4. Sort the bitmaps and AND-NOT each against the previous so they
    partition the new commits.

The OR against 'reuse' in step 1 and the AND-NOT against 'reuse'
cancel each other out, except when commits from the reused part of
history are added to a bitmap in step 2.  So avoid adding commits from
the reused part of history in step 2 and skip the OR and AND-NOT.

Performance impact (thanks to Terry for measuring):

The initial "selecting bitmaps" phase of garbage collection decreased
from (83 + 81 + 85) / 3 = 83 to (56 + 57 + 56) / 3 = 56.3, meaning
nearly a ~50% speedup of that phase.

Tested-by: Terry Parker <tparker@google.com>
Change-Id: I26ea695809594347575d14a1d8e6721b8608eb9c
2015-11-08 16:23:37 -08:00
Jonathan Nieder 65e04a2a92 Avoid repeated sort of tipCommitBitmaps
Change-Id: I0feb2003f58776d50fab2d31d46ac98ae863bea8
2015-11-07 15:36:55 -08:00
Terry Parker 6d19f5dc8f [style] Shorten line lengths and import order in bitmap code
Change-Id: I420fcd308a97e30b8c74026d74b93ed3ec74bb3f
Signed-off-by: Terry Parker <tparker@google.com>
2015-11-07 10:32:45 -08:00
Jonathan Nieder e87f0cd866 Inline PackWriterBitmapWalker.newRevFilter into callers
Instead of using the newRevFilter helper, call the appropriate
RevFilter constructor directly.  This means one less hop to find
documentation about what the RevFilter will do.

Change-Id: Ida6ff1c0457a47a1bd1e4ed0fd1dd42a616d214f
2015-11-05 14:51:47 -08:00
Jonathan Nieder af4ee73454 Convert remaining callers of BitmapBuilder.add to use .addObject
When setupTipCommitBitmaps is called, writeBitmaps does not have any
bitmaps saved, so these calls to .add always add a single commit and
do not OR in a bitmap.

The objects returned by nextObject after a commit walk is finished
are trees and blobs.  Non-commit objects do not have bitmaps
associated so the call to .add also can only add a single object.

Change-Id: I7b816145251a7fa4f1fffe0d03644257ea7f5440
2015-11-05 14:51:47 -08:00
Jonathan Nieder 4009713946 Merge changes I57b1d7c1,I590ac460
* changes:
  Use .addObject and .or instead of .add in AddToBitmapFilter
  Replace anonymous BitmapRevFilter subclasses with explicit classes
2015-11-05 17:51:15 -05:00
Matthias Sohn 2d46de03bb Merge "Fix imports in DfsInserterTest" 2015-11-05 17:48:55 -05:00
Jonathan Nieder 10fe4a5405 Merge changes Ia95da478,I2773aa94,Ib745645f,I92c65f34,Ibb714002, ...
* changes:
  Remove BitmapRevFilter.getCountOfLoadedCommits
  Make BitmapBuilder.getBitmapIndex public
  Deprecate BitmapBuilder.add and introduce simpler addObject method
  Add @Override annotations to BitmapIndexImpl
  Rely on bitmap RevFilter to filter walk during bitmap selection
  Use 'reused' bitmap to filter walk during bitmap selection
  Rely on bitmap RevFilter to filter tip commit setup walk
  Use 'reused' bitmap to filter tip commit setup walk
  Include ancestors of reused bitmap commits in reuse bitmap again
2015-11-05 17:08:26 -05:00
Matthias Sohn 7ee184acfa Fix imports in DfsInserterTest
- remove unused import of AnyObjectId
- auto-sort import statements

Change-Id: I1c7cec2734bd58370a7dfae70a6a4ccbe3e304ce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-11-05 22:47:54 +01:00
Jonathan Nieder fd1ee636a2 Use .addObject and .or instead of .add in AddToBitmapFilter
This is the caller that the BitmapBuilder.add method was designed
around.  Moving away from .add makes it more verbose but hopefully
clearer.

Change-Id: I57b1d7c1dc8fb800b242b76c606922b5aa36b9b2
2015-11-05 13:03:22 -08:00
Jonathan Nieder f102abf035 Replace anonymous BitmapRevFilter subclasses with explicit classes
This puts the code for include() in each RevFilter returned by
newRevFilter in one place and should make the code easier to
understand and modify.

Change-Id: I590ac4604b61fc1ffe7aba2ed89f8139847ccac3
2015-11-05 12:42:35 -08:00
Jonathan Nieder 42f0a3d51d Remove BitmapRevFilter.getCountOfLoadedCommits
The count of loaded commits is equal to the number of commits returned
by the walk.  Simplify BitmapRevFilter by counting them in the caller.

Change-Id: Ia95da47831d9e89d6f8068470ec4529aaabfa7dd
2015-11-05 12:40:13 -08:00
Jonathan Nieder 73474466eb Make BitmapBuilder.getBitmapIndex public
Every Bitmap in current JGit code has an associated BitmapIndex.  Make
it public in BitmapBuilder to make retrieving bitmaps to OR in from
that index easier.

Change-Id: I2773aa94d8b67f12194608e6317c0792a5de21e2
2015-11-05 12:39:57 -08:00
Jonathan Nieder f523f21e59 Deprecate BitmapBuilder.add and introduce simpler addObject method
The BitmapIndex.BitmapBuilder.add API is subtle:

	/**
	 * Adds the id and the existing bitmap for the id, if one
	 * exists, to the bitmap.
	 *
	 * @return true if the value was not contained or able to be
	 * loaded.
	 */
	boolean add(AnyObjectId objectId, int type);

Reading the name of the method does not make it obvious what it will
do.  Does it add the named object to the bitmap, or all objects
reachable from it?  It depends on whether the BitmapIndex owns an
existing bitmap for that object.  I did not notice this subtlety when
skimming the javadoc, either.  This resulted in enough confusion to
subtly break the bitmap building code (see change
I30844134bfde0cbabdfaab884c84b9809dd8bdb8 for details).

So discourage use of the add() API by deprecating it.

To replace it, provide a addObject() method that adds a single object.
This way, callers can decide whether to use addObject() or or() based
on the context.

For example,

	if (bitmap.add(c, OBJ_COMMIT)) {
		for (RevCommit p : c.getParents()) {
			rememberToAlsoHandle(p);
		}
	}

can be replaced with

	if (bitmap.contains(c)) {
		// already included
	} else if (index.getBitmap(c) != null) {
		bitmap.or(index.getBitmap(c));
	} else {
		bitmap.addObject(c, OBJ_COMMIT);
		for (RevCommit p : c.getParents()) {
			rememberToAlsoHandle(p);
		}
	}

which is more verbose but makes it clearer that the behavior
depends on the content of index.getBitmaps().

Change-Id: Ib745645f187e1b1483f8587e99501dfcb7b867a5
2015-11-05 12:29:27 -08:00
Jonathan Nieder 424aa22b56 Add @Override annotations to BitmapIndexImpl
This makes it easier to distinguish between implementations of methods
from the interface from helpers internal to org.eclipse.jgit.internal.storage.*.

This was illegal in Java 5 but JGit requires newer Java these days.

Change-Id: I92c65f3407a334acddd32ec9e09ab7d1d39c4dc6
2015-11-05 12:27:52 -08:00
Jonathan Nieder 0e403a18e6 Rely on bitmap RevFilter to filter walk during bitmap selection
This RevWalk filters out reused bitmap commits via the 'reuse' bitmap.
Avoid possible wasted time and complexity by not also redundantly
marking them UNINTERESTING.

Change-Id: Ibb714002ddac599963d148a9aab90645fcc73141
2015-11-05 12:27:44 -08:00
Jonathan Nieder 2a2c2f3373 Use 'reused' bitmap to filter walk during bitmap selection
When building fullBitmap in order to determine which ancestor chain to
add this commit to, we were excluding the ancestors of reusedCommits
using markUninteresting.  This use of markUninteresting is a bit
wasteful because we already have a bitmap indicating exactly which
commits should be excluded (which can save some walking).  Use it.

A separate commit will remove the now-redundant markUninteresting
call.

No behavior change intended (except for performance improvement).

Change-Id: I1112641852d72aa05c9a8bd08a552c70342ccedb
2015-11-05 12:27:28 -08:00
Jonathan Nieder b28091e450 Rely on bitmap RevFilter to filter tip commit setup walk
This RevWalk filters out reused bitmap commits via the 'reuse' bitmap.
Avoid possible wasted time and complexity by not redundantly marking
them UNINTERESTING any more.

Change-Id: If467ccd1d75e17cf9367b2a0399fca3f9d52adf9
2015-11-05 12:27:21 -08:00
Jonathan Nieder 9d4e5216a6 Use 'reused' bitmap to filter tip commit setup walk
When garbage collecting, we decide to reuse some bitmaps in older
history from the previous pack to save time.  The remainder of commit
selection only involves commits not covered by those bitmaps.

Currently we carry that out in two ways:

1. by building a bitmap representing the already-covered commits,
   for easy containment checks and AND-NOT-ing against
2. by marking the reused bitmap commits as uninteresting in the
   RevWalk that finds new commits

The mechanism in (2) is less efficient than (1): rw.next() will walk
back from reused bitmap commits to check whether the commit it is
about to emit is an ancestor of them, when using the bitmap from (1)
would let us perform the same check with a single contains() call.
Add a RevFilter teaching the RevWalk to perform that same check
directly using the bitmap from (1).

The next time the RevWalk is used, a different RevFilter is installed
so this does not break that.

A later commit will drop the markUninteresting calls.

No functional change intended except a possible speedup.

Change-Id: Ic375210fa69330948be488bf9dbbe4cb0d069ae6
2015-11-05 12:25:32 -08:00
Mike Williams c4d73fb7cc Insert duplicate objects to prevent race during garbage collection.
Prior to this change, DfsInserter would not insert an object into a pack
if it already existed in another pack in the repository, even if that
pack was unreachable. Consider this sequence of events:

- Object FOO is pushed to a repository.
- Subsequent ref changes make FOO UNREACHABLE_GARBAGE.
- FOO is subsequently re-inserted using a DfsInserter, but skipped
  due to existing in UNREACHABLE_GARBAGE.
- The repository is repacked; FOO will not be written into a new pack
  because it is not yet reachable from a reference. If the
  UNREACHABLE_GARBAGE packs are deleted, FOO disappears.
- A reference is updated to reference FOO. This reference is now broken
  as FOO was removed when the repacking process deleted the
  UNREACHABLE_GARBAGE pack that stored the only copy of FOO.

The garbage collector can't safely delete the UNREACHABLE_GARBAGE
pack because FOO might be in the middle of being re-inserted/re-packed.

This change writes a duplicate copy of an object if it only exists in
UNREACHABLE_GARBAGE. This "freshens" the object to give it a chance to
survive long enough to be made reachable through a reference.

Change-Id: I20f2062230f3af3bccd6f21d3b7342f1152a5532
Signed-off-by: Mike Williams <miwilliams@google.com>
2015-11-04 22:25:07 -08:00