diff mbox series

[2/8] merge-tree: move logic for existing merge into new function

Message ID 9da8e77c1d7c3645fdad74080c0093f420dcfef4.1640927044.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series RFC: Server side merges (no ref updating, no commit creating, no touching worktree or index) | expand

Commit Message

Elijah Newren Dec. 31, 2021, 5:03 a.m. UTC
From: Elijah Newren <newren@gmail.com>

In preparation for adding a non-trivial merge capability to merge-tree,
move the existing merge logic for trivial merges into a new function.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/merge-tree.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Johannes Altmanninger Jan. 1, 2022, 8:11 p.m. UTC | #1
On Fri, Dec 31, 2021 at 05:03:58AM +0000, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail.com>
> 
> In preparation for adding a non-trivial merge capability to merge-tree,
> move the existing merge logic for trivial merges into a new function.
> 
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  builtin/merge-tree.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
> index 06f9eee9f78..9fe5b99f623 100644
> --- a/builtin/merge-tree.c
> +++ b/builtin/merge-tree.c
> @@ -366,15 +366,11 @@ static void *get_tree_descriptor(struct repository *r,
>  	return buf;
>  }
>  
> -int cmd_merge_tree(int argc, const char **argv, const char *prefix)
> -{
> +static int trivial_merge(int argc, const char **argv) {

I guess the brace should probably stay on its own line
Elijah Newren Jan. 1, 2022, 8:17 p.m. UTC | #2
On Sat, Jan 1, 2022 at 12:11 PM Johannes Altmanninger <aclopte@gmail.com> wrote:
>
> On Fri, Dec 31, 2021 at 05:03:58AM +0000, Elijah Newren via GitGitGadget wrote:
> > From: Elijah Newren <newren@gmail.com>
> >
> > In preparation for adding a non-trivial merge capability to merge-tree,
> > move the existing merge logic for trivial merges into a new function.
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> >  builtin/merge-tree.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
> > index 06f9eee9f78..9fe5b99f623 100644
> > --- a/builtin/merge-tree.c
> > +++ b/builtin/merge-tree.c
> > @@ -366,15 +366,11 @@ static void *get_tree_descriptor(struct repository *r,
> >       return buf;
> >  }
> >
> > -int cmd_merge_tree(int argc, const char **argv, const char *prefix)
> > -{
> > +static int trivial_merge(int argc, const char **argv) {
>
> I guess the brace should probably stay on its own line

Whoops, indeed.  Thanks for spotting.
diff mbox series

Patch

diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 06f9eee9f78..9fe5b99f623 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -366,15 +366,11 @@  static void *get_tree_descriptor(struct repository *r,
 	return buf;
 }
 
-int cmd_merge_tree(int argc, const char **argv, const char *prefix)
-{
+static int trivial_merge(int argc, const char **argv) {
 	struct repository *r = the_repository;
 	struct tree_desc t[3];
 	void *buf1, *buf2, *buf3;
 
-	if (argc != 4)
-		usage(merge_tree_usage);
-
 	buf1 = get_tree_descriptor(r, t+0, argv[1]);
 	buf2 = get_tree_descriptor(r, t+1, argv[2]);
 	buf3 = get_tree_descriptor(r, t+2, argv[3]);
@@ -386,3 +382,10 @@  int cmd_merge_tree(int argc, const char **argv, const char *prefix)
 	show_result();
 	return 0;
 }
+
+int cmd_merge_tree(int argc, const char **argv, const char *prefix)
+{
+	if (argc != 4)
+		usage(merge_tree_usage);
+	return trivial_merge(argc, argv);
+}