From: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
To: git@vger.kernel.org
Cc: greened@obbligato.org, amdmi3@amdmi3.ru, john@keeping.me.uk,
techlivezheng@gmail.com, apenwarr@gmail.com,
Matthew Ogilvie <mmogilvi_git@miniinfo.net>
Subject: [PATCH 3/4] subtree: add --edit option
Date: Sat, 7 Dec 2013 11:21:24 -0700 [thread overview]
Message-ID: <1386440485-3092-3-git-send-email-mmogilvi_git@miniinfo.net> (raw)
In-Reply-To: <1386440485-3092-1-git-send-email-mmogilvi_git@miniinfo.net>
Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
---
contrib/subtree/git-subtree.sh | 37 +++++++++++++++++++++++++++++--------
contrib/subtree/git-subtree.txt | 4 ++++
2 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 56d915f..ac82b4d 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -21,6 +21,7 @@ d show debug messages
P,prefix= the name of the subdir to split out
m,message= use the given message as the commit message for the merge commit
squash merge subtree changes as a single commit
+edit allow user to edit squash commit message interactively
options for 'split'
annotate= add a prefix to commit message of new commits
b,branch= create a new branch from the split subtree
@@ -45,6 +46,7 @@ ignore_joins=
annotate=
squash=
message=
+edit=
debug()
{
@@ -91,6 +93,7 @@ while [ $# -gt 0 ]; do
--ignore-joins) ignore_joins=1 ;;
--no-ignore-joins) ignore_joins= ;;
--squash) squash=1 ;;
+ --edit) edit=1 ;;
--no-squash) squash= ;;
--) break ;;
*) die "Unexpected option: $opt" ;;
@@ -434,13 +437,12 @@ new_squash_commit()
old="$1"
oldsub="$2"
newsub="$3"
+ msg_file="$4"
tree=$(toptree_for_commit $newsub) || exit $?
if [ -n "$old" ]; then
- squash_msg "$dir" "$oldsub" "$newsub" |
- git commit-tree "$tree" -p "$old" || exit $?
+ git commit-tree "$tree" -p "$old" -F "$msg_file" || exit $?
else
- squash_msg "$dir" "" "$newsub" |
- git commit-tree "$tree" || exit $?
+ git commit-tree "$tree" -F "$msg_file" || exit $?
fi
}
@@ -556,7 +558,13 @@ cmd_add_commit()
fi
if [ -n "$squash" ]; then
- rev=$(new_squash_commit "" "" "$rev") || exit $?
+ msg_file="$GIT_DIR/COMMIT_EDITMSG"
+ squash_msg "$dir" "" "$rev" >"$msg_file"
+ if [ -n "$edit" ]; then
+ git_editor "$msg_file"
+ fi
+ rev=$(new_squash_commit "" "" "$rev" "$msg_file") || exit $?
+ rm -f "$msg_file"
commit=$(add_squashed_msg "$rev" "$dir" |
git commit-tree $tree $headp -p "$rev") || exit $?
else
@@ -672,8 +680,14 @@ cmd_split()
say "Subtree is already at commit $latest_new."
exit 0
fi
- new=$(new_squash_commit "$old" "$sub" "$latest_new") \
- || exit $?
+ msg_file="$GIT_DIR/COMMIT_EDITMSG"
+ squash_msg "$dir" "$sub" "$latest_new" >"$msg_file"
+ if [ -n "$edit" ]; then
+ git_editor "$msg_file"
+ fi
+ new=$(new_squash_commit "$old" "$sub" "$latest_new" \
+ "$msg_file") || exit $?
+ rm -f "$msg_file"
debug "New squash commit: $new"
fi
@@ -708,7 +722,13 @@ cmd_merge()
say "Subtree is already at commit $rev."
exit 0
fi
- new=$(new_squash_commit "$old" "$sub" "$rev") || exit $?
+ msg_file="$GIT_DIR/COMMIT_EDITMSG"
+ squash_msg "$dir" "$sub" "$rev" >"$msg_file"
+ if [ -n "$edit" ]; then
+ git_editor "$msg_file"
+ fi
+ new=$(new_squash_commit "$old" "$sub" "$rev" "$msg_file") || exit $?
+ rm -f "$msg_file"
debug "New squash commit: $new"
rev="$new"
fi
@@ -748,6 +768,7 @@ cmd_push()
if [ -n "$squash" ]; then
opts="-squash"
fi
+ # Can't easily pass on --edit because of stdout capture redirection
if [ -e "$dir" ]; then
repository=$1
diff --git a/contrib/subtree/git-subtree.txt b/contrib/subtree/git-subtree.txt
index 03092bc..16525d4 100644
--- a/contrib/subtree/git-subtree.txt
+++ b/contrib/subtree/git-subtree.txt
@@ -177,6 +177,10 @@ OPTIONS
the merge back to the mainline, not the synthetic subtree
history.
+--edit::
+ When used with '--squash', bring up an editor on the squash
+ commit message, to allow customizing it.
+
OPTIONS FOR split
-----------------
--
1.8.3.2
next prev parent reply other threads:[~2013-12-07 18:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-23 20:18 [PATCH] subtree: add squash handling for split and push Pierre Penninckx
2013-11-28 18:23 ` Matthew Ogilvie
2013-11-28 22:58 ` Pierre Penninckx
2013-12-07 18:21 ` [PATCH 1/4] subtree: support split --rejoin --squash Matthew Ogilvie
2013-12-07 18:21 ` [PATCH 2/4] subtree: allow --squash and --message with push Matthew Ogilvie
2013-12-07 18:21 ` Matthew Ogilvie [this message]
2013-12-07 18:21 ` [PATCH/BAD 4/4] subtree: poor bugfix for split new commits with parents before previous split Matthew Ogilvie
2013-12-10 22:46 ` [PATCH 1/4] subtree: support split --rejoin --squash Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386440485-3092-3-git-send-email-mmogilvi_git@miniinfo.net \
--to=mmogilvi_git@miniinfo.net \
--cc=amdmi3@amdmi3.ru \
--cc=apenwarr@gmail.com \
--cc=git@vger.kernel.org \
--cc=greened@obbligato.org \
--cc=john@keeping.me.uk \
--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.
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 NNTP newsgroup(s).