@@ -9,21 +9,22 @@ module Diff
99 module Vcs
1010 def self . checkout_vcs ( root , screenshot_path , checkout_path )
1111 root_path = root . to_s
12- git_root , _ , status = Open3 . capture3 ( "git" , "-C" , root_path , "rev-parse" , "--show-toplevel" )
12+ git_env = { "GIT_DIR" => nil , "GIT_WORK_TREE" => nil , "GIT_INDEX_FILE" => nil }
13+ git_root , _ , status = Open3 . capture3 ( git_env , "git" , "-C" , root_path , "rev-parse" , "--show-toplevel" )
1314 return false unless status . success?
1415
1516 git_root = git_root . chomp
1617 vcs_file_path = Pathname . new ( screenshot_path ) . expand_path . relative_path_from ( Pathname . new ( git_root ) ) . to_s
1718
1819 if Screenshot . use_lfs
1920 tmp_path = "#{ checkout_path } .tmp"
20- success = system ( "git" , "-C" , root_path , "show" , "HEAD:#{ vcs_file_path } " , out : tmp_path , err : File ::NULL )
21+ success = system ( git_env , "git" , "-C" , root_path , "show" , "HEAD:#{ vcs_file_path } " , out : tmp_path , err : File ::NULL )
2122 if success
22- system ( "git" , "-C" , root_path , "lfs" , "smudge" , in : tmp_path , out : checkout_path . to_s , err : File ::NULL )
23+ system ( git_env , "git" , "-C" , root_path , "lfs" , "smudge" , in : tmp_path , out : checkout_path . to_s , err : File ::NULL )
2324 end
2425 File . delete ( tmp_path ) if File . exist? ( tmp_path )
2526 else
26- success = system ( "git" , "-C" , root_path , "show" , "HEAD:#{ vcs_file_path } " , out : checkout_path . to_s , err : File ::NULL )
27+ success = system ( git_env , "git" , "-C" , root_path , "show" , "HEAD:#{ vcs_file_path } " , out : checkout_path . to_s , err : File ::NULL )
2728 end
2829
2930 unless success
0 commit comments