diff mbox series

[6/8] merge-ort: allow update messages to be written to different file stream

Message ID 32ad5b5c10da7204dc4a2d3ca74f8d73745925a7.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:04 a.m. UTC
From: Elijah Newren <newren@gmail.com>

This modifies the new display_update_messages() function to allow
printing to somewhere other than stdout.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 merge-ort.c | 7 +++++--
 merge-ort.h | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

Comments

Johannes Altmanninger Jan. 1, 2022, 8:08 p.m. UTC | #1
On Fri, Dec 31, 2021 at 05:04:02AM +0000, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail.com>
> 
> This modifies the new display_update_messages() function to allow
> printing to somewhere other than stdout.
> 
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  merge-ort.c | 7 +++++--
>  merge-ort.h | 3 ++-
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/merge-ort.c b/merge-ort.c
> index 6237e2fb7fe..86eebf39166 100644
> --- a/merge-ort.c
> +++ b/merge-ort.c
> [...]
> @@ -4271,6 +4272,8 @@ void merge_switch_to_result(struct merge_options *opt,
>  		trace2_region_leave("merge", "write_auto_merge", opt->repo);
>  	}
>  
> +	if (display_update_msgs)
> +		merge_display_update_messages(opt, result, stdout);

is it intentional that the previous patch doesn't have this call?
Elijah Newren Jan. 1, 2022, 8:19 p.m. UTC | #2
On Sat, Jan 1, 2022 at 12:08 PM Johannes Altmanninger <aclopte@gmail.com> wrote:
>
> On Fri, Dec 31, 2021 at 05:04:02AM +0000, Elijah Newren via GitGitGadget wrote:
> > From: Elijah Newren <newren@gmail.com>
> >
> > This modifies the new display_update_messages() function to allow
> > printing to somewhere other than stdout.
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> >  merge-ort.c | 7 +++++--
> >  merge-ort.h | 3 ++-
> >  2 files changed, 7 insertions(+), 3 deletions(-)
> >
> > diff --git a/merge-ort.c b/merge-ort.c
> > index 6237e2fb7fe..86eebf39166 100644
> > --- a/merge-ort.c
> > +++ b/merge-ort.c
> > [...]
> > @@ -4271,6 +4272,8 @@ void merge_switch_to_result(struct merge_options *opt,
> >               trace2_region_leave("merge", "write_auto_merge", opt->repo);
> >       }
> >
> > +     if (display_update_msgs)
> > +             merge_display_update_messages(opt, result, stdout);
>
> is it intentional that the previous patch doesn't have this call?

Ugh, oops.  Yeah, bad split of the patches; this should have been part
of the previous one.
diff mbox series

Patch

diff --git a/merge-ort.c b/merge-ort.c
index 6237e2fb7fe..86eebf39166 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -4198,7 +4198,8 @@  static int record_conflicted_index_entries(struct merge_options *opt)
 }
 
 void merge_display_update_messages(struct merge_options *opt,
-				   struct merge_result *result)
+				   struct merge_result *result,
+				   FILE *stream)
 {
 	struct merge_options_internal *opti = result->priv;
 	struct hashmap_iter iter;
@@ -4222,7 +4223,7 @@  void merge_display_update_messages(struct merge_options *opt,
 	for (i = 0; i < olist.nr; ++i) {
 		struct strbuf *sb = olist.items[i].util;
 
-		printf("%s", sb->buf);
+		fprintf(stream, "%s", sb->buf);
 	}
 	string_list_clear(&olist, 0);
 
@@ -4271,6 +4272,8 @@  void merge_switch_to_result(struct merge_options *opt,
 		trace2_region_leave("merge", "write_auto_merge", opt->repo);
 	}
 
+	if (display_update_msgs)
+		merge_display_update_messages(opt, result, stdout);
 
 	merge_finalize(opt, result);
 }
diff --git a/merge-ort.h b/merge-ort.h
index 1b93555a60b..55819a57da8 100644
--- a/merge-ort.h
+++ b/merge-ort.h
@@ -76,7 +76,8 @@  void merge_switch_to_result(struct merge_options *opt,
  * so only call this when bypassing merge_switch_to_result().
  */
 void merge_display_update_messages(struct merge_options *opt,
-				   struct merge_result *result);
+				   struct merge_result *result,
+				   FILE *stream);
 
 /* Do needed cleanup when not calling merge_switch_to_result() */
 void merge_finalize(struct merge_options *opt,