aboutsummaryrefslogtreecommitdiff
path: root/git-submodule-move-all-git-dirs
blob: fc92b66077eb7a67b757fdeefcd2c74aa8b5030a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
#
# Call git-submodule-move-git-dir for each repository in a tree
#

# Parameters
BASENAME="`basename $0`"
FOLDER="$1"

# Checks
if [ -z "$FOLDER" ]; then
  echo "usage: $BASENAME <repository-path>"
  exit 1
elif [ ! -d "$FOLDER" ]; then
  echo "$BASENAME: repository not found: $FOLDER"
  exit 1
elif [ ! -e "$FOLDER/.git" ]; then
  echo "$BASENAME: $FOLDER/.git not found"
  exit 1
fi

cd $FOLDER

# Find returns innermost folders first, which is essential for a
# successful migration
find -type f -name .git | while read repo; do
  folder="`dirname $repo`"
  git-submodule-move-git-dir $folder
done