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

[PATCH 2/4] contrib/subtree: Allow stale .gitsubtree entries to be replaced

From
Paul Campbell <pcampbell@kemitix.net>
Date
Feb 12, 2013, 23:23 UTC
Message-ID
<CALeLG_=t1E9uemehqPD48r+2JrRSToJJcSBuOQn=Qz7730=4-w@mail.gmail.com>

Should .gitsubtree have a <prefix> listed that doesn't exist on disk, allow it to be replaced/updated by a git subtree add.

Ideally I would have aborted the operation if there was an existing entry and required the user to edit the .gitsubtree file by hand, but that behaviour broke a lot of the tests.

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 02aae30..4f21902 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -490,7 +490,13 @@ ensure_clean()

 subtree_memorize()
 {
-	if [ $# -eq 1 ] ; then
+	if ( grep "^$dir " .gitsubtree ); then
+		# remove $dir from .gitsubtree - there's probably a clever way to
do this with sed
+		grep -v "^$dir " .gitsubtree > .gitsubtree.temp
+		rm .gitsubtree
+		mv .gitsubtree.temp .gitsubtree
+	fi
+	if [ $# -eq 1 ]; then
 		echo "$dir . $@" >> .gitsubtree
 	elif [ $# -eq 2 ]; then
 		echo "$dir $@" >> .gitsubtree
-- 
1.8.1.3.566.gaa39828
Message 1 of 1 in “contrib/subtree: Allow stale .gitsubtree entries to be replaced”
  1. 2/4 contrib/subtree: Allow stale .gitsubtree entries to be replacedPaul Campbell, Feb 12, 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.