@matheusbsbs / matheus-bagliano / commits / 304cc11c65
Fork 0

notes: refactor display notes extra refs field

There's no need to use an extra pointer, which just ends up leaking memory. The fact that the list is empty tells us the same thing. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 29, 2011 at 16:56 UTC 304cc11c6566cf22e811aa791988c61b6d291973
3 files changed +6 -6
notes.c
+2 -2
@@ -1066,9 +1066,9 @@ void init_display_notes(struct display_notes_opt *opt)
1066
1067 git_config(notes_display_config, &load_config_refs);
1068
1069 - if (opt && opt->extra_notes_refs) {
1069 + if (opt) {
1070 struct string_list_item *item;
1071 - for_each_string_list_item(item, opt->extra_notes_refs)
1071 + for_each_string_list_item(item, &opt->extra_notes_refs)
1072 string_list_add_refs_by_glob(&display_notes_refs,
1073 item->string);
1074 }
notes.h
+3 -1
@@ -1,6 +1,8 @@
1 #ifndef NOTES_H
2 #define NOTES_H
3
4 +#include "string-list.h"
5 +
6 /*
7 * Function type for combining two notes annotating the same object.
8 *
@@ -257,7 +259,7 @@ struct string_list;
259
260 struct display_notes_opt {
261 unsigned int suppress_default_notes:1;
260 - struct string_list *extra_notes_refs;
262 + struct string_list extra_notes_refs;
263 };
264
265 /*
revision.c
+1 -3
@@ -1372,11 +1372,9 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1372 struct strbuf buf = STRBUF_INIT;
1373 revs->show_notes = 1;
1374 revs->show_notes_given = 1;
1375 - if (!revs->notes_opt.extra_notes_refs)
1376 - revs->notes_opt.extra_notes_refs = xcalloc(1, sizeof(struct string_list));
1375 strbuf_addstr(&buf, arg+13);
1376 expand_notes_ref(&buf);
1379 - string_list_append(revs->notes_opt.extra_notes_refs,
1377 + string_list_append(&revs->notes_opt.extra_notes_refs,
1378 strbuf_detach(&buf, NULL));
1379 } else if (!strcmp(arg, "--no-notes")) {
1380 revs->show_notes = 0;