diff --git a/ensure.go b/ensure.go index 22d4365..9f0855f 100644 --- a/ensure.go +++ b/ensure.go @@ -103,7 +103,7 @@ func updateSubmodules(ctx context.Context, retry Retry, dst string, enabled bool return nil } policy := retry.Resolved() - if _, err := policy.Run(ctx, dst, remoteEnv(), "submodule", "sync", "--recursive"); err != nil { + if _, err := policy.Run(ctx, dst, remoteEnv(), longPathArgs("submodule", "sync", "--recursive")...); err != nil { if ctxErr := ctx.Err(); ctxErr != nil { return ctxErr } @@ -112,7 +112,7 @@ func updateSubmodules(ctx context.Context, retry Retry, dst string, enabled bool Label: "submodule", Dir: dst, Env: remoteEnv(), - Args: []string{"submodule", "update", "--init", "--recursive", "--depth", "1"}, + Args: longPathArgs("submodule", "update", "--init", "--recursive", "--depth", "1"), }); err != nil { if ctxErr := ctx.Err(); ctxErr != nil { return ctxErr @@ -147,7 +147,7 @@ func fetchRef(ctx context.Context, retry Retry, url, dst, ref string, full bool) return fmt.Errorf("%s: %w", strings.TrimSpace(out), err) } out, err = policy.Run(ctx, "", nil, - "-C", dst, "reset", "--quiet", "--hard", "--no-recurse-submodules", "FETCH_HEAD", + longPathArgs("-C", dst, "reset", "--quiet", "--hard", "--no-recurse-submodules", "FETCH_HEAD")..., ) if err != nil { return fmt.Errorf("%s: %w", strings.TrimSpace(out), err) diff --git a/ensure_test.go b/ensure_test.go index 0863acc..beb3e1d 100644 --- a/ensure_test.go +++ b/ensure_test.go @@ -244,11 +244,11 @@ func TestEnsureWithOptionsIgnoresSubmoduleFailure(t *testing.T) { ); err != nil { t.Fatalf("EnsureWithOptions: %v", err) } - wantSyncArgs := []string{"submodule", "sync", "--recursive"} + wantSyncArgs := []string{"-c", "core.longpaths=true", "submodule", "sync", "--recursive"} if !slices.Equal(syncArgs, wantSyncArgs) { t.Errorf("submodule sync args = %v, want %v", syncArgs, wantSyncArgs) } - wantUpdateArgs := []string{"submodule", "update", "--init", "--recursive", "--depth", "1"} + wantUpdateArgs := []string{"-c", "core.longpaths=true", "submodule", "update", "--init", "--recursive", "--depth", "1"} if !slices.Equal(updateArgs, wantUpdateArgs) { t.Errorf("submodule update args = %v, want %v", updateArgs, wantUpdateArgs) } @@ -379,7 +379,7 @@ func TestEnsureRetriesCloneAndResetsPartialDestination(t *testing.T) { } } -func TestEnsureConfiguresLongPathsForCloneAndFetch(t *testing.T) { +func TestEnsureConfiguresLongPathsForCloneFetchAndReset(t *testing.T) { dst := filepath.Join(t.TempDir(), "checkout") commands := make(map[string][]string) retry := Retry{ @@ -393,7 +393,7 @@ func TestEnsureConfiguresLongPathsForCloneAndFetch(t *testing.T) { if err != nil { t.Fatalf("Ensure: %v", err) } - for _, command := range []string{"clone", "fetch"} { + for _, command := range []string{"clone", "fetch", "reset"} { args := commands[command] want := []string{"-c", "core.longpaths=true"} if len(args) < len(want) || !slices.Equal(args[:len(want)], want) {