Skip to content

Commit 6f1871f

Browse files
ChemicalRascalgitster
authored andcommitted
contrib/subtree: allow adding an annotated tag
cmd_add_commit() is passed FETCH_HEAD by cmd_add_repository, which is then rev-parsed into an object name. However, if the user is fetching a tag rather than a branch HEAD, such as by executing: $ git subtree add -P oldGit https://github.com/git/git.git tags/v1.8.0 the object name refers to a tag and is never peeled, and the git commit-tree call (line 561) slaps us in the face because it doesn't peel tags to commits. Because peeling a committish doesn't do anything if it's already a commit, fix by peeling the object name before assigning it to $rev using peel_committish() from git:git-sh-setup.sh, a pre-existing dependency of git-subtree. Reported-by: Kevin Cagle <[email protected]> Helped-by: Junio C Hamano <[email protected]> Signed-off-by: James Denholm <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 602efc4 commit 6f1871f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,9 @@ cmd_add_commit()
558558
commit=$(add_squashed_msg "$rev" "$dir" |
559559
git commit-tree $tree $headp -p "$rev") || exit $?
560560
else
561+
revp=$(peel_committish "$rev") &&
561562
commit=$(add_msg "$dir" "$headrev" "$rev" |
562-
git commit-tree $tree $headp -p "$rev") || exit $?
563+
git commit-tree $tree $headp -p "$revp") || exit $?
563564
fi
564565
git reset "$commit" || exit $?
565566

0 commit comments

Comments
 (0)