Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git_manager.rb:64: warning: conflicting chdir during another chdir block #10

Open
paulie4 opened this issue Nov 2, 2012 · 3 comments
Open

Comments

@paulie4
Copy link
Contributor

paulie4 commented Nov 2, 2012

I was getting many of those chdir warnings. To stop them, I removed the surrounding Dir.chdir @git_path do so this:

      Dir.chdir @git_path do
        # This is fast, but only works on locally checked out branches
        `git show-ref --verify --quiet 'refs/heads/#{branch}'`
        return true if $?.exitstatus == 0

        # This is slow and will only get called for remote branches.
        result = `git ls-remote --heads origin 'refs/heads/#{branch}'`
        return result.strip.length != 0
      end

becomes this:

      # This is fast, but only works on locally checked out branches
      `git --git-dir #{@git_path}/.git show-ref --verify --quiet 'refs/heads/#{branch}'`
      return true if $?.exitstatus == 0

      # This is slow and will only get called for remote branches.
      result = `git --git-dir #{@git_path}/.git ls-remote --heads origin 'refs/heads/#{branch}'`
      return result.strip.length != 0
@paulie4
Copy link
Contributor Author

paulie4 commented Nov 3, 2012

I just noticed that the git() function also wraps the git calls in Dir.chdir and should also be changed.

@paulie4
Copy link
Contributor Author

paulie4 commented Nov 3, 2012

Whoops. Evidently, the git calls will also need --work-tree, e.g.:
git --work-tree #{@git_path} --git-dir #{@git_path}/.git #{cmd.to_s} 2>&1

@meltingice
Copy link
Member

Would love to see this in a pull request 😄

This was referenced Nov 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants