Skip to content

Commit 5d65fe3

Browse files
Rob Mayoffpeff
authored andcommitted
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>. Signed-off-by: Rob Mayoff <mayoff@dqd.com> Signed-off-by: Jeff King <peff@peff.net>
1 parent 5cb2e16 commit 5d65fe3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ find_latest_squash()
245245
case "$a" in
246246
START) sq="$b" ;;
247247
git-subtree-mainline:) main="$b" ;;
248-
git-subtree-split:) sub="$b" ;;
248+
git-subtree-split:)
249+
sub="$(git rev-parse "$b^0")" ||
250+
die "could not rev-parse split hash $b from commit $sq"
251+
;;
249252
END)
250253
if [ -n "$sub" ]; then
251254
if [ -n "$main" ]; then
@@ -278,7 +281,10 @@ find_existing_splits()
278281
case "$a" in
279282
START) sq="$b" ;;
280283
git-subtree-mainline:) main="$b" ;;
281-
git-subtree-split:) sub="$b" ;;
284+
git-subtree-split:)
285+
sub="$(git rev-parse "$b^0")" ||
286+
die "could not rev-parse split hash $b from commit $sq"
287+
;;
282288
END)
283289
debug " Main is: '$main'"
284290
if [ -z "$main" -a -n "$sub" ]; then

0 commit comments

Comments
 (0)