mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-22 19:43:51 -05:00
Skip pulling tags in shallow clone. Currently seg faults
When fetching, verify tag commits aren't ghost commits
This commit is contained in:
+22
-5
@@ -357,8 +357,17 @@ func FetchFollowTags(ctx context.Context, tempTableDir string, srcDB, destDB *do
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
if !has {
|
||||
// neither tag nor commit has been fetched
|
||||
if has {
|
||||
// We _might_ have it. We need to check if it's a ghost, in which case we'll skip this commit.
|
||||
optCmt, err := destDB.ReadCommit(ctx, cmHash)
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
_, ok := optCmt.ToCommit()
|
||||
if !ok {
|
||||
return false, nil
|
||||
}
|
||||
} else {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -545,6 +554,8 @@ func fetchRefSpecsWithDepth(
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
shallowClone := depth > 0
|
||||
ghostsPersisted := false
|
||||
// We loop on fetching chunks until we've fetched all the new heads we need, or we've reached the depth limit.
|
||||
// In the case where we pull everything (depth < 0), we'll only loop once.
|
||||
@@ -642,9 +653,15 @@ func fetchRefSpecsWithDepth(
|
||||
}
|
||||
}
|
||||
|
||||
err = FetchFollowTags(ctx, tmpDir, srcDB, dbData.Ddb, progStarter, progStopper)
|
||||
if err != nil {
|
||||
return err
|
||||
if !shallowClone {
|
||||
// TODO: Currently shallow clones don't pull any tags, but they could. We need to make FetchFollowTags wise
|
||||
// to the skipped commits list, and then we can remove this conditional. Also, FetchFollowTags assumes that
|
||||
// progStarter and progStopper are always non-nil, which we don't assume elsewhere. Shallow clone has no
|
||||
// progress reporting, and as a result they are nil.
|
||||
err = FetchFollowTags(ctx, tmpDir, srcDB, dbData.Ddb, progStarter, progStopper)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -40,6 +40,8 @@ seed_and_start_serial_remote() {
|
||||
dolt commit -a -m "Added Val: $SEQ"
|
||||
done
|
||||
|
||||
dolt tag nonheadtag HEAD~2
|
||||
|
||||
remotesrv --http-port 1234 --repo-mode &
|
||||
remotesrv_pid=$!
|
||||
|
||||
@@ -117,6 +119,23 @@ seed_and_start_serial_remote() {
|
||||
[[ "$output" =~ "15" ]] || false # 1+2+3+4+5 = 15.
|
||||
}
|
||||
|
||||
@test "shallow-clone: push to a new remote should error" {
|
||||
seed_and_start_serial_remote
|
||||
|
||||
mkdir clones
|
||||
cd clones
|
||||
|
||||
dolt clone --depth 1 http://localhost:50051/test-org/test-repo
|
||||
cd test-repo
|
||||
|
||||
dolt remote add altremote file://../file-remote-alt
|
||||
|
||||
run dolt push altremote main
|
||||
[ "$status" -eq 1 ]
|
||||
# NM4 - give a better error message.
|
||||
[[ "$output" =~ "failed to get all chunks" ]] || false
|
||||
}
|
||||
|
||||
@test "shallow-clone: depth 3 clone of serial history" {
|
||||
seed_and_start_serial_remote
|
||||
|
||||
|
||||
Reference in New Issue
Block a user