Re: [RFC/PATCH] merge: Add '--continue' option as a synonym for 'git commit'

2016-12-13 Thread Chris Packham
On Mon, Dec 12, 2016 at 10:02 PM, Markus Hitter  wrote:
> Am 12.12.2016 um 09:34 schrieb Chris Packham:
>> Teach 'git merge' the --continue option which allows 'continuing' a
>> merge by completing it. The traditional way of completing a merge after
>> resolving conflicts is to use 'git commit'. Now with commands like 'git
>> rebase' and 'git cherry-pick' having a '--continue' option adding such
>> an option to 'git merge' presents a consistent UI.
>
> Like.
>
> While Junio is entirely right that this is redundant, the inner workings of 
> Git are just voodoo for a (guessed) 95% of users out there, so a consistent 
> UI is important.
>
>>  DESCRIPTION
>>  ---
>> @@ -61,6 +62,9 @@ reconstruct the original (pre-merge) changes. Therefore:
>>  discouraged: while possible, it may leave you in a state that is hard to
>>  back out of in the case of a conflict.
>>
>> +The fourth syntax ("`git merge --continue`") can only be run after the
>> +merge has resulted in conflicts. 'git merge --continue' will take the
>> +currently staged changes and complete the merge.
>
> I think this should mention the equivalence to 'git commit'.
>

It is mentioned in the OPTIONS section where the --continue option is
documented. I could move it here but the OPTIONS section is where the
--abort synonym also has a reference to git reset --merge.

>
> Markus
>
> --
> - - - - - - - - - - - - - - - - - - -
> Dipl. Ing. (FH) Markus Hitter
> http://www.jump-ing.de/


Re: [RFC/PATCH] merge: Add '--continue' option as a synonym for 'git commit'

2016-12-12 Thread Jeff King
On Mon, Dec 12, 2016 at 09:34:13PM +1300, Chris Packham wrote:

> Teach 'git merge' the --continue option which allows 'continuing' a
> merge by completing it. The traditional way of completing a merge after
> resolving conflicts is to use 'git commit'. Now with commands like 'git
> rebase' and 'git cherry-pick' having a '--continue' option adding such
> an option to 'git merge' presents a consistent UI.
> 
> Signed-off-by: Chris Packham 
> ---
> So here is a quick patch that adds the --continue option. I need to add
> some tests (suggestions for where to start are welcome).

I'm not sure if there's much to test besides concluding a successful
merge, and possibly some error cases where --continue should complain.
Probably that could go at the end of t7600.

