git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[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
Next: Josef Weidendorfer
Message 1 of 21 in “[RFC 2/2] Automatically transform .git/{branches,remotes} into .git/config”
  1. Johannes SchindelinNov 21, 2005
  2. Josef WeidendorferNov 21, 2005
  3. Johannes SchindelinNov 21, 2005
  4. Josef WeidendorferNov 21, 2005
  5. Andreas EricssonNov 21, 2005
  6. Junio C HamanoNov 21, 2005
  7. Petr BaudisNov 27, 2005
  8. Johannes SchindelinNov 28, 2005
  9. Junio C HamanoNov 28, 2005
  10. Andreas EricssonNov 28, 2005
  11. Junio C HamanoNov 28, 2005
  12. Josef WeidendorferNov 28, 2005
  13. Andreas EricssonNov 28, 2005
  14. Generic configuration plumbing (Was: Re: [RFC 2/2] Automatically transform...)Josef Weidendorfer, Nov 28, 2005
  15. Johannes SchindelinNov 28, 2005
  16. Petr BaudisNov 28, 2005
  17. Josef WeidendorferNov 28, 2005
  18. Junio C HamanoNov 29, 2005
  19. Johannes SchindelinNov 28, 2005
  20. Petr BaudisNov 28, 2005
  21. Johannes SchindelinNov 28, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.