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

Re: [PATCH 1/3] list-objects: add "void *data" parameter to show functions

From
Christian Couder <chriscool@tuxfamily.org>
Date
Apr 8, 2009, 04:39 UTC
Message-ID
<200904080639.35499.chriscool@tuxfamily.org>
In-Reply-To
<7vk55vubcv.fsf@gitster.siamese.dyndns.org>
Le mercredi 8 avril 2009, Junio C Hamano a écrit :
Show 15 quoted lines
> Christian Couder <chriscool@tuxfamily.org> writes:
> > The goal of this patch is to get rid of the "static struct rev_info
> > revs" static variable in "builtin-rev-list.c".
>
> Hmm.  If it were a more library-ish file, a removal of such a static
> variable might help you to make more than one calls to a library
> function, but does it matter in files like builtin-rev-list.c?  Its
> cmd_rev_list() is like main() --- it is meant to run once and exit.
>
> So if it is the only goal of this series, I am inclined to say that I do
> not have a reason to look at the rest of the series, but as a side effect
> does this removal make some other API better?  Perhaps a more library-ish
> function is in builtin-rev-list.c and this structure should really needs
> to be passed around as a parameter, but I cannot tell solely by reading
> the goal above, without reading the patches themselves.

In the cover letter, I wrote that the patch series removes restrictions on using the "show_bisect_vars" function.

In fact there was a restriction on the use of the BISECT_SHOW_ALL flag because that would use the "show_commit" function that was using static variables.

The restriction was described in a comment in "bisect.h" and this comment is removed by the series.

This is the relevant hunk in patch 2/3:
diff --git a/bisect.h b/bisect.h
index f5d1067..b1c334d 100644
--- a/bisect.h
+++ b/bisect.h
@@ -14,12 +14,14 @@ extern struct commit_list *filter_skipped(struct 
commit_list *list,
 #define BISECT_SHOW_TRIED      (1<<1)
 #define BISECT_SHOW_STRINGED   (1<<2)
 
-/*
- * The flag BISECT_SHOW_ALL should not be set if this function is called
- * from outside "builtin-rev-list.c" as otherwise it would use
- * static "revs" from this file.
- */
-extern int show_bisect_vars(struct rev_info *revs, int reaches, int all,
+struct rev_list_info {
+       struct rev_info *revs;
+       int show_timestamp;
+       int hdr_termination;
+       const char *header_prefix;
+};
+
+extern int show_bisect_vars(struct rev_list_info *info, int reaches, int 
all,
                            int flags);
 
 extern int bisect_next_vars(const char *prefix);


Best regards,
Christian.

> > Anyway this makes the code more clean and more generic, so it
> > should be a good thing in the long run.
>
> I wouldn't disagree with that "long run" thing, but the answer to the
> above question affects the placement of this series in my prioritized
> queue.
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 8 in “list-objects: add "void *data" parameter to show functions”
  1. 1/3 list-objects: add "void *data" parameter to show functionsChristian Couder, Apr 6, 2009
  2. 2/3 rev-list: remove last static vars used in "show_commit"Christian Couder, Apr 6, 2009
  3. 3/3 rev-list: add "int bisect_show_flags" in "struct rev_list_info"Christian Couder, Apr 7, 2009
  4. Paolo BonziniApr 8, 2009
  5. Christian CouderApr 9, 2009
  6. Junio C HamanoApr 8, 2009
  7. Christian CouderApr 8, 2009
  8. Junio C HamanoApr 8, 2009

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.