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

[PATCH 02/19] Add from-submodule. Conflicts: .gitignore contrib/subtree/git-subtree.sh test.sh

From
Paul Campbell <pcampbell@kemitix.net>
Date
Mar 9, 2013, 19:20 UTC
Message-ID
<CALeLG_=Ch2eTBF59UKTCr1vCpW=asbAdXBs+uYP+gtv=w4H6AA@mail.gmail.com>
>From 718c99d167255b28830b6f684d6e6e184fba0f7c Mon Sep 17 00:00:00 2001
From: Paul Campbell <pcampbell@kemitix.net>
Date: Sat, 9 Mar 2013 18:30:20 +0000
Subject: [PATCH 02/19] Add from-submodule. Conflicts: 	.gitignore
 contrib/subtree/git-subtree.sh 	test.sh
Original-Author: Peter Jaros <pjaros@pivotallabs.com>
Conflicts-resolved-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.sh | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..caf4988 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -14,6 +14,7 @@ git subtree merge --prefix=<prefix> <commit>
 git subtree pull  --prefix=<prefix> <repository> <refspec...>
 git subtree push  --prefix=<prefix> <repository> <refspec...>
 git subtree split --prefix=<prefix> <commit...>
+git subtree from-submodule --prefix=<prefix>
 --
 h,help        show the help
 q             quiet
@@ -101,7 +102,7 @@ done
 command="$1"
 shift
 case "$command" in
-	add|merge|pull) default= ;;
+	add|merge|pull|from-submodule) default= ;;
 	split|push) default="--default HEAD" ;;
 	*) die "Unknown command '$command'" ;;
 esac
@@ -721,4 +722,31 @@ cmd_push()
 	fi
 }

+cmd_from-submodule()
+{
+	ensure_clean
+
+	local submodule_sha=$(git submodule status $prefix | cut -d ' ' -f 2)
+
+	# Remove references to submodule.
+	git config --remove-section submodule.$prefix
+	git config --file .gitmodules --remove-section submodule.$prefix
+	git add .gitmodules
+
+	# Move submodule aside.
+	local tmp_repo="$(mktemp -d /tmp/git-subtree.XXXXX)"
+	rm -r $tmp_repo
+	mv $prefix $tmp_repo
+	git rm $prefix
+
+	# Commit changes.
+	git commit -m "Remove '$prefix/' submodule"
+
+	# subtree add from submodule repo.
+	cmd_add_repository $tmp_repo HEAD
+
+	# Remove submodule repo.
+	rm -rf $tmp_repo
+}
+
 "cmd_$command" "$@"
-- 
1.8.2.rc1


-- 
Paul [W] Campbell
Message 1 of 1 in “Add from-submodule. Conflicts: .gitignore contrib/subtree/git-subtree.sh test.sh”
  1. 02/19 Add from-submodule. Conflicts: .gitignore contrib/subtree/git-subtree.sh test.shPaul 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.