> @@ -1166,6 +1169,18 @@ int cmd_merge(int argc, const char **argv, const char 
> *prefix)
>   goto done;
>   }
>  
> + if (continue_current_merge) {
> + int nargc = 1;
> + const char *nargv[] = {"commit", NULL};
> +
> + if (!file_exists(git_path_merge_head()))
> + die(_("There is no merge in progress (MERGE_HEAD 
> missing)."));
> +
> + /* Invoke 'git commit' */
> + ret = cmd_commit(nargc, nargv, prefix);
> + goto done;
> + }
> +

I know this block is just adapted from the "--abort" one above, but
should both of these complain when other arguments are given? I can't
imagine what the user might mean with "git merge --no-commit
--continue", but probably it should be an error.  :)

-Peff


Re: [RFC/PATCH] merge: Add '--continue' option as a synonym for 'git commit'

2016-12-12 Thread Markus Hitter
Am 12.12.2016 um 09:34 schrieb Chris Packham:
> Teach 'git merge' the --continue option which allows 'continuing' a
> merge by completing it. The traditional way of completing a merge after
> resolving conflicts is to use 'git commit'. Now with commands like 'git
> rebase' and 'git cherry-pick' having a '--continue' option adding such
> an option to 'git merge' presents a consistent UI.

Like.

While Junio is entirely right that this is redundant, the inner workings of Git 
are just voodoo for a (guessed) 95% of users out there, so a consistent UI is 
important.

>  DESCRIPTION
>  ---
> @@ -61,6 +62,9 @@ reconstruct the original (pre-merge) changes. Therefore:
>  discouraged: while possible, it may leave you in a state that is hard to
>  back out of in the case of a conflict.
>  
> +The fourth syntax ("`git merge --continue`") can only be run after the
> +merge has resulted in conflicts. 'git merge --continue' will take the
> +currently staged changes and complete the merge.

I think this should mention the equivalence to 'git commit'.


Markus

-- 
- - - - - - - - - - - - - - - - - - -
Dipl. Ing. (FH) Markus Hitter
http://www.jump-ing.de/


[RFC/PATCH] merge: Add '--continue' option as a synonym for 'git commit'

2016-12-12 Thread Chris Packham
Teach 'git merge' the --continue option which allows 'continuing' a
merge by completing it. The traditional way of completing a merge after
resolving conflicts is to use 'git commit'. Now with commands like 'git
rebase' and 'git cherry-pick' having a '--continue' option adding such
an option to 'git merge' presents a consistent UI.

Signed-off-by: Chris Packham 
---
So here is a quick patch that adds the --continue option. I need to add
some tests (suggestions for where to start are welcome).

 Documentation/git-merge.txt | 13 -
 builtin/merge.c | 17 -
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index b758d5556..765b0f26e 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -15,6 +15,7 @@ SYNOPSIS
[--[no-]rerere-autoupdate] [-m ] [...]
 'git merge'  HEAD ...
 'git merge' --abort
+'git merge' --continue
 
 DESCRIPTION
 ---
@@ -61,6 +62,9 @@ reconstruct the original (pre-merge) changes. Therefore:
 discouraged: while possible, it may leave you in a state that is hard to
 back out of in the case of a conflict.
 
+The fourth syntax ("`git merge --continue`") can only be run after the
+merge has resulted in conflicts. 'git merge --continue' will take the
+currently staged changes and complete the merge.
 
 OPTIONS
 ---
@@ -99,6 +103,12 @@ commit or stash your changes before running 'git merge'.
 'git merge --abort' is equivalent to 'git reset --merge' when
 `MERGE_HEAD` is present.
 
+--continue::
+   Take the currently staged changes and complete the merge.
++
+'git merge --continue' is equivalent to 'git commit' when
+`MERGE_HEAD` is present.
+
 ...::
Commits, usually other branch heads, to merge into our branch.
Specifying more than one commit will create a merge with
@@ -277,7 +287,8 @@ After seeing a conflict, you can do two things:
 
  * Resolve the conflicts.  Git will mark the conflicts in
the working tree.  Edit the files into shape and
-   'git add' them to the index.  Use 'git commit' to seal the deal.
+   'git add' them to the index.  Use 'git merge --continue' to seal the
+   deal.
 
 You can work through the conflict with a number of tools:
 
diff --git a/builtin/merge.c b/builtin/merge.c
index b65eeaa87..1ce18cbbe 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -65,6 +65,7 @@ static int option_renormalize;
 static int verbosity;
 static int allow_rerere_auto;
 static int abort_current_merge;
+static int continue_current_merge;
 static int allow_unrelated_histories;
 static int show_progress = -1;
 static int default_to_upstream = 1;
@@ -223,6 +224,8 @@ static struct option builtin_merge_options[] = {
OPT__VERBOSITY(),
OPT_BOOL(0, "abort", _current_merge,
N_("abort the current in-progress merge")),
+   OPT_BOOL(0, "continue", _current_merge,
+   N_("continue the current in-progress merge")),
OPT_BOOL(0, "allow-unrelated-histories", _unrelated_histories,
 N_("allow merging unrelated histories")),
OPT_SET_INT(0, "progress", _progress, N_("force progress 
reporting"), 1),
@@ -739,7 +742,7 @@ static void abort_commit(struct commit_list *remoteheads, 
const char *err_msg)
if (err_msg)
error("%s", err_msg);
fprintf(stderr,
-   _("Not committing merge; use 'git commit' to complete the 
merge.\n"));
+   _("Not committing merge; use 'git merge --continue' to complete 
the merge.\n"));
write_merge_state(remoteheads);
exit(1);
 }
@@ -1166,6 +1169,18 @@ int cmd_merge(int argc, const char **argv, const char 
*prefix)
goto done;
}
 
+   if (continue_current_merge) {
+   int nargc = 1;
+   const char *nargv[] = {"commit", NULL};
+
+   if (!file_exists(git_path_merge_head()))
+   die(_("There is no merge in progress (MERGE_HEAD 
missing)."));
+
+   /* Invoke 'git commit' */
+   ret = cmd_commit(nargc, nargv, prefix);
+   goto done;
+   }
+
if (read_cache_unmerged())
die_resolve_conflict("merge");
 
-- 
2.11.0