git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Hariom Verma via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Hariom Verma <hariom18599@gmail.com>,
	Hariom Verma <hariom18599@gmail.com>
Subject: [PATCH 4/5] ref_format: add option to skip `\n` at eol
Date: Mon, 15 Jun 2020 10:57:41 +0000	[thread overview]
Message-ID: <0eecb653d21355d7d2ab3dd209cfdb3c24365417.1592218662.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.658.git.1592218662.gitgitgadget@gmail.com>

From: Hariom Verma <hariom18599@gmail.com>

We might always need a `\n` at end of line in the case of
`git for-each-ref`. But as we intend to use ref-filter's logic
in pretty, having an option to skip `\n` will be useful.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Hariom Verma <hariom18599@gmail.com>
---
 ref-filter.c | 3 ++-
 ref-filter.h | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ref-filter.c b/ref-filter.c
index bf7b70299b4..0e2fecbda4c 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2410,7 +2410,8 @@ void show_ref_array_item(struct ref_array_item *info,
 	fwrite(final_buf.buf, 1, final_buf.len, stdout);
 	strbuf_release(&error_buf);
 	strbuf_release(&final_buf);
-	putchar('\n');
+	if(format->need_newline_at_eol)
+		putchar('\n');
 }
 
 void pretty_print_ref(const char *name, const struct object_id *oid,
diff --git a/ref-filter.h b/ref-filter.h
index 8ecc33cdfa5..410446dc412 100644
--- a/ref-filter.h
+++ b/ref-filter.h
@@ -81,11 +81,13 @@ struct ref_format {
 	int quote_style;
 	int use_color;
 
+	int need_newline_at_eol;
+
 	/* Internal state to ref-filter */
 	int need_color_reset_at_eol;
 };
 
-#define REF_FORMAT_INIT { NULL, 0, -1 }
+#define REF_FORMAT_INIT { NULL, 0, -1, 1 }
 
 /*  Macros for checking --merged and --no-merged options */
 #define _OPT_MERGED_NO_MERGED(option, filter, h) \
-- 
gitgitgadget


  parent reply	other threads:[~2020-06-15 10:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15 10:57 [PATCH 0/5] [GSoC][RFC] print commits using ref-filter's logic Hariom Verma via GitGitGadget
2020-06-15 10:57 ` [PATCH 1/5] builtin/log: new config log.useRefFilter Hariom Verma via GitGitGadget
2020-06-15 10:57 ` [PATCH 2/5] revision: add `use_ref_filter` in struct rev_info Hariom Verma via GitGitGadget
2020-06-15 10:57 ` [PATCH 3/5] pretty: introduce `get_user_format()` Hariom Verma via GitGitGadget
2020-06-15 10:57 ` Hariom Verma via GitGitGadget [this message]
2020-06-15 10:57 ` [PATCH 5/5] pretty-lib: print commits using ref-filters logic Hariom Verma via GitGitGadget

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=0eecb653d21355d7d2ab3dd209cfdb3c24365417.1592218662.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=hariom18599@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).