Skip to content

Commit afa75bc

Browse files
jnarebgitster
authored andcommitted
contrib: Make remotes2config.sh script more robust
The remotes2config.sh script replaced all 'unsafe' characters in repo name with '.'; include '-' in the 'safe' characters set (the set is probably even larger). Script required also space after "URL:", "Push:" and "Pull:" in remotes file. This for example made the following remote URL: git://git.kernel.org/pub/scm/git/git.git Pull: refs/heads/master:refs/heads/origin Pull:+refs/heads/pu:refs/heads/pu miss 'pu' branch (forced branch) in config file after conversion. Allow for any number of whitespace after "URL:", "Push:", "Pull:". Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2d324ef commit afa75bc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contrib/remotes2config.sh

100644100755
+4-4
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ if [ -d "$GIT_DIR"/remotes ]; then
1111
{
1212
cd "$GIT_DIR"/remotes
1313
ls | while read f; do
14-
name=$(printf "$f" | tr -c "A-Za-z0-9" ".")
14+
name=$(printf "$f" | tr -c "A-Za-z0-9-" ".")
1515
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" \
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" \
1919
< "$f"
2020
done
2121
echo done

0 commit comments

Comments
 (0)