Skip to content

Commit 3d92ccb

Browse files
committed
vcs.rb: Export working directory without cloning
Simply checkout the files from the source directory.
1 parent b2a00cc commit 3d92ccb

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tool/lib/vcs.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ def parse_iso_date(date)
213213
end
214214

215215
def after_export(dir)
216-
FileUtils.rm_rf(Dir.glob("#{dir}/.git*"))
217-
FileUtils.rm_rf(Dir.glob("#{dir}/.mailmap"))
216+
# Files to be removed should be excluded at checkout.
218217
end
219218

220219
def revision_handler(rev)
@@ -463,7 +462,11 @@ def grep(pat, tag, *files, &block)
463462
end
464463

465464
def export(revision, url, dir, keep_temp = false)
466-
system(COMMAND, "clone", "-c", "advice.detachedHead=false", "-s", (@srcdir || '.').to_s, "-b", url, dir) or return
465+
git_dir = cmd_read([COMMAND, "rev-parse", "--absolute-git-dir"])
466+
git_dir&.chomp!
467+
FileUtils.mkpath(dir)
468+
excludes = %w":^/.git* :^/.mailmap*"
469+
system(COMMAND, "--git-dir=#{git_dir}", "checkout", url, "--", *excludes, chdir: dir) or return
467470
GIT.new(File.expand_path(dir))
468471
end
469472

0 commit comments

Comments
 (0)