From: "David A. Greene" <greened@obbligato.org>
To: git@vger.kernel.org
Cc: Techlive Zheng <techlivezheng@gmail.com>,
"David A. Greene" <greened@obbligato.org>
Subject: [PATCH 2/7] contrib/subtree: Use %B for Split Subject/Body
Date: Tue, 8 Jan 2013 06:09:52 -0600 [thread overview]
Message-ID: <1357646997-28675-3-git-send-email-greened@obbligato.org> (raw)
In-Reply-To: <1357646997-28675-1-git-send-email-greened@obbligato.org>
From: Techlive Zheng <techlivezheng@gmail.com>
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>
---
contrib/subtree/git-subtree.sh | 6 +++++-
contrib/subtree/t/t7900-subtree.sh | 15 +++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 920c664..5341b36 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -296,7 +296,11 @@ copy_commit()
# We're going to set some environment vars here, so
# do it in a subshell to get rid of them safely later
debug copy_commit "{$1}" "{$2}" "{$3}"
- git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%s%n%n%b' "$1" |
+ # Use %B rather than %s%n%n%b to handle the special case of a
+ # commit that only has a subject line. We don't want to
+ # introduce a newline after the subject, causing generation of
+ # a new hash.
+ git log -1 --pretty=format:'%an%n%ae%n%ad%n%cn%n%ce%n%cd%n%B' "$1" |
(
read GIT_AUTHOR_NAME
read GIT_AUTHOR_EMAIL
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 6cf9fb9..3f17f55 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -74,6 +74,10 @@ test_expect_success 'add sub1' '
git branch -m master subproj
'
+# Save this hash for testing later.
+
+subdir_hash=`git rev-parse HEAD`
+
test_expect_success 'add sub2' '
create sub2 &&
git commit -m "sub2" &&
@@ -211,6 +215,17 @@ test_expect_success 'check split with --branch' '
check_equal ''"$(git rev-parse splitbr1)"'' "$spl1"
'
+test_expect_success 'check hash of split' '
+ spl1=$(git subtree split --prefix subdir) &&
+ undo &&
+ git subtree split --prefix subdir --branch splitbr1test &&
+ check_equal ''"$(git rev-parse splitbr1test)"'' "$spl1"
+ git checkout splitbr1test &&
+ new_hash=$(git rev-parse HEAD~2) &&
+ git checkout mainline &&
+ check_equal ''"$new_hash"'' "$subdir_hash"
+'
+
test_expect_success 'check split with --branch for an existing branch' '
spl1=''"$(git subtree split --annotate='"'*'"' --prefix subdir --onto FETCH_HEAD --message "Split & rejoin" --rejoin)"'' &&
undo &&
--
1.7.10.4
next prev parent reply other threads:[~2013-01-08 12:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 12:09 Revised git-subtree Patches David A. Greene
2013-01-08 12:09 ` [PATCH 1/7] Remove Test Number Comments David A. Greene
2013-01-08 12:09 ` David A. Greene [this message]
2013-01-08 18:29 ` [PATCH 2/7] contrib/subtree: Use %B for Split Subject/Body Junio C Hamano
2013-01-16 3:14 ` greened
2013-01-08 23:21 ` 郑文辉(Techlive Zheng)
2013-01-09 0:41 ` Junio C Hamano
2013-01-16 3:18 ` greened
2013-01-16 15:43 ` Junio C Hamano
2013-01-22 8:39 ` greened
2013-01-08 12:09 ` [PATCH 3/7] contrib/subtree: Add --unannotate David A. Greene
2013-01-08 18:45 ` Junio C Hamano
2013-01-16 3:20 ` greened
2013-01-16 4:06 ` greened
2013-01-16 4:31 ` Junio C Hamano
2013-01-22 8:37 ` greened
2013-01-08 12:09 ` [PATCH 4/7] contrib/subtree: Better Error Handling for add David A. Greene
2013-01-08 18:45 ` Junio C Hamano
2013-01-16 3:21 ` greened
2013-01-08 12:09 ` [PATCH 5/7] contrib/subtree: Fix Synopsis David A. Greene
2013-01-08 12:09 ` [PATCH 6/7] contrib/subtree: Honor DESTDIR David A. Greene
2013-01-08 12:09 ` [PATCH 7/7] contrib/subtree: Make the Manual Directory if Needed David A. Greene
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1357646997-28675-3-git-send-email-greened@obbligato.org \
--to=greened@obbligato.org \
--cc=git@vger.kernel.org \
--cc=techlivezheng@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).