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

Support submodules #31

Closed
ekohl opened this issue Sep 28, 2012 · 3 comments
Closed

Support submodules #31

ekohl opened this issue Sep 28, 2012 · 3 comments

Comments

@ekohl
Copy link

ekohl commented Sep 28, 2012

Currently when you use git up in a submodule you get the following stack trace:

/usr/lib/ruby/gems/1.8/gems/grit-2.4.1/lib/grit/git-ruby.rb:114:in `chdir': Not a directory - /some/path/to/our/submodule/.git (Errno::ENOTDIR)
    from /usr/lib/ruby/gems/1.8/gems/grit-2.4.1/lib/grit/git-ruby.rb:114:in `refs'
    from /usr/lib/ruby/gems/1.8/gems/grit-2.4.1/lib/grit/ref.rb:13:in `find_all'
    from /usr/lib/ruby/gems/1.8/gems/grit-2.4.1/lib/grit/repo.rb:212:in `branches'
    from /usr/lib/ruby/gems/1.8/gems/git-up-0.5.8/lib/git-up.rb:88:in `remote_map'
    from /usr/lib/ruby/gems/1.8/gems/git-up-0.5.8/lib/git-up.rb:84:in `remotes'
    from /usr/lib/ruby/gems/1.8/gems/git-up-0.5.8/lib/git-up.rb:8:in `run'
    from /usr/lib64/ruby/gems/1.8/gems/git-up-0.5.8/bin/git-up:5
    from /usr/bin/git-up:8:in `load'
    from /usr/bin/git-up:8

That's because it's a file with a pointer to the real directory:

gitdir: /the/real/path/to/our/submodule

I think it would be a nice feature to support.

@aanand
Copy link
Owner

aanand commented Oct 7, 2012

Yeah, this has been raised before. I agree it'd be nice, but it's not something I'm personally interested in working on. Pull requests welcome!

@aanand aanand closed this as completed Oct 7, 2012
@ekohl
Copy link
Author

ekohl commented Oct 7, 2012

I'll look into this. Not that experienced in ruby, but this might be a good time to learn. Btw, if you use #24 it will create a reference in both issues.

@ekohl
Copy link
Author

ekohl commented Oct 7, 2012

Looks like you can fix it in a 1-liner which I'll try to upstream in grit. No changes needed in git-up.

diff --git a/lib/grit/git-ruby.rb b/lib/grit/git-ruby.rb
index 290ebcd..ddf5f69 100644
--- a/lib/grit/git-ruby.rb
+++ b/lib/grit/git-ruby.rb
@@ -116,6 +116,10 @@ module Grit
     def refs(options, prefix)
       refs = []
       already = {}
+
+      # submodule
+      @git_dir = File.read(@git_dir)[/gitdir: (.*)/, 1] if File.file?(@git_dir)
+
       Dir.chdir(@git_dir) do
         files = Dir.glob(prefix + '/**/*')
         files.each do |ref|

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