git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add `[decorate]' configuration section.

From
SDSteven Drake <sdrake@xnet.co.nz>
Date
Feb 25, 2010, 22:44 UTC
Message-ID
<alpine.LNX.2.00.1002261131190.19126@vqena.qenxr.bet.am>
In-Reply-To
<7vr5ojwy38.fsf@alter.siamese.dyndns.org>
Sorry for taking so  long to reply to your email, got destracted.
 
On Wed, 17 Feb 2010, Junio C Hamano wrote:
Show 13 quoted lines
> Steven Drake <sdrake@xnet.co.nz> writes:
> 
> > This can be used to enable the display of ref names of commits that are
> > shown by log commands.  Each of the log commands (whatchanged, show,
> > reflog, and log) can be enable separately.
> >
> > e.g:
> > 	[decorate]
> > 		log
> > 		reflog
> 
> What is the reason to set these configuration differently except "because
> we can"? 

Basicly yes, but I did this when I was looking at what you said in a reply about the "log.decorate" changes, I.E.

  On Tue, 16 Feb 2010, Junio C Hamano wrote:
  > I was not worried about what your change does.  I am worried about
  > protecting what the code after your change currently does from future
  > changes done by other people while you are not actively watching the
  > patches in flight on this list.
But that can easly be with the patch below.
> Also, if it is a good idea to allow setting them independently,
> you would need to make it easier for people who want to set them all to
> the same value, e.g. "[decorate] logfamily = short" or something.
Good Idea!
> I somehow find the older "log.decorate" much more natural and the changes
> from it to this version not worth it, but maybe it is just me.

I agree with you, I just thought having a single "[decorate]" section in the config file was cleaner. But nomater which way around it was done someone would want t done the other way around.

--- >8 ---
Subject: [PATCH 1/1] log.decorate: future proofing against builtin-log.c changes

Instead of directly setting 'decoration_style' in git_log_config() we set an intermediate variable, then for each of the commands we want 'log.decorate' to have an affect 'decoration_style' is set from the intermediate.

This is to protect against future change to cmd_log_init() and how it is used or the commands 'log.decorate' affects.

Signed-off-by: Steven Drake <sdrake@xnet.co.nz>
---
 builtin-log.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/builtin-log.c b/builtin-log.c
index 0afba31..91712e6 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -24,7 +24,7 @@
 static const char *default_date_mode = NULL;
 
 static int default_show_root = 1;
-static int decoration_style;
+static int default_decoration_style, decoration_style;
 static const char *fmt_patch_subject_prefix = "PATCH";
 static const char *fmt_pretty;
 
@@ -269,9 +269,9 @@ static int git_log_config(const char *var, const char *value, void *cb)
 	if (!strcmp(var, "log.date"))
 		return git_config_string(&default_date_mode, var, value);
 	if (!strcmp(var, "log.decorate")) {
-		decoration_style = parse_decoration_style(var, value);
-		if (decoration_style < 0)
-			decoration_style = 0; /* maybe warn? */
+		default_decoration_style = parse_decoration_style(var, value);
+		if (default_decoration_style < 0)
+			default_decoration_style = 0; /* maybe warn? */
 		return 0;
 	}
 	if (!strcmp(var, "log.showroot")) {
@@ -286,6 +286,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
 	struct rev_info rev;
 
 	git_config(git_log_config, NULL);
+	decoration_style = default_decoration_style;
 
 	if (diff_use_color_default == -1)
 		diff_use_color_default = git_use_color_default;
@@ -353,6 +354,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
 	int i, count, ret = 0;
 
 	git_config(git_log_config, NULL);
+	decoration_style = default_decoration_style;
 
 	if (diff_use_color_default == -1)
 		diff_use_color_default = git_use_color_default;
@@ -429,6 +431,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
 	struct rev_info rev;
 
 	git_config(git_log_config, NULL);
+	decoration_style = default_decoration_style;
 
 	if (diff_use_color_default == -1)
 		diff_use_color_default = git_use_color_default;
@@ -462,6 +465,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
 	struct rev_info rev;
 
 	git_config(git_log_config, NULL);
+	decoration_style = default_decoration_style;
 
 	if (diff_use_color_default == -1)
 		diff_use_color_default = git_use_color_default;
-- 
1.6.6
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 10 in “Add `[decorate]' configuration section.”
  1. Add `[decorate]' configuration section.Steven Drake, Feb 17, 2010
  2. Junio C HamanoFeb 17, 2010
  3. Re* [PATCH] Add `[decorate]' configuration section.Junio C Hamano, Feb 17, 2010
  4. Heiko VoigtFeb 20, 2010
  5. Thomas RastFeb 20, 2010
  6. Junio C HamanoFeb 22, 2010
  7. Steven DrakeFeb 25, 2010
  8. Junio C HamanoFeb 25, 2010
  9. Steven DrakeFeb 26, 2010
  10. Steven DrakeFeb 26, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.