* [PATCH] contrib/subtree: add "--no-commit" flag for merge and pull
@ 2017-03-26 7:02 Mike Lewis
2017-03-29 7:37 ` David Aguilar
0 siblings, 1 reply; 3+ messages in thread
From: Mike Lewis @ 2017-03-26 7:02 UTC (permalink / raw)
To: git
Cc: David A . Greene, Techlive Zheng, James Denholm, David Aguilar,
Charles Bailey, Mike Lewis
Allows the user to verify and/or change the contents of the merge
before committing as necessary
Signed-off-by: Mike Lewis <mike@mplew.is>
---
contrib/subtree/git-subtree.sh | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index dec085a23..c30087485 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -29,6 +29,8 @@ onto= try connecting new tree to an existing one
rejoin merge the new branch back into HEAD
options for 'add', 'merge', and 'pull'
squash merge subtree changes as a single commit
+ options for 'merge' and 'pull'
+no-commit perform the merge, but don't commit
"
eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
@@ -48,6 +50,7 @@ annotate=
squash=
message=
prefix=
+commit_option="--commit"
debug () {
if test -n "$debug"
@@ -137,6 +140,12 @@ do
--no-squash)
squash=
;;
+ --no-commit)
+ commit_option="--no-commit"
+ ;;
+ --no-no-commit)
+ commit_option="--commit"
+ ;;
--)
break
;;
@@ -815,17 +824,17 @@ cmd_merge () {
then
if test -n "$message"
then
- git merge -s subtree --message="$message" "$rev"
+ git merge -s subtree --message="$message" "$commit_option" "$rev"
else
- git merge -s subtree "$rev"
+ git merge -s subtree "$commit_option" "$rev"
fi
else
if test -n "$message"
then
git merge -Xsubtree="$prefix" \
- --message="$message" "$rev"
+ --message="$message" "$commit_option" "$rev"
else
- git merge -Xsubtree="$prefix" $rev
+ git merge -Xsubtree="$prefix" "$commit_option" $rev
fi
fi
}
--
2.12.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] contrib/subtree: add "--no-commit" flag for merge and pull
2017-03-26 7:02 [PATCH] contrib/subtree: add "--no-commit" flag for merge and pull Mike Lewis
@ 2017-03-29 7:37 ` David Aguilar
2017-03-29 7:56 ` Mike Lewis
0 siblings, 1 reply; 3+ messages in thread
From: David Aguilar @ 2017-03-29 7:37 UTC (permalink / raw)
To: Mike Lewis
Cc: git, David A . Greene, Techlive Zheng, James Denholm,
Charles Bailey
On Sun, Mar 26, 2017 at 03:02:38AM -0400, Mike Lewis wrote:
> Allows the user to verify and/or change the contents of the merge
> before committing as necessary
>
> Signed-off-by: Mike Lewis <mike@mplew.is>
> ---
> contrib/subtree/git-subtree.sh | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
> index dec085a23..c30087485 100755
> --- a/contrib/subtree/git-subtree.sh
> +++ b/contrib/subtree/git-subtree.sh
> @@ -29,6 +29,8 @@ onto= try connecting new tree to an existing one
> rejoin merge the new branch back into HEAD
> options for 'add', 'merge', and 'pull'
> squash merge subtree changes as a single commit
> + options for 'merge' and 'pull'
> +no-commit perform the merge, but don't commit
> "
> eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
>
> @@ -48,6 +50,7 @@ annotate=
> squash=
> message=
> prefix=
> +commit_option="--commit"
It might be simpler to default commit_option= empty like the others, and
remove the "" double quotes around "$commit_option" indicated below so
that the shell ignores it when it's empty.
>
> debug () {
> if test -n "$debug"
> @@ -137,6 +140,12 @@ do
> --no-squash)
> squash=
> ;;
> + --no-commit)
> + commit_option="--no-commit"
> + ;;
> + --no-no-commit)
> + commit_option="--commit"
> + ;;
"--no-no-commit" should just be "--commit" instead.
The real flag is called "--commit" (git help merge), so subtree
should follow suite by supporting "--commit" and "--no-commit" only.
> @@ -815,17 +824,17 @@ cmd_merge () {
> then
> if test -n "$message"
> then
> - git merge -s subtree --message="$message" "$rev"
> + git merge -s subtree --message="$message" "$commit_option" "$rev"
^ ^
> else
> - git merge -s subtree "$rev"
> + git merge -s subtree "$commit_option" "$rev"
^ ^
> fi
> [...]
--
David
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] contrib/subtree: add "--no-commit" flag for merge and pull
2017-03-29 7:37 ` David Aguilar
@ 2017-03-29 7:56 ` Mike Lewis
0 siblings, 0 replies; 3+ messages in thread
From: Mike Lewis @ 2017-03-29 7:56 UTC (permalink / raw)
To: David Aguilar
Cc: Mike Lewis, git, David A . Greene, Techlive Zheng, James Denholm,
Charles Bailey
I had defaulted it to "--commit" just to make it absolutely clear what the default was going to be, since passing the "--commit" flag to `git-merge` in this case doesn’t change the existing behavior. But you’re right that having the default be blank matches the existing style better, so I’ll make a new patch.
Regarding the "--no-no-commit" I definitely agree it should be that way, and my first attempt at this had it that way. However, `git rev-parse --parseopt` seems to rewrite "--commit" to "--no-no-commit" when it detects the "no-commit" option in the $OPTS_SPEC variable. Essentially, you still type the argument as "--commit", but it’s rewritten to "--no-no-commit" before it gets to the argument case block, as "no-commit" is the only documented option. Documenting both the "--commit" and "--no-commit" options in $OPTS_SPEC leads to the expected resulting argument, but I wasn't sure if both arguments should be documented, as none of the other "default" options (for instance, "--no-squash") are documented in the help output. But please let me know what your thoughts are, and I'll gladly update my patch.
Mike Lewis
> On 29 Mar 2017, at 03:37, David Aguilar <davvid@gmail.com> wrote:
>
> On Sun, Mar 26, 2017 at 03:02:38AM -0400, Mike Lewis wrote:
>> Allows the user to verify and/or change the contents of the merge
>> before committing as necessary
>>
>> Signed-off-by: Mike Lewis <mike@mplew.is>
>> ---
>> contrib/subtree/git-subtree.sh | 17 +++++++++++++----
>> 1 file changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
>> index dec085a23..c30087485 100755
>> --- a/contrib/subtree/git-subtree.sh
>> +++ b/contrib/subtree/git-subtree.sh
>> @@ -29,6 +29,8 @@ onto= try connecting new tree to an existing one
>> rejoin merge the new branch back into HEAD
>> options for 'add', 'merge', and 'pull'
>> squash merge subtree changes as a single commit
>> + options for 'merge' and 'pull'
>> +no-commit perform the merge, but don't commit
>> "
>> eval "$(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)"
>>
>> @@ -48,6 +50,7 @@ annotate=
>> squash=
>> message=
>> prefix=
>> +commit_option="--commit"
>
> It might be simpler to default commit_option= empty like the others, and
> remove the "" double quotes around "$commit_option" indicated below so
> that the shell ignores it when it's empty.
>
>>
>> debug () {
>> if test -n "$debug"
>> @@ -137,6 +140,12 @@ do
>> --no-squash)
>> squash=
>> ;;
>> + --no-commit)
>> + commit_option="--no-commit"
>> + ;;
>> + --no-no-commit)
>> + commit_option="--commit"
>> + ;;
>
> "--no-no-commit" should just be "--commit" instead.
> The real flag is called "--commit" (git help merge), so subtree
> should follow suite by supporting "--commit" and "--no-commit" only.
>
>
>> @@ -815,17 +824,17 @@ cmd_merge () {
>> then
>> if test -n "$message"
>> then
>> - git merge -s subtree --message="$message" "$rev"
>> + git merge -s subtree --message="$message" "$commit_option" "$rev"
> ^ ^
>> else
>> - git merge -s subtree "$rev"
>> + git merge -s subtree "$commit_option" "$rev"
> ^ ^
>> fi
>> [...]
>
> --
> David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-29 7:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-26 7:02 [PATCH] contrib/subtree: add "--no-commit" flag for merge and pull Mike Lewis
2017-03-29 7:37 ` David Aguilar
2017-03-29 7:56 ` Mike Lewis
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).