aboutsummaryrefslogtreecommitdiff
path: root/git-submodule-move-all-git-dirs
blob: 72e1aa3fc83037b0bb58c7c1e4758875a8847ba8 (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
#!/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
find -type f -name .git | while read repo; do
  folder="`dirname $repo`"
  git-submodule-move-git-dir $folder
done