subtree: fix add and pull for GPG-signed commits
If log.showsignature is true (or --show-signature is passed) while performing a `subtree add` or `subtree pull`, the command fails. toptree_for_commit() calls `log` and passes the output to `commit-tree`. If this output shows the GPG signature data, `commit-tree` throws a fatal error. This commit fixes the issue by adding --no-show-signature to `log` calls in a few places, as well as using the more appropriate `rev-parse` instead where possible. Signed-off-by: Stephen R Guglielmo <srg@guglielmo.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stephen R Guglielmo committed
Feb 23, 2018 at 15:41 UTC
8841b5222c63f4105d8751139a2b26dc2e3c5f9d
1 file changed
+6
-6
contrib/subtree/git-subtree.sh
+6
-6
@@ -297,7 +297,7 @@ find_latest_squash () {
297
main=
298
sub=
299
git log --grep="^git-subtree-dir: $dir/*\$" \
300
- --pretty=format:'START %H%n%s%n%n%b%nEND%n' HEAD |
300
+ --no-show-signature --pretty=format:'START %H%n%s%n%n%b%nEND%n' HEAD |
301
while read a b junk
302
do
303
debug "$a $b $junk"
@@ -341,7 +341,7 @@ find_existing_splits () {
341
main=
342
sub=
343
git log --grep="^git-subtree-dir: $dir/*\$" \
344
- --pretty=format:'START %H%n%s%n%n%b%nEND%n' $revs |
344
+ --no-show-signature --pretty=format:'START %H%n%s%n%n%b%nEND%n' $revs |
345
while read a b junk
346
do
347
case "$a" in
@@ -382,7 +382,7 @@ copy_commit () {
382
# We're going to set some environment vars here, so
383
# do it in a subshell to get rid of them safely later
384
debug copy_commit "{$1}" "{$2}" "{$3}"
385
- git log -1 --pretty=format:'%an%n%ae%n%aD%n%cn%n%ce%n%cD%n%B' "$1" |
385
+ git log -1 --no-show-signature --pretty=format:'%an%n%ae%n%aD%n%cn%n%ce%n%cD%n%B' "$1" |
386
(
387
read GIT_AUTHOR_NAME
388
read GIT_AUTHOR_EMAIL
@@ -462,8 +462,8 @@ squash_msg () {
462
oldsub_short=$(git rev-parse --short "$oldsub")
463
echo "Squashed '$dir/' changes from $oldsub_short..$newsub_short"
464
echo
465
- git log --pretty=tformat:'%h %s' "$oldsub..$newsub"
466
- git log --pretty=tformat:'REVERT: %h %s' "$newsub..$oldsub"
465
+ git log --no-show-signature --pretty=tformat:'%h %s' "$oldsub..$newsub"
466
+ git log --no-show-signature --pretty=tformat:'REVERT: %h %s' "$newsub..$oldsub"
467
else
468
echo "Squashed '$dir/' content from commit $newsub_short"
469
fi
@@ -475,7 +475,7 @@ squash_msg () {
475
476
toptree_for_commit () {
477
commit="$1"
478
- git log -1 --pretty=format:'%T' "$commit" -- || exit $?
478
+ git rev-parse --verify "$commit^{tree}" || exit $?
479
}
480
481
subtree_for_commit () {