]> git.phdru.name Git - git-scripts.git/blob - clone2current
Carefully list dirty repos and show their status
[git-scripts.git] / clone2current
1 #! /bin/sh
2
3 if [ -z "$1" ]; then
4    echo "Usage: $0 repoistory [directories]" >&2
5    exit 1
6 fi
7
8 cd "$1" && source_dir="`pwd`" &&
9
10 if [ ! -d ".git" ]; then
11    echo "$source_dir is not a repoistory (.git isn't found)" >&2
12    exit 1
13 fi &&
14
15 cd "$HOME"/current/projects &&
16 directories="$2" &&
17 if [ -n "$directories" ]; then
18    mkdir -p "$directories" && cd "$directories"
19 fi &&
20
21 dest_dir="`basename \"$source_dir\"`" &&
22 git clone "$source_dir" "$dest_dir" &&
23
24 cd "$dest_dir" &&
25 if [ "`cat \"$source_dir\"/.git/description`" = \
26    "Unnamed repository; edit this file 'description' to name the repository." ]
27 then
28    "${VISUAL:-${EDITOR:-vi}}" "$source_dir"/.git/description .git/description
29 else
30    cp -p "$source_dir"/.git/description .git
31 fi &&
32
33 cd "$source_dir" &&
34 if [ -n "$directories" ]; then
35    dest_dir="$directories/$dest_dir"
36 fi &&
37 exec git remote add current "$HOME"/current/projects/"$dest_dir"