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

[PATCH] pretty: initialize new cmt_fmt_map to 0

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 8, 2010, 21:07 UTC
Message-ID
<20100508210739.GA6486@progeny.tock>
In-Reply-To
<1272798044-10487-4-git-send-email-wmpalmer@gmail.com>

Without this change, is_alias is likely to happen to be nonzero, resulting in "fatal: invalid --pretty format" when the fake alias cannot be resolved.

Use memset instead of initializing the members one by one to make it easier to expand the struct in the future if needed.

t4205 (log --pretty) does not pass for me without this fix.
Cc: Will Palmer <wmpalmer@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Sorry I missed this before.  Sane?
Jonathan
 pretty.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/pretty.c b/pretty.c
index aaf8020..4784f67 100644
--- a/pretty.c
+++ b/pretty.c
@@ -59,6 +59,7 @@ static int git_pretty_formats_config(const char *var, const char *value, void *c
 		ALLOC_GROW(commit_formats, commit_formats_len+1,
 			   commit_formats_alloc);
 		commit_format = &commit_formats[commit_formats_len];
+		memset(commit_format, 0, sizeof(*commit_format));
 		commit_formats_len++;
 	}
 
-- 
1.7.1
Previous: Will PalmerNext: Will Palmer
Message 9 of 11 in “pretty: format aliases”
  1. 0/3 pretty: format aliasesWill Palmer, May 2, 2010
  2. 1/3 pretty: make it easier to add new formatsWill Palmer, May 2, 2010
  3. Jonathan NiederMay 2, 2010
  4. 2/3 pretty: add infrastructure to allow format aliasesWill Palmer, May 2, 2010
  5. Jonathan NiederMay 2, 2010
  6. 3/3 pretty: add aliases for pretty formatsWill Palmer, May 2, 2010
  7. Jonathan NiederMay 2, 2010
  8. Will PalmerMay 2, 2010
  9. pretty: initialize new cmt_fmt_map to 0Jonathan Nieder, May 8, 2010
  10. Will PalmerMay 8, 2010
  11. Junio C HamanoMay 2, 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.