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

[PATCH 1/2] git-subtree: make sure the SHA saved as ancestor is a commit

From
JRJérémy Rosen <jeremy.rosen@openwide.fr>
Date
Mar 13, 2013, 16:17 UTC
Message-ID
<1363191452-28804-2-git-send-email-jeremy.rosen@openwide.fr>
In-Reply-To
<1363191452-28804-1-git-send-email-jeremy.rosen@openwide.fr>

When adding or merging the first parameter might not be a commit, it can also be a tag SHA. This needs to be fixed by using the underlying commit or the ancestor finding code will croak at split time

Signed-off-by: Jérémy Rosen <jeremy.rosen@openwide.fr>
---
 contrib/subtree/git-subtree.sh |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 8a23f58..8b9d114 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -531,7 +531,7 @@ cmd_add_repository()
 
 cmd_add_commit()
 {
-	revs=$(git rev-parse $default --revs-only "$@") || exit $?
+	revs=$(git rev-parse $default --revs-only "$1^{commit}") || exit $?
 	set -- $revs
 	rev="$1"
 	
@@ -655,7 +655,7 @@ cmd_split()
 
 cmd_merge()
 {
-	revs=$(git rev-parse $default --revs-only "$@") || exit $?
+	revs=$(git rev-parse $default --revs-only "$1^{commit}") || exit $?
 	ensure_clean
 	
 	set -- $revs
-- 
1.7.10.4
Previous: Jérémy RosenNext: Jérémy Rosen
Message 2 of 3 in “git subtree: properly handle remote refs”
  1. 0/2 git subtree: properly handle remote refsJérémy Rosen, Mar 13, 2013
  2. 1/2 git-subtree: make sure the SHA saved as ancestor is a commitJérémy Rosen, Mar 13, 2013
  3. 2/2 git-subtree: use ls-remote to check the refspec passed to pull and addJérémy Rosen, Mar 13, 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.