提交 6f1871fe 编写于 作者: J James Denholm 提交者: Junio C Hamano

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: NKevin Cagle <kcagle@micron.com>
Helped-by: NJunio C Hamano <gitster@pobox.com>
Signed-off-by: NJames Denholm <nod.helm@gmail.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 602efc4f
......@@ -558,8 +558,9 @@ cmd_add_commit()
commit=$(add_squashed_msg "$rev" "$dir" |
git commit-tree $tree $headp -p "$rev") || exit $?
else
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 $?
fi
git reset "$commit" || exit $?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册