Fix detection of "initial checkout"
A checkout done directly after cloning (the "initial checkout") has a different semantic as a default checkout. That is defined in the documentation of "git read-tree" [1]. JGit was detecting that it is doing an initial checkout differently from native git: jgit used to check that the index is empty but native git required that the index file does not exist [2]. Teach JGit to behave like native git. [1] https://github.com/git/git/blob/master/Documentation/git-read-tree.txt#L187 [2] https://marc.info/?t=154150811200001&r=1&w=2 Change-Id: I1dd0f1ede7cd7ea60d28607916d0165269a9f628
This commit is contained in:
parent
1168ab0f37
commit
530812d936
|
@ -157,7 +157,7 @@ public CheckoutMetadata(EolStreamType eolStreamType,
|
||||||
|
|
||||||
private ArrayList<String> toBeDeleted = new ArrayList<>();
|
private ArrayList<String> toBeDeleted = new ArrayList<>();
|
||||||
|
|
||||||
private boolean emptyDirCache;
|
private boolean initialCheckout;
|
||||||
|
|
||||||
private boolean performingCheckout;
|
private boolean performingCheckout;
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ public DirCacheCheckout(Repository repo, ObjectId headCommitTree, DirCache dc,
|
||||||
this.headCommitTree = headCommitTree;
|
this.headCommitTree = headCommitTree;
|
||||||
this.mergeCommitTree = mergeCommitTree;
|
this.mergeCommitTree = mergeCommitTree;
|
||||||
this.workingTree = workingTree;
|
this.workingTree = workingTree;
|
||||||
this.emptyDirCache = (dc == null) || (dc.getEntryCount() == 0);
|
this.initialCheckout = !repo.isBare() && !repo.getIndexFile().exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -961,7 +961,7 @@ else if (m == null)
|
||||||
// called before). Ignore the cached deletion and use what we
|
// called before). Ignore the cached deletion and use what we
|
||||||
// find in Merge. Potentially updates the file.
|
// find in Merge. Potentially updates the file.
|
||||||
if (equalIdAndMode(hId, hMode, mId, mMode)) {
|
if (equalIdAndMode(hId, hMode, mId, mMode)) {
|
||||||
if (emptyDirCache)
|
if (initialCheckout)
|
||||||
update(name, mId, mMode);
|
update(name, mId, mMode);
|
||||||
else
|
else
|
||||||
keep(dce);
|
keep(dce);
|
||||||
|
|
Loading…
Reference in New Issue