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>
Techlive Zheng committed
Feb 4, 2013 at 22:06 UTC
a5b8e28e4eb5762c9da68b56efdf45d6c885bd56
2 files changed
+20
-5
contrib/subtree/git-subtree.sh
+1
-1
@@ -296,7 +296,7 @@ copy_commit()
296
# We're going to set some environment vars here, so
297
# do it in a subshell to get rid of them safely later
298
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" |
300
(
301
read GIT_AUTHOR_NAME
302
read GIT_AUTHOR_EMAIL
contrib/subtree/t/t7900-subtree.sh
+19
-4
@@ -74,6 +74,10 @@ test_expect_success 'add sub1' '
74
git branch -m master subproj
75
'
76
77
+# Save this hash for testing later.
78
+
79
+subdir_hash=`git rev-parse HEAD`
80
+
81
test_expect_success 'add sub2' '
82
create sub2 &&
83
git commit -m "sub2" &&
@@ -205,10 +209,21 @@ test_expect_success 'check if --message works for split+rejoin' '
209
'
210
211
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"
227
'
228
229
test_expect_success 'check split with --branch for an existing branch' '