diff --git a/internal/cli/banger.go b/internal/cli/banger.go index cb595b6..56e850d 100644 --- a/internal/cli/banger.go +++ b/internal/cli/banger.go @@ -1589,7 +1589,7 @@ func importVMRunRepoToGuest(ctx context.Context, client vmRunGuestClient, spec v return formatVMRunStepError("prepare guest checkout", err, scriptLog.String()) } var overlayLog bytes.Buffer - remoteCommand := fmt.Sprintf("tar -C %s --strip-components=1 -xf -", shellQuote(vmRunGuestDir(spec.RepoName))) + remoteCommand := fmt.Sprintf("tar -o -C %s --strip-components=1 -xf -", shellQuote(vmRunGuestDir(spec.RepoName))) if err := client.StreamTarEntries(ctx, spec.RepoRoot, spec.OverlayPaths, remoteCommand, &overlayLog); err != nil { return formatVMRunStepError("overlay host working tree", err, overlayLog.String()) } @@ -1640,6 +1640,7 @@ func vmRunCloneScript(spec vmRunRepoSpec) string { fmt.Fprintf(&script, "git -C \"$DIR\" checkout --detach %s\n", shellQuote(spec.HeadCommit)) } script.WriteString("find \"$DIR\" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +\n") + script.WriteString("git config --global --add safe.directory \"$DIR\"\n") return script.String() } diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index 5083811..95e77ad 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -1121,13 +1121,16 @@ func TestRunVMRunCreatesImportsAndAttaches(t *testing.T) { if !strings.Contains(fakeClient.script, `git -C "$DIR" checkout -B 'feature' 'cafebabe'`) { t.Fatalf("script = %q, want guest branch checkout", fakeClient.script) } + if !strings.Contains(fakeClient.script, `git config --global --add safe.directory "$DIR"`) { + t.Fatalf("script = %q, want guest safe.directory config", fakeClient.script) + } if fakeClient.streamSourceDir != repoRoot { t.Fatalf("streamSourceDir = %q, want %q", fakeClient.streamSourceDir, repoRoot) } if !reflect.DeepEqual(fakeClient.streamEntries, spec.OverlayPaths) { t.Fatalf("streamEntries = %v, want %v", fakeClient.streamEntries, spec.OverlayPaths) } - if fakeClient.streamCommand != "tar -C '/root/repo' --strip-components=1 -xf -" { + if fakeClient.streamCommand != "tar -o -C '/root/repo' --strip-components=1 -xf -" { t.Fatalf("streamCommand = %q", fakeClient.streamCommand) } wantAttach := []string{"attach", "--dir", "/root/repo", "http://172.16.0.2:4096"}