Skip to content

Commit a5b8e28

Browse files
weynhamzgitster
authored andcommitted
contrib/subtree: use %B for split subject/body
Use %B to format the commit message and body to avoid an extra newline if a commit only has a subject line. Signed-off-by: Techlive Zheng <techlivezheng@gmail.com> Signed-off-by: David A. Greene <greened@obbligato.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 144797d commit a5b8e28

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ copy_commit()
296296
# We're going to set some environment vars here, so
297297
# do it in a subshell to get rid of them safely later
298298
debug copy_commit "{$1}" "{$2}" "{$3}"
299-
git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' "$1" |
299+
git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' "$1" |
300300
(
301301
read GIT_AUTHOR_NAME
302302
read GIT_AUTHOR_EMAIL

contrib/subtree/t/t7900-subtree.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ test_expect_success 'add sub1' '
7474
git branch -m master subproj
7575
'
7676

77+
# Save this hash for testing later.
78+
79+
subdir_hash=`git rev-parse HEAD`
80+
7781
test_expect_success 'add sub2' '
7882
create sub2 &&
7983
git commit -m "sub2" &&
@@ -205,10 +209,21 @@ test_expect_success 'check if --message works for split+rejoin' '
205209
'
206210

207211
test_expect_success 'check split with --branch' '
208-
spl1=$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
209-
undo &&
210-
git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&
211-
check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
212+
spl1=$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin) &&
213+
undo &&
214+
git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --branch splitbr1 &&
215+
check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
216+
'
217+
218+
test_expect_success 'check hash of split' '
219+
spl1=$(git subtree split --prefix subdir) &&
220+
undo &&
221+
git subtree split --prefix subdir --branch splitbr1test &&
222+
check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1"
223+
git checkout splitbr1test &&
224+
new_hash=$(git rev-parse HEAD~2) &&
225+
git checkout mainline &&
226+
check_equal ''"$new_hash"'' "$subdir_hash"
212227
'
213228

214229
test_expect_success 'check split with --branch for an existing branch' '

0 commit comments

Comments
 (0)