Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

git reset --hard breaks the hard links #4

Open
dylanahsmith opened this issue Sep 5, 2012 · 1 comment
Open

git reset --hard breaks the hard links #4

dylanahsmith opened this issue Sep 5, 2012 · 1 comment

Comments

@dylanahsmith
Copy link

Although the copy.rb script will make the copy into the release directory fast, this time is actually just shifting to the git reset --hard command since it will break all the hard links, even for unchanged files. Breaking hard links equates to copying the file to replace the hard link.

Ideally this would be fixed in git, but as a workaround I found that git reset --mixed #{revision} && git checkout -f . checks out the files without breaking hard links, so actually speeds up deploys when using fast_remote_cache.

Adding the following to config/deploy.rb will speed up deploys by using avoid git reset --hard.

module FastGitSync
  def sync(revision, destination)
    git     = command
    remote  = origin
    branch  = head

    execute = []
    execute << "cd #{destination}"

    execute << "#{git} fetch #{verbose} #{remote} +#{branch}:refs/remotes/#{remote}/#{branch}"

    # Reset the git index
    execute << "#{git} reset #{verbose} --mixed #{revision}"

    # Checkout the index into the work tree
    execute << "#{git} checkout -f ."

    # Remove untracked files
    execute << "#{git} clean #{verbose} -d -x -f"

    execute.join(" && ")
  end
end

set(:source) { Capistrano::Deploy::SCM.new(scm, self).extend(FastGitSync) }

Some conditions from sync where removed for brevity. See the original source for the sync method for details.

Any thoughts on how this change should be integrated into fast_remote_cache?

@mherrmann
Copy link

Related: brave/brave-browser#20316 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants