Re: Git mv -- submodule -- recursive
On Mon, Jun 27, 2016 at 1:07 PM, Bart Bogaerts wrote: > Hi, > > I tested this on git version 2.9 and it still fails (exactly the same > behaviour as on the stackoverflow post; also the workarounded I posted > there still works). I see. the commit I referenced was solving a slightly different problem, than what we do here. That commit only fixed the issue for submodules in a nested directory. The important detail what is different in this case is having another nested submodule. If you only had - git-repo a -- subdirectory 2015 --- git-submodule b -- git-submodule c (quoted from SO) then `git mv c 2015/` is expected to work as well as `mkdir d && git mv 2015 d/` with submodule b being nested in 2015. but as you have a submodule inside of c, moving c is buggy. Stefan -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Git mv -- submodule -- recursive
Hi, I tested this on git version 2.9 and it still fails (exactly the same behaviour as on the stackoverflow post; also the workarounded I posted there still works). Some output showing the bug follows below: bartb@EB-Latitude-E5450 ~/Documents/papers $ git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean bartb@EB-Latitude-E5450 ~/Documents/papers $ git --version git version 2.9.0 bartb@EB-Latitude-E5450 ~/Documents/papers $ git mv fo-c-revisited/ 2016 bartb@EB-Latitude-E5450 ~/Documents/papers $ git status fatal: Not a git repository: idp-latex/../../.git/modules/fo-c-revisited/modules/idp-latex fatal: 'git status --porcelain' failed in submodule 2016/fo-c-revisited bartb@EB-Latitude-E5450 ~/Documents/papers $ rm 2016/fo-c-revisited/idp-latex/.git bartb@EB-Latitude-E5450 ~/Documents/papers $ git submodule update bartb@EB-Latitude-E5450 ~/Documents/papers $ git status On branch master Your branch is up-to-date with 'origin/master'. Changes to be committed: (use "git reset HEAD ..." to unstage) modified: .gitmodules renamed:fo-c-revisited -> 2016/fo-c-revisited bartb@EB-Latitude-E5450 ~/Documents/papers $ 2016-06-27 19:57 GMT+03:00 Stefan Beller : > On Sun, Jun 26, 2016 at 11:01 PM, Bart Bogaerts > wrote: >> With a repo structured as follows >> >> main-files >> |- submod >> |- subsubmodule >> >> git mv submod newlocation >> >> does not do what it is supposed to do. It actually breaks the git repository. >> It can be fixed easily. >> A complete description of the bug, including a workaround, can be found on >> http://stackoverflow.com/q/32782382/2274140 > > Which version of Git are you using? > I think this is fixed in a127331cd81233 (mv: allow moving nested > submodules, 2016-04-19), which is first included in v2.8.3 > (or v2.9 and later). > > Thanks, > Stefan > >> >> -- >> Bart Bogaerts >> -- >> To unsubscribe from this list: send the line "unsubscribe git" in >> the body of a message to majord...@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html -- Bart Bogaerts -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Git mv -- submodule -- recursive
On Sun, Jun 26, 2016 at 11:01 PM, Bart Bogaerts wrote: > With a repo structured as follows > > main-files > |- submod > |- subsubmodule > > git mv submod newlocation > > does not do what it is supposed to do. It actually breaks the git repository. > It can be fixed easily. > A complete description of the bug, including a workaround, can be found on > http://stackoverflow.com/q/32782382/2274140 Which version of Git are you using? I think this is fixed in a127331cd81233 (mv: allow moving nested submodules, 2016-04-19), which is first included in v2.8.3 (or v2.9 and later). Thanks, Stefan > > -- > Bart Bogaerts > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Git mv -- submodule -- recursive
With a repo structured as follows main-files |- submod |- subsubmodule git mv submod newlocation does not do what it is supposed to do. It actually breaks the git repository. It can be fixed easily. A complete description of the bug, including a workaround, can be found on http://stackoverflow.com/q/32782382/2274140 -- Bart Bogaerts -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git-mv-submodule
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 pgpZne3BJMPSW.pgp Description: PGP signature
Re: git-mv-submodule
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). -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
git-mv-submodule
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 #!/usr/bin/env perl use 5.10.1; use strict; use warnings; use autodie; use File::Basename 'dirname'; use File::Path 'make_path'; die "you must pass both a from and a to" unless @ARGV == 2; my ($from, $to) = @ARGV; die "you have changes in your working copy!" unless is_clean(); # move the real dir make_path(dirname($to)); safe_system('mv', $from, $to); # move the git dir (not really that important) make_path(dirname(".git/modules/$to")); safe_system('mv', ".git/modules/$from", ".git/modules/$to"); # update .gitmodules and .git/config book keeping spew($_, slurp($_) =~ s/\Q$from\E/$to/gr) for qw( .gitmodules .git/config ); my $dir_count = scalar split qr(/), $to =~ s(/$)()r; my $derp = ('../' x (2 + $dir_count)) . $to; # update .git/modules/$to/config book keeping spew( ".git/modules/$to/config", slurp(".git/modules/$to/config") =~ s/worktree.*/worktree = $derp/gr ); # update $to book keeping spew( "$to/.git", 'gitdir: ' . ('../' x $dir_count) . ".git/modules/$to" ); safe_system(qw( git add -A ), $from, $to, '.gitmodules' ); sub safe_system { system(@_); die "@_ exited poorly :(" if $? >> 8; } sub safe_capture { my $ret = qx(@_); die "@_ exited poorly :(" if $? >> 8; return $ret; } sub slurp { open my $fh, '<', $_[0]; local $/ = undef; scalar <$fh> } sub spew { open my $fh, '>', $_[0]; print {$fh} $_[1] } sub is_clean { !safe_capture(qw(git status --porcelain)) } pgpEyJW_kdh5r.pgp Description: PGP signature