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

[PATCH 03/19] Use .gittrees config file like a .gitmodules when pull or push

From
Paul Campbell <pcampbell@kemitix.net>
Date
Mar 9, 2013, 19:21 UTC
Message-ID
<CALeLG_mY2BPpPjbGJ=3BKkeu3V7cngEmvhDOJ2UWDeO25E+aLw@mail.gmail.com>
>From 92787322c6e0e8c9166f02f98a71b6e0af9dc405 Mon Sep 17 00:00:00 2001
From: bibendi <bibendi@bk.ru>
Date: Fri, 20 May 2011 00:15:53 +0600
Subject: [PATCH 03/19] Use .gittrees config file like a .gitmodules when pull
 or push
---
 contrib/subtree/git-subtree.sh | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index caf4988..cb9e288 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -593,7 +593,8 @@ cmd_split()
 	eval "$grl" |
 	while read rev parents; do
 		revcount=$(($revcount + 1))
-		say -n "$revcount/$revmax ($createcount)
"
+		say -n "$revcount/$revmax ($createcount)
+"
 		debug "Processing commit: $rev"
 		exists=$(cache_get $rev)
 		if [ -n "$exists" ]; then
@@ -700,21 +701,31 @@ cmd_merge()

 cmd_pull()
 {
-	ensure_clean
-	git fetch "$@" || exit $?
-	revs=FETCH_HEAD
-	set -- $revs
-	cmd_merge "$@"
+    if [ $# -ne 1 ]; then
+	    die "You must provide <branch>"
+	fi
+	if [ -e "$dir" ]; then
+	    ensure_clean
+	    repository=$(git config -f .gittrees subtree.$prefix.url)
+	    refspec=$1
+	    git fetch $repository $refspec || exit $?
+	    echo "git fetch using: " $repository $refspec
+	    revs=FETCH_HEAD
+	    set -- $revs
+	    cmd_merge "$@"
+	else
+	    die "'$dir' must already exist. Try 'git subtree add'."
+	fi
 }

 cmd_push()
 {
-	if [ $# -ne 2 ]; then
-	    die "You must provide <repository> <refspec>"
+	if [ $# -ne 1 ]; then
+	    die "You must provide <branch>"
 	fi
 	if [ -e "$dir" ]; then
-	    repository=$1
-	    refspec=$2
+	    repository=$(git config -f .gittrees subtree.$prefix.url)
+	    refspec=$1
 	    echo "git push using: " $repository $refspec
 	    git push $repository $(git subtree split
--prefix=$prefix):refs/heads/$refspec
 	else
-- 
1.8.2.rc1


-- 
Paul [W] Campbell
Message 1 of 1 in “Use .gittrees config file like a .gitmodules when pull or push”
  1. 03/19 Use .gittrees config file like a .gitmodules when pull or pushPaul Campbell, Mar 9, 2013

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.