git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 2/2] Automatically transform .git/{branches,remotes} into .git/config
@ 2005-11-21 13:56 Johannes Schindelin
  2005-11-21 15:44 ` Josef Weidendorfer
  2005-11-27 12:59 ` Petr Baudis
  0 siblings, 2 replies; 21+ messages in thread
From: Johannes Schindelin @ 2005-11-21 13:56 UTC (permalink / raw)
  To: git


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

^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2005-11-29  6:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-21 13:56 [RFC 2/2] Automatically transform .git/{branches,remotes} into .git/config Johannes Schindelin
2005-11-21 15:44 ` Josef Weidendorfer
2005-11-21 15:57   ` Johannes Schindelin
2005-11-21 16:25     ` Josef Weidendorfer
2005-11-21 16:34     ` Andreas Ericsson
2005-11-21 22:26     ` Junio C Hamano
2005-11-27 12:59 ` Petr Baudis
2005-11-28  1:52   ` Johannes Schindelin
2005-11-28  6:22     ` Junio C Hamano
2005-11-28  8:43       ` Andreas Ericsson
2005-11-28  9:14         ` Junio C Hamano
2005-11-28 12:59         ` Josef Weidendorfer
2005-11-28 13:11           ` Andreas Ericsson
2005-11-28 14:32             ` Generic configuration plumbing (Was: Re: [RFC 2/2] Automatically transform...) Josef Weidendorfer
2005-11-28 15:26               ` Johannes Schindelin
2005-11-28 13:48           ` [RFC 2/2] Automatically transform .git/{branches,remotes} into .git/config Petr Baudis
2005-11-28 15:03             ` Josef Weidendorfer
2005-11-29  6:04           ` Junio C Hamano
2005-11-28 16:29       ` Johannes Schindelin
2005-11-28 13:59     ` Petr Baudis
2005-11-28 16:33       ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).