Re:Heroku Fucking Console
by hesselink on Friday March 01, 2013 @02:07PM
(#5306253)
It always annoys me when git does this:
I bet git knows exactly where that is. So go there and do it!
[ Parent
| on HN ]
It may know exactly where that is, but it doesn't necessarily know that you weren't trying to only update submodules in the current directory. Most git commands operate only on stuff reachable from the current directory, but `git submodule update` is incapable of being limited like that.
I'm not sure that is true...
You can update only a specific repo if you'd like. In which case it would be possible to limit the submodule command to only submodules existing in the current directory.
Yes, it would need to scale back up to the .gitmodules file, but it is still possible.
Yes, obviously the behavior of `git submodule update` could be rewritten. But the way it works right now, it can't be restricted to just submodules reachable from the current directory.
This might be because it's ambiguous which submodules you want to update if you have nested submodules.
In other words, git knows "exactly where that is" by searching parent directories until it sees a ".git". Unfortunately, submodules also have ".git" in them since they're full git repositories themselves.
git submodules are not the nicest part of git, unfortunately.
OK, so it wouldn't work if you're in a submodule. It could print a warning if there are no submodules. But if would still work perfectly fine in the majority of the cases.
For those also annoyed, I use this git alias, which does what I want:
sup = !sh -c 'cd `git rev-parse --show-toplevel` && git submodule update --init' -Honestly, git's the only program on this page that I'm fine with it being explicit and pedantic about what it's going to do. There are many situations where it could probably guess what I wanted to do but be wrong...
I mean, christ, I fetch and merge as separate steps.