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

Re: [PATCH] refs.c: use a stringlist for repack_without_refs

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 19, 2014, 18:00 UTC
Message-ID
<xmqq4mtvt6jj.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1416359308-14831-1-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 10 quoted lines
> This patch doesn't intend any functional changes. It is just
> a refactoring, which replaces a char** array by a stringlist
> in the function repack_without_refs.
> This is easier to read and maintain as it delivers the same
> functionality with less lines of code less pointers.
>
> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
> Signed-off-by: Stefan Beller <sbeller@google.com>
>
> -

Have three of them, not just one, here. (no need to resend to fix only this). Or...

Show 9 quoted lines
>
> This patch was heavily inspired by a part of the ref-transactions-rename
> series[1], but people tend to dislike large series and this part is
> relatively easy to take out and unrelated, so I'll send it as a single
> patch.
>
> [1] https://www.mail-archive.com/git@vger.kernel.org/msg60604.html
>
> ---

... next time, write the comments here, where Git already gives you three dashes.

Also mention what you updated and why relative to your earlier round here, if not covered in the log message already.

For example, renaming of delete_refs_list (in v1) to delete_refs (this version) is a sensible change because readers know it is a list from its type being string_list already, but that change is new relative to the codebase, so it could go to the log message ("Having array delete_refs[] and string_list delete_refs_list is redundant; drop the array and give the string_list variable the shorter name", or something like that) if you wanted to.

Show 17 quoted lines
> @@ -1316,8 +1311,8 @@ static int prune_remote(const char *remote, int dry_run)
>  {
>  	int result = 0, i;
>  	struct ref_states states;
> -	struct string_list delete_refs_list = STRING_LIST_INIT_NODUP;
> -	const char **delete_refs;
> +	struct string_list delete_refs = STRING_LIST_INIT_NODUP;
> +	struct string_list_item *ref;
>  	const char *dangling_msg = dry_run
>  		? _(" %s will become dangling!")
>  		: _(" %s has become dangling!");
> @@ -1325,6 +1320,9 @@ static int prune_remote(const char *remote, int dry_run)
>  	memset(&states, 0, sizeof(states));
>  	get_remote_ref_states(remote, &states, GET_REF_STATES);
>  
> +	for_each_string_list_item(ref, &delete_refs)
> +		string_list_append(&delete_refs, ref->string);
What are you trying to do here?

Initialise delete_refs to an empty string list, and then iterate over its elements and append them into the same string list???

It looks like a "currently noop, waiting for somebody to throw an item to the list before this code, at which time it turns into an infinite memory eater".

Curious...
Previous: Stefan BellerNext: Stefan Beller
Message 7 of 61 in “refs.c: use a stringlist for repack_without_refs”
  1. refs.c: use a stringlist for repack_without_refsStefan Beller, Nov 18, 2014
  2. Junio C HamanoNov 18, 2014
  3. Junio C HamanoNov 18, 2014
  4. Jonathan NiederNov 18, 2014
  5. Stefan BellerNov 19, 2014
  6. refs.c: use a stringlist for repack_without_refsStefan Beller, Nov 19, 2014
  7. Junio C HamanoNov 19, 2014
  8. refs.c: use a stringlist for repack_without_refsStefan Beller, Nov 19, 2014
  9. Jonathan NiederNov 19, 2014
  10. refs.c: use a stringlist for repack_without_refsStefan Beller, Nov 19, 2014
  11. refs.c: use a stringlist for repack_without_refsStefan Beller, Nov 19, 2014
  12. Jonathan NiederNov 20, 2014
  13. Junio C HamanoNov 20, 2014
  14. 1/1 refs.c: use a stringlist for repack_without_refsStefan Beller, Nov 20, 2014
  15. refs.c: repack_without_refs may be called without error string bufferStefan Beller, Nov 20, 2014
  16. Ronnie SahlbergNov 20, 2014
  17. Jonathan NiederNov 20, 2014
  18. Ronnie SahlbergNov 20, 2014
  19. Stefan BellerNov 20, 2014
  20. Jonathan NiederNov 20, 2014
  21. Jonathan NiederNov 20, 2014
  22. Junio C HamanoNov 20, 2014
  23. Stefan BellerNov 20, 2014
  24. refs.c: use a string_list for repack_without_refsStefan Beller, Nov 20, 2014
  25. Jonathan NiederNov 20, 2014
  26. 0/6 repack_without_refs(): convert to string_listMichael Haggerty, Nov 21, 2014
  27. 1/6 prune_remote(): exit early if there are no stale referencesMichael Haggerty, Nov 21, 2014
  28. Jonathan NiederNov 22, 2014
  29. 2/6 prune_remote(): initialize both delete_refs lists in a single loopMichael Haggerty, Nov 21, 2014
  30. 3/6 prune_remote(): sort delete_refs_list references en masseMichael Haggerty, Nov 21, 2014
  31. Junio C HamanoNov 21, 2014
  32. Michael HaggertyNov 25, 2014
  33. Michael HaggertyNov 25, 2014
  34. Jonathan NiederNov 22, 2014
  35. 4/6 repack_without_refs(): make the refnames argument a string_listMichael Haggerty, Nov 21, 2014
  36. Jonathan NiederNov 22, 2014
  37. Michael HaggertyNov 25, 2014
  38. 5/6 prune_remote(): rename local variableMichael Haggerty, Nov 21, 2014
  39. Jonathan NiederNov 22, 2014
  40. 6/6 prune_remote(): iterate using for_each_string_list_item()Michael Haggerty, Nov 21, 2014
  41. Jonathan NiederNov 22, 2014
  42. Michael HaggertyNov 21, 2014
  43. Junio C HamanoNov 21, 2014
  44. Stefan BellerNov 21, 2014
  45. Our cumbersome mailing list workflow (was: Re: [PATCH 0/6] repack_without_refs(): convert to string_list)Michael Haggerty, Nov 25, 2014
  46. Torsten BögershausenNov 27, 2014
  47. Matthieu MoyNov 27, 2014
  48. Philip OakleyNov 28, 2014
  49. Eric WongNov 27, 2014
  50. Michael HaggertyNov 28, 2014
  51. brian m. carlsonNov 28, 2014
  52. Junio C HamanoDec 1, 2014
  53. Stefan BellerDec 3, 2014
  54. Jonathan NiederDec 3, 2014
  55. Junio C HamanoDec 3, 2014
  56. Torsten BögershausenDec 3, 2014
  57. Michael HaggertyNov 28, 2014
  58. Marc BranchaudNov 28, 2014
  59. Damien RobertNov 28, 2014
  60. Philip OakleyDec 3, 2014
  61. Stefan BellerDec 4, 2014

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.