@matheusbsbs / matheus-bagliano / commits / a4a6e4ab32
Fork 0

Add a conversion tool to migrate remote information into the config

Use this tool to rewrite the .git/remotes/* files into the config. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed May 3, 2006 at 15:27 UTC a4a6e4ab32648631204398691f4066719dea1029
1 file changed +35
contrib/remotes2config.sh new
+35
@@ -0,0 +1,35 @@
1 +#!/bin/sh
2 +
3 +# Use this tool to rewrite your .git/remotes/ files into the config.
4 +
5 +. git-sh-setup
6 +
7 +if [ -d "$GIT_DIR"/remotes ]; then
8 + echo "Rewriting $GIT_DIR/remotes" >&2
9 + error=0
10 + # rewrite into config
11 + {
12 + cd "$GIT_DIR"/remotes
13 + ls | while read f; do
14 + name=$(echo -n "$f" | tr -c "A-Za-z0-9" ".")
15 + sed -n \
16 + -e "s/^URL: \(.*\)$/remote.$name.url \1 ./p" \
17 + -e "s/^Pull: \(.*\)$/remote.$name.fetch \1 ^$ /p" \
18 + -e "s/^Push: \(.*\)$/remote.$name.push \1 ^$ /p" \
19 + < "$f"
20 + done
21 + echo done
22 + } | while read key value regex; do
23 + case $key in
24 + done)
25 + if [ $error = 0 ]; then
26 + mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old
27 + fi ;;
28 + *)
29 + echo "git-repo-config $key "$value" $regex"
30 + git-repo-config $key "$value" $regex || error=1 ;;
31 + esac
32 + done
33 +fi
34 +
35 +