app/services/merge_requests/squash_service.rb
# Adding a worktree means checking out the repository. For large repos, this
# can be very expensive, so set up sparse checkout for the worktree to only
# check out the files we're interested in.
#
Adding a worktree means checking out the repository. For large repos, this
can be very expensive, so set up sparse checkout for the worktree to only
check out the files we're interested in.
Adding a worktree means checking out the repository . For large repos this can be very expensive so set up sparse checkout for the worktree to only check out the files we ' re interested in .
def configure_sparse_checkout
      run_git_command(
        %w(config core.sparseCheckout true),
        repository.path_to_repo,
        git_env,
        'configure sparse checkout'
      )
      diff_files = run_git_command(
        %W(diff --name-only --diff-filter=a --binary {diff_range}),
        repository.path_to_repo,
        git_env,
        'get files in diff'
      )
       If only new files are introduced by this MR, then our sparse checkout
       doesn't need to have any files at all.
      unless diff_files.empty?
        worktree_info = File.join(worktree_path, 'info')
        FileUtils.mkdir_p(worktree_info) unless File.directory?(worktree_info)
        File.write(File.join(worktree_info, 'sparse-checkout'), diff_files)
      end
      run_git_command(
        %W(checkout --detach {merge_request.target_branch}),
        tree_path,
        git_env,
        'check out target branch'
      )
    end
def configure_sparse_checkout run_git_command ( %w( config core.sparseCheckout true ) , repository . path_to_repo , git_env , 'configure sparse checkout' ) diff_files = run_git_command ( %W( diff --name-only --diff-filter=a --binary #{ diff_range } ) , repository . path_to_repo , git_env , 'get files in diff' ) unless diff_files . empty? worktree_info = File . join ( worktree_path , 'info' ) FileUtils . mkdir_p ( worktree_info ) unless File . directory? ( worktree_info ) File . write ( File . join ( worktree_info , 'sparse-checkout' ) , diff_files ) end run_git_command ( %W( checkout --detach #{ merge_request . target_branch } ) , tree_path , git_env , 'check out target branch' ) end
Adding a worktree means checking out the repository.
Adding a worktree means checking out the repository .
# Get the same diff we'll apply, excluding added files. (We can't check # out files on the target branch if they don't exist yet!) # # If only new files are introduced by this MR, then our sparse checkout # doesn't need to have any files at all. #