[RFC 2/2] Automatically transform .git/{branches,remotes} into .git/config
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Nov 21, 2005, 13:56 UTC
- Message-ID
- <Pine.LNX.4.63.0511211455120.13775@wbgn013.biozentrum.uni-wuerzburg.de>
With this patch, git automatically extracts the information from .git/branches and .git/remotes, puts it into .git/config, and renames the directories to .git/branches.old and .git/remotes.old, respectively.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
git-parse-remote.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-)
applies-to: 239817500e3556e8541d3b2b8257802c10da85c2 69062e3473f9f3cafe33954d9b995da89f6d9898
diff --git a/git-parse-remote.sh b/git-parse-remote.sh index cd976da..0d603ac 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -2,6 +2,59 @@ . git-sh-setup +if [ -d "$GIT_DIR"/branches ]; then + echo "Rewriting $GIT_DIR/branches" >&2 + error=0 + # rewrite into config + { + cd "$GIT_DIR"/branches + ls | while read f; do + name=$(echo -n "$f" | tr -c "A-Za-z0-9" ".") + sed \ + -e "s/^/remote.$name.url /" \ + -e "s/#\(.*\)$/\nremote.$name.pull \1/" \ + < "$f" + done + echo done + } | while read key value; do + case $key in + done) + if [ $error = 0 ]; then + mv "$GIT_DIR"/branches "$GIT_DIR"/branches.old + fi ;; + *) + git-config-set $key "$value" || error=1 ;; + esac + done +fi + +if [ -d "$GIT_DIR"/remotes ]; then + echo "Rewriting $GIT_DIR/remotes" >&2 + error=0 + # rewrite into config + { + cd "$GIT_DIR"/remotes + ls | while read f; do + name=$(echo -n "$f" | tr -c "A-Za-z0-9" ".") + sed -n \ + -e "s/^URL: /remote.$name.url . /p" \ + -e "s/^Pull: /remote.$name.pull ^$ /p" \ + -e "s/^Push: /remote.$name.push ^$ /p" \ + < "$f" + done + echo done + } | while read key regex value; do + case $key in + done) + if [ $error = 0 ]; then + mv "$GIT_DIR"/remotes "$GIT_DIR"/remotes.old + fi ;; + *) + git-config-set $key "$value" $regex || error=1 ;; + esac + done +fi + get_data_source () { case "$1" in */*) --- 0.99.9.GIT