2626fi
2727
2828OPTS_SPEC=" \
29- git subtree add --prefix=<prefix> <commit>
30- git subtree add --prefix=<prefix> <repository> <ref>
31- git subtree merge --prefix=<prefix> <commit>
32- git subtree split --prefix=<prefix> [<commit>]
33- git subtree pull --prefix=<prefix> <repository> <ref>
34- git subtree push --prefix=<prefix> <repository> <refspec>
29+ git subtree add --prefix=<prefix> [-S[=<key-id>]] <commit>
30+ git subtree add --prefix=<prefix> [-S[=<key-id>]] <repository> <ref>
31+ git subtree merge --prefix=<prefix> [-S[=<key-id>]] <commit>
32+ git subtree split --prefix=<prefix> [-S[=<key-id>]] [ <commit>]
33+ git subtree pull --prefix=<prefix> [-S[=<key-id>]] <repository> <ref>
34+ git subtree push --prefix=<prefix> [-S[=<key-id>]] <repository> <refspec>
3535--
3636h,help! show the help
3737q,quiet! quiet
@@ -46,6 +46,7 @@ rejoin merge the new branch back into HEAD
4646 options for 'add' and 'merge' (also: 'pull', 'split --rejoin', and 'push --rejoin')
4747squash merge subtree changes as a single commit
4848m,message!= use the given message as the commit message for the merge commit
49+ S,gpg-sign?key-id GPG-sign commits. The keyid argument is optional and defaults to the committer identity
4950"
5051
5152indent=0
@@ -115,7 +116,7 @@ main () {
115116 then
116117 set -- -h
117118 fi
118- set_args=" $( echo " $OPTS_SPEC " | git rev-parse --parseopt -- " $@ " || echo exit $? ) "
119+ set_args=" $( echo " $OPTS_SPEC " | git rev-parse --parseopt --stuck-long -- " $@ " || echo exit $? ) "
119120 eval " $set_args "
120121 . git-sh-setup
121122 require_work_tree
@@ -131,9 +132,6 @@ main () {
131132 opt=" $1 "
132133 shift
133134 case " $opt " in
134- --annotate|-b|-P|-m|--onto)
135- shift
136- ;;
137135 --rejoin)
138136 arg_split_rejoin=1
139137 ;;
@@ -171,48 +169,44 @@ main () {
171169 arg_split_annotate=
172170 arg_addmerge_squash=
173171 arg_addmerge_message=
172+ arg_gpg_sign=
174173 while test $# -gt 0
175174 do
176175 opt=" $1 "
177176 shift
178177
179178 case " $opt " in
180- -q )
179+ --quiet )
181180 arg_quiet=1
182181 ;;
183- -d )
182+ --debug )
184183 arg_debug=1
185184 ;;
186- --annotate)
185+ --annotate= * )
187186 test -n " $allow_split " || die_incompatible_opt " $opt " " $arg_command "
188- arg_split_annotate=" $1 "
189- shift
187+ arg_split_annotate=" ${opt#* =} "
190188 ;;
191189 --no-annotate)
192190 test -n " $allow_split " || die_incompatible_opt " $opt " " $arg_command "
193191 arg_split_annotate=
194192 ;;
195- -b )
193+ --branch= * )
196194 test -n " $allow_split " || die_incompatible_opt " $opt " " $arg_command "
197- arg_split_branch=" $1 "
198- shift
195+ arg_split_branch=" ${opt#* =} "
199196 ;;
200- -P)
201- arg_prefix=" ${1%/ } "
202- shift
197+ --prefix=* )
198+ arg_prefix=" ${opt#* =} "
203199 ;;
204- -m )
200+ --message= * )
205201 test -n " $allow_addmerge " || die_incompatible_opt " $opt " " $arg_command "
206- arg_addmerge_message=" $1 "
207- shift
202+ arg_addmerge_message=" ${opt#* =} "
208203 ;;
209204 --no-prefix)
210205 arg_prefix=
211206 ;;
212- --onto)
207+ --onto= * )
213208 test -n " $allow_split " || die_incompatible_opt " $opt " " $arg_command "
214- arg_split_onto=" $1 "
215- shift
209+ arg_split_onto=" ${opt#* =} "
216210 ;;
217211 --no-onto)
218212 test -n " $allow_split " || die_incompatible_opt " $opt " " $arg_command "
@@ -240,6 +234,9 @@ main () {
240234 test -n " $allow_addmerge " || die_incompatible_opt " $opt " " $arg_command "
241235 arg_addmerge_squash=
242236 ;;
237+ --gpg-sign=* | --gpg-sign | --no-gpg-sign)
238+ arg_gpg_sign=" $opt "
239+ ;;
243240 --)
244241 break
245242 ;;
@@ -272,6 +269,7 @@ main () {
272269 debug " quiet: {$arg_quiet }"
273270 debug " dir: {$dir }"
274271 debug " opts: {$* }"
272+ debug " gpg-sign: {$arg_gpg_sign }"
275273 debug
276274
277275 " cmd_$arg_command " " $@ "
@@ -537,7 +535,7 @@ copy_commit () {
537535 printf " %s" " $arg_split_annotate "
538536 cat
539537 ) |
540- git commit-tree " $2 " $3 # reads the rest of stdin
538+ git commit-tree $arg_gpg_sign " $2 " $3 # reads the rest of stdin
541539 ) || die " fatal: can't copy commit $1 "
542540}
543541
@@ -683,10 +681,10 @@ new_squash_commit () {
683681 if test -n " $old "
684682 then
685683 squash_msg " $dir " " $oldsub " " $newsub " |
686- git commit-tree " $tree " -p " $old " || exit $?
684+ git commit-tree $arg_gpg_sign " $tree " -p " $old " || exit $?
687685 else
688686 squash_msg " $dir " " " " $newsub " |
689- git commit-tree " $tree " || exit $?
687+ git commit-tree $arg_gpg_sign " $tree " || exit $?
690688 fi
691689}
692690
@@ -925,11 +923,11 @@ cmd_add_commit () {
925923 then
926924 rev=$( new_squash_commit " " " " " $rev " ) || exit $?
927925 commit=$( add_squashed_msg " $rev " " $dir " |
928- git commit-tree " $tree " $headp -p " $rev " ) || exit $?
926+ git commit-tree $arg_gpg_sign " $tree " $headp -p " $rev " ) || exit $?
929927 else
930928 revp=$( peel_committish " $rev " ) || exit $?
931929 commit=$( add_msg " $dir " $headrev " $rev " |
932- git commit-tree " $tree " $headp -p " $revp " ) || exit $?
930+ git commit-tree $arg_gpg_sign " $tree " $headp -p " $revp " ) || exit $?
933931 fi
934932 git reset " $commit " || exit $?
935933
@@ -1080,9 +1078,9 @@ cmd_merge () {
10801078 if test -n " $arg_addmerge_message "
10811079 then
10821080 git merge --no-ff -Xsubtree=" $arg_prefix " \
1083- --message=" $arg_addmerge_message " " $rev "
1081+ --message=" $arg_addmerge_message " $arg_gpg_sign " $rev "
10841082 else
1085- git merge --no-ff -Xsubtree=" $arg_prefix " $rev
1083+ git merge --no-ff -Xsubtree=" $arg_prefix " $arg_gpg_sign $ rev
10861084 fi
10871085}
10881086
0 commit comments