git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Denton Liu <liu.denton@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Elijah Newren <newren@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Beat Bolli <dev+git@drbeat.li>, Pavel Roskin <plroskin@gmail.com>
Subject: [PATCH 2/5] notes: create init_display_notes() helper
Date: Mon, 9 Dec 2019 05:10:41 -0800	[thread overview]
Message-ID: <bb66c95f43e2cb727a9aafbce8c70f25df513a13.1575896661.git.liu.denton@gmail.com> (raw)
In-Reply-To: <cover.1575896661.git.liu.denton@gmail.com>

We currently open code the initialization for revs->notes_opt. Abstract
this away into a helper function so that the logic can be reused in a
future commit.

This is slightly wasteful as we memset the struct twice but this is only
run once so it shouldn't have any major effect.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 notes.c    | 6 ++++++
 notes.h    | 5 +++++
 revision.c | 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/notes.c b/notes.c
index fd6cef14a3..53d1e7767c 100644
--- a/notes.c
+++ b/notes.c
@@ -1039,6 +1039,12 @@ struct notes_tree **load_notes_trees(struct string_list *refs, int flags)
 	return trees;
 }
 
+void init_display_notes(struct display_notes_opt *opt)
+{
+	memset(opt, 0, sizeof(*opt));
+	opt->use_default_notes = -1;
+}
+
 void load_display_notes(struct display_notes_opt *opt)
 {
 	char *display_ref_env;
diff --git a/notes.h b/notes.h
index 1ce528442a..c0b712371c 100644
--- a/notes.h
+++ b/notes.h
@@ -260,6 +260,11 @@ struct display_notes_opt {
 	struct string_list extra_notes_refs;
 };
 
+/*
+ * Initialize a display_notes_opt to its default value.
+ */
+void init_display_notes(struct display_notes_opt *opt);
+
 /*
  * Load the notes machinery for displaying several notes trees.
  *
diff --git a/revision.c b/revision.c
index d4aaf0ef25..24ad974590 100644
--- a/revision.c
+++ b/revision.c
@@ -1637,7 +1637,7 @@ void repo_init_revisions(struct repository *r,
 		revs->diffopt.prefix_length = strlen(prefix);
 	}
 
-	revs->notes_opt.use_default_notes = -1;
+	init_display_notes(&revs->notes_opt);
 }
 
 static void add_pending_commit_list(struct rev_info *revs,
-- 
2.24.0.627.geba02921db


  parent reply	other threads:[~2019-12-09 13:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 13:10 [PATCH 0/5] format-patch: improve handling of `format.notes` Denton Liu
2019-12-09 13:10 ` [PATCH 1/5] notes: rename to load_display_notes() Denton Liu
2019-12-09 13:10 ` Denton Liu [this message]
2019-12-09 13:10 ` [PATCH 3/5] notes: extract logic into set_display_notes() Denton Liu
2019-12-09 16:26   ` Eric Sunshine
2019-12-09 19:19     ` Denton Liu
2019-12-10 11:22       ` Philip Oakley
2019-12-09 13:10 ` [PATCH 4/5] format-patch: use --notes behavior for format.notes Denton Liu
2019-12-09 13:10 ` [PATCH 5/5] format-patch: move git_config() before repo_init_revisions() Denton Liu
2019-12-09 21:36 ` [PATCH 0/5] format-patch: improve handling of `format.notes` Junio C Hamano
2019-12-09 21:42 ` Elijah Newren

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb66c95f43e2cb727a9aafbce8c70f25df513a13.1575896661.git.liu.denton@gmail.com \
    --to=liu.denton@gmail.com \
    --cc=dev+git@drbeat.li \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newren@gmail.com \
    --cc=plroskin@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.
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).