Hello all,
I was on a plane, moving around some of the many (30ish) submodules in
my dotfiles and got really annoyed at how much work it is (move the
dir, remove old from git, add new to git, fix .gitmodules, fix
.git/config, fix all the parts of the submodule config) so I wrote a
perl script to work for the most common case.
As far as I know it should work for anyone not doing Something Weird,
ie manually fiddling with their submodules. The main case it does not
support that I'd like to in the future is submodules containing
submodules, and also at some point I'd like to wrap git mv to invoke
this script on demand automatically.
Note that this script requires perl 5.10.1, released in 2009. If you
are stuck with something inferior to that you can comment out the
version at the top and the autodie usage and it should work further
back, but won't be quite as robust.
Enjoy!
--
fREW Schmidt
http://blog.afoolishmanifesto.com
Am 21.12.2013 10:48, schrieb fREW Schmidt:
Hello all,
I was on a plane, moving around some of the many (30ish) submodules in
my dotfiles and got really annoyed at how much work it is (move the
dir, remove old from git, add new to git, fix .gitmodules, fix
.git/config, fix all the parts of the submodule config) so I wrote a
perl script to work for the most common case.
As far as I know it should work for anyone not doing Something Weird,
ie manually fiddling with their submodules. The main case it does not
support that I'd like to in the future is submodules containing
submodules, and also at some point I'd like to wrap git mv to invoke
this script on demand automatically.
Thanks for sharing! Form a cursory look over your perl script it
looks like it does what stock "git mv" will do since 1.8.5 (except
for changing the name of the submodule, which I would not advise
to do when only moving the submodule location in the work tree).
On Sat, Dec 21, 2013 at 05:08:59PM +0100, Jens Lehmann wrote:
Am 21.12.2013 10:48, schrieb fREW Schmidt:
Thanks for sharing! Form a cursory look over your perl script it
looks like it does what stock "git mv" will do since 1.8.5 (except
for changing the name of the submodule, which I would not advise
to do when only moving the submodule location in the work tree).
See, I thought I read that in the changelog; unfortunately I don'g
thing it does the final set of book-keeping (changing the .git file if
you changed the depth of the submodule in the mv and changing the path
of the worktree in the actual git repo in .git/modules)
I'd love to be wrong on that as this script is clearly not perfect. I
think my second little script in my previous email re git submodule
bugs shows the issue. I'll include it here for simplicity though:
mkdir -p test/a test/b
cd test/a
git init
touch a.txt
git add a.txt
git ci -m 'initial commit'
cd ../b
git init
mkdir c
touch c/c.txt
git submodule add ../a c/a
git ci -m 'initial commit'
git mv c d
git status
--
fREW Schmidt
http://blog.afoolishmanifesto.com