git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [BUG] can't switch branches with submodules
@ 2013-02-09 12:25 Ramkumar Ramachandra
  0 siblings, 0 replies; 20+ messages in thread
From: Ramkumar Ramachandra @ 2013-02-09 12:25 UTC (permalink / raw)
  To: Git List; +Cc: Jens Lehmann

Hi,

I have two branches: master and gh-pages.  master has one submodule
called foo that gh-pages doesn't.  When I try to check out gh-pages
from master:

    warning: unable to rmdir foo: Directory not empty

And the foo directory exists in my worktree.  This is very annoying,
and I want to fix it now.  Where is this error coming from?  How does
the worktree get updated when I checkout?

^ permalink raw reply	[flat|nested] 20+ messages in thread
* [New Feature] git-submodule-move - Easily move submodules
@ 2013-02-03 22:36 TJ
  2013-02-04 20:14 ` Jens Lehmann
  0 siblings, 1 reply; 20+ messages in thread
From: TJ @ 2013-02-03 22:36 UTC (permalink / raw)
  To: git

I've recently had need to re-arrange more than ten submodules within a project and discovered there is apparently no easy way to do it.

Using some suggestions I found on Stack Overflow I eventually figured out the steps required. Because the steps can be
complex I thought it would be handy to have a tool to automate the functionality.

I have put together a reasonably bullet-proof shell script "git-submodule-move" that does the job pretty well. I've put it through quite a bit of testing and trusted it with my own project and it has
performed well.

I've published to github so others can use and improve it.

https://github.com/iam-TJ/git-submodule-move

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Moving (renaming) submodules, recipe/script
@ 2013-01-07  0:36 W. Trevor King
  2013-01-07  1:39 ` Jonathan Nieder
  2013-02-03 23:38 ` Moving (renaming) submodules, recipe/script W. Trevor King
  0 siblings, 2 replies; 20+ messages in thread
From: W. Trevor King @ 2013-01-07  0:36 UTC (permalink / raw)
  To: Git

[-- Attachment #1: Type: text/plain, Size: 2325 bytes --]

Today I had to move my first submodule, and I discovered that Git's
support for this is pretty limited.  There have been a few patch
series attempting to address this [1,2], but none of them seems to
have pushed through into master (although I can't put my finger on a
reason for why).  There are also some SO postings discussing this
[3,4].  It would be nice if `git mv` worked out of the box on
submodules.  Failing that, there could be a `git submodule mv` command
that casts the appropriate spell.  Failing that, there could be a
recipe in Documentation/git-submodule.txt.  Here's the best I could
come up with for a `git-submodule-mv.sh`:

  #!/bin/sh
  # usage: git-submodule-mv.sh OLD NEW
  OLD=$(realpath --relative-to . "$1")
  NEW=$(realpath --relative-to . "$2")
  SHA=$(git ls-files -s "$OLD" | sed 's|^[0-9]* \([0-9a-f]*\) .*|\1|')
  NAME=$(git config -f .gitmodules --get-regexp 'submodule\..*\.path' "$OLD" |
    sed -e 's|^submodule.||' -e "s|.path $OLD\$||")
  GITDIR=$(realpath --relative-to "$NEW" .git/modules/"$NAME")
  git config -f .gitmodules submodule."$NAME".path "$NEW"
  git config -f .git/modules/"$NAME"/config core.worktree "../../../$NEW"
  git rm --cached "$OLD"
  mv "$OLD" "$NEW"
  echo "gitdir: $GITDIR" > "$NEW/.git"
  git update-index --add --cacheinfo 160000 "$SHA" "$NEW"

This only works from the repository root directory, and I'm sure makes
a number of poor assumptions (e.g. old-style submodules that don't use
`gitdir` links are not supported).  It does work for some simple test
cases.  The tricky parts (e.g. path -> name conversion) are already
worked out more robustly git-submodule.sh, so adding a new cmd_mv
shouldn't be very difficult.

Could something like this live somewhere in Git, or are we waiting for
a more integrated solution?

Cheers,
Trevor

[1]: http://thread.gmane.org/gmane.comp.version-control.git/88720
[2]: http://thread.gmane.org/gmane.comp.version-control.git/143250
[4]: http://stackoverflow.com/questions/4323558/moving-submodules-with-git
[3]: http://stackoverflow.com/questions/4604486/how-do-i-move-an-existing-git-submodule-within-a-git-repository

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Git submodule for a local branch?
@ 2012-10-22 12:37 W. Trevor King
  2012-10-23 13:21 ` W. Trevor King
  2012-10-23 20:57 ` Jens Lehmann
  0 siblings, 2 replies; 20+ messages in thread
From: W. Trevor King @ 2012-10-22 12:37 UTC (permalink / raw)
  To: Git

[-- Attachment #1: Type: text/plain, Size: 1187 bytes --]

I have a bunch of branches in my repo (a, b, c, …), and I'd like to
check them out into subdirectories of another branch (index).  My
initial inclination was to use something like

  $ git checkout index
  $ git branch
    a
    b
    c
  * index
  $ git submodule add -b a --reference ./ ./ dir-for-a/
  $ git submodule add -b b --reference ./ ./ dir-for-b/
  $ git submodule add -b c --reference ./ ./ dir-for-c/

but cloning a remote repository (vs. checking out a local branch)
seems to be baked into the submodule implementation.  Should I be
thinking about generalizing git-submodule.sh, or am I looking under
the wrong rock?  My ideal syntax would be something like

  $ git submodule add -b c --local dir-for-c/

The motivation is that I have website that contains a bunch of
sub-sites, and the sub-sites share content.  I have per-sub-site
branches (a, b, c) and want a master branch (index) that aggregates
them.  Perhaps this is too much to wedge into a single repository?

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2013-02-09 12:32 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-09 12:25 [BUG] can't switch branches with submodules Ramkumar Ramachandra
  -- strict thread matches above, loose matches on Subject: below --
2013-02-03 22:36 [New Feature] git-submodule-move - Easily move submodules TJ
2013-02-04 20:14 ` Jens Lehmann
2013-01-07  0:36 Moving (renaming) submodules, recipe/script W. Trevor King
2013-01-07  1:39 ` Jonathan Nieder
2013-01-07  6:59   ` Jens Lehmann
2013-01-07  7:44     ` Junio C Hamano
2013-01-07  8:18       ` Jens Lehmann
2013-01-07 16:08         ` Junio C Hamano
2013-01-07 12:08     ` W. Trevor King
2013-01-08 14:32     ` W. Trevor King
2013-01-08 17:12       ` Jens Lehmann
2013-01-08 17:48         ` W. Trevor King
2013-02-09 12:32     ` [BUG] can't switch branches with submodules W. Trevor King
2013-02-03 23:38 ` Moving (renaming) submodules, recipe/script W. Trevor King
2012-10-22 12:37 Git submodule for a local branch? W. Trevor King
2012-10-23 13:21 ` W. Trevor King
2012-10-23 20:57 ` Jens Lehmann
2012-10-23 22:09   ` W. Trevor King
2013-01-08 15:59     ` Moving (renaming) submodules, recipe/script W. Trevor King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).