[PATCH 1/4] oneline: parse --newlineafter flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: John Cai <johncai86@xxxxxxxxx>

* revision.h: add newlineafter flag type
* builtin/log.c: parse newlineafter flag with callback

Signed-off-by: John Cai <johncai86@xxxxxxxxx>
---
 builtin/log.c | 25 +++++++++++++++++++++++++
 revision.h    |  4 ++++
 2 files changed, 29 insertions(+)

diff --git a/builtin/log.c b/builtin/log.c
index f75d87e8d7f..3758c73760c 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -53,6 +53,7 @@ static int decoration_given;
 static int use_mailmap_config = 1;
 static const char *fmt_patch_subject_prefix = "PATCH";
 static int fmt_patch_name_max = FORMAT_PATCH_NAME_MAX_DEFAULT;
+static int newlineafter = NEWLINEAFTER_NONE;
 static const char *fmt_pretty;
 
 static const char * const builtin_log_usage[] = {
@@ -132,6 +133,27 @@ static int log_line_range_callback(const struct option *option, const char *arg,
 	return 0;
 }
 
+static int parse_newlineafter(const char *value)
+{
+	if (!strcmp(value, "decorations"))
+		return NEWLINEAFTER_DECORATIONS;
+
+	return NEWLINEAFTER_NONE;
+}
+
+static int option_parse_newlineafter(const struct option *opt,
+				   const char *arg, int unset)
+{
+	int *newlineafter = opt->value;
+
+	if (unset)
+		*newlineafter = NEWLINEAFTER_NONE;
+	else
+		*newlineafter = parse_newlineafter(arg);
+
+	return 0;
+}
+
 static void init_log_defaults(void)
 {
 	init_diff_ui_defaults();
@@ -156,6 +178,7 @@ static void cmd_log_init_defaults(struct rev_info *rev)
 	rev->show_signature = default_show_signature;
 	rev->encode_email_headers = default_encode_email_headers;
 	rev->diffopt.flags.allow_textconv = 1;
+	rev->newlineafter = NEWLINEAFTER_NONE;
 
 	if (default_date_mode)
 		parse_date_format(default_date_mode, &rev->date_mode);
@@ -189,6 +212,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 		OPT_CALLBACK('L', NULL, &line_cb, "range:file",
 			     N_("trace the evolution of line range <start>,<end> or function :<funcname> in <file>"),
 			     log_line_range_callback),
+		OPT_CALLBACK(0, "newlineafter", &newlineafter, N_("field"), N_("new line after <field>"), option_parse_newlineafter),
 		OPT_END()
 	};
 
@@ -265,6 +289,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
 		load_ref_decorations(&decoration_filter, decoration_style);
 	}
 
+	rev->newlineafter = newlineafter;
 	if (rev->line_level_traverse)
 		line_log_init(rev, line_cb.prefix, &line_cb.args);
 
diff --git a/revision.h b/revision.h
index 5578bb4720a..ff0b89c1f40 100644
--- a/revision.h
+++ b/revision.h
@@ -243,6 +243,10 @@ struct rev_info {
 	int		no_inline;
 	int		show_log_size;
 	struct string_list *mailmap;
+	enum {
+			NEWLINEAFTER_NONE,
+			NEWLINEAFTER_DECORATIONS
+		} newlineafter;
 
 	/* Filter by commit log message */
 	struct grep_opt	grep_filter;
-- 
gitgitgadget




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux