path: root/contrib/subtree/
diff options
authorJames Denholm <>2014-05-13 04:08:58 (GMT)
committerJunio C Hamano <>2014-05-13 19:33:26 (GMT)
commit6f1871fe0f7d9bddfbe199cceeb255cf8edbaab3 (patch)
tree16177315dec7727e132af53503eb0bbe9004ac27 /contrib/subtree/
parent602efc4f90295369763cc58b47c3c6532a070fe9 (diff)
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 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, a pre-existing dependency of git-subtree. Reported-by: Kevin Cagle <> Helped-by: Junio C Hamano <> Signed-off-by: James Denholm <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'contrib/subtree/')
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/subtree/ b/contrib/subtree/
index db925ca..fa1a583 100755
--- a/contrib/subtree/
+++ b/contrib/subtree/
@@ -558,8 +558,9 @@ cmd_add_commit()
commit=$(add_squashed_msg "$rev" "$dir" |
git commit-tree $tree $headp -p "$rev") || exit $?
+ revp=$(peel_committish "$rev") &&
commit=$(add_msg "$dir" "$headrev" "$rev" |
- git commit-tree $tree $headp -p "$rev") || exit $?
+ git commit-tree $tree $headp -p "$revp") || exit $?
git reset "$commit" || exit $?