Skip to contentSkip to conversation

contrib/subtree: unwrap tag refs

PATCH In review Rob Mayoff 4 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

Rob Mayoff

author
#0 lore raw

PATCH v2 1/1 contrib/subtree: unwrap tag refs

If a subtree was added using a tag ref, the tag ref is stored in the subtree commit message instead of the underlying commit's ref. To split or push subsequent changes to the subtree, the subtree command needs to unwrap the tag ref. This patch makes it do so.

The problem was described in a message to the mailing list from Junio C Hamano dated 29 Apr 2014, with the subject "Re: git subtree issue in more recent versions". The archived message can be found at <http://comments.gmane.org/gmane.comp.version-control.git/247503>.

---

changes since v1:

* remove obsolete sub assignments
* wrap lines

 contrib/subtree/git-subtree.sh | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
contrib/subtree/git-subtree.sh +8 -2
index 9f06571..5ed0ea5 100755
@@ -245,7 +245,10 @@ find_latest_squash()
 		case "$a" in
 			START) sq="$b" ;;
 			git-subtree-mainline:) main="$b" ;;
-			git-subtree-split:) sub="$b" ;;
+			git-subtree-split:)
+				sub="$(git rev-parse "$b^0")" ||
+				    die "could not rev-parse split hash $b from commit $sq"
+				;;
 			END)
 				if [ -n "$sub" ]; then
 					if [ -n "$main" ]; then
@@ -278,7 +281,10 @@ find_existing_splits()
 		case "$a" in
 			START) sq="$b" ;;
 			git-subtree-mainline:) main="$b" ;;
-			git-subtree-split:) sub="$b" ;;
+			git-subtree-split:)
+				sub="$(git rev-parse "$b^0")" ||
+				    die "could not rev-parse split hash $b from commit $sq"
+				;;
 			END)
 				debug "  Main is: '$main'"
 				if [ -z "$main" -a -n "$sub" ]; then
Signature · 1 line
2.4.3
#1 lore raw
Quoted 10 lines · Rob Mayoff

If a subtree was added using a tag ref, the tag ref is stored in the subtree commit message instead of the underlying commit's ref. To split or push subsequent changes to the subtree, the subtree command needs to unwrap the tag ref. This patch makes it do so.

The problem was described in a message to the mailing list from Junio C Hamano dated 29 Apr 2014, with the subject "Re: git subtree issue in more recent versions". The archived message can be found at <http://comments.gmane.org/gmane.comp.version-control.git/247503>.

Quoted 7 lines

---

changes since v1:

* remove obsolete sub assignments
* wrap lines

Thanks. David, can I get an Ack on this?

-Peff

#2 lore raw
Quoted 14 lines · Jeff King
Quoted 12 lines · Rob Mayoff

If a subtree was added using a tag ref, the tag ref is stored in the subtree commit message instead of the underlying commit's ref. To split or push subsequent changes to the subtree, the subtree command needs to unwrap the tag ref. This patch makes it do so.

The problem was described in a message to the mailing list from Junio C Hamano dated 29 Apr 2014, with the subject "Re: git subtree issue in more recent versions". The archived message can be found at <http://comments.gmane.org/gmane.comp.version-control.git/247503>.>

---

Quoted 6 lines
Quoted 4 lines

changes since v1:

* remove obsolete sub assignments
* wrap lines

Thanks. David, can I get an Ack on this?

Yep. I'm sorry I missed this re-roll.

-David