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

Re: [PATCH v3 16/44] refs.c: move ref iterators to the common code

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Oct 13, 2015, 04:12 UTC
Message-ID
<561C84BA.7000001@alum.mit.edu>
In-Reply-To
<1444686725-27660-17-git-send-email-dturner@twopensource.com>
On 10/12/2015 11:51 PM, David Turner wrote:
Show 73 quoted lines
> From: Ronnie Sahlberg <sahlberg@google.com>
> 
> Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
> ---
>  refs-be-files.c | 82 ---------------------------------------------------------
>  refs.c          | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 81 insertions(+), 82 deletions(-)
> 
> diff --git a/refs-be-files.c b/refs-be-files.c
> index ecf2b33..46fa43c 100644
> --- a/refs-be-files.c
> +++ b/refs-be-files.c
> [...]
> @@ -2012,40 +1964,6 @@ int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)
>  	return ret;
>  }
>  
> -int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
> -	const char *prefix, void *cb_data)
> -{
> -	struct strbuf real_pattern = STRBUF_INIT;
> -	struct ref_filter filter;
> -	int ret;
> -
> -	if (!prefix && !starts_with(pattern, "refs/"))
> -		strbuf_addstr(&real_pattern, "refs/");
> -	else if (prefix)
> -		strbuf_addstr(&real_pattern, prefix);
> -	strbuf_addstr(&real_pattern, pattern);
> -
> -	if (!has_glob_specials(pattern)) {
> -		/* Append implied '/' '*' if not present. */
> -		strbuf_complete(&real_pattern, '/');
> -		/* No need to check for '*', there is none. */
> -		strbuf_addch(&real_pattern, '*');
> -	}
> -
> -	filter.pattern = real_pattern.buf;
> -	filter.fn = fn;
> -	filter.cb_data = cb_data;
> -	ret = for_each_ref(filter_refs, &filter);
> -
> -	strbuf_release(&real_pattern);
> -	return ret;
> -}
> -
> [...]
> diff --git a/refs.c b/refs.c
> index 44ee4f4..7714dad 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -781,3 +781,84 @@ const char *prettify_refname(const char *name)
>  		starts_with(name, "refs/remotes/") ? 13 :
>  		0);
>  }
> [...]
> +int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,
> +	const char *prefix, void *cb_data)
> +{
> +	struct strbuf real_pattern = STRBUF_INIT;
> +	struct ref_filter filter;
> +	int ret;
> +
> +	if (!prefix && !starts_with(pattern, "refs/"))
> +		strbuf_addstr(&real_pattern, "refs/");
> +	else if (prefix)
> +		strbuf_addstr(&real_pattern, prefix);
> +	strbuf_addstr(&real_pattern, pattern);
> +
> +	if (!has_glob_specials(pattern)) {
> +		/* Append implied '/' '*' if not present. */
> +		if (real_pattern.buf[real_pattern.len - 1] != '/')
> +			strbuf_addch(&real_pattern, '/');
The original has
		strbuf_complete(&real_pattern, '/');

in place of the above two lines. I think you made a mistake when rebasing on top of

    00b6c178c3 use strbuf_complete to conditionally append slash
Show 14 quoted lines
> +		/* No need to check for '*', there is none. */
> +		strbuf_addch(&real_pattern, '*');
> +	}
> +
> +	filter.pattern = real_pattern.buf;
> +	filter.fn = fn;
> +	filter.cb_data = cb_data;
> +	ret = for_each_ref(filter_refs, &filter);
> +
> +	strbuf_release(&real_pattern);
> +	return ret;
> +}
> +
> [...]
Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
Previous: David TurnerNext: David Turner
Message 26 of 71 in “alternate refs backends”
  1. 00/44 alternate refs backendsDavid Turner, Oct 12, 2015
  2. 01/44 refs.c: create a public version of verify_refname_availableDavid Turner, Oct 12, 2015
  3. Michael HaggertyOct 13, 2015
  4. 02/44 refs: make repack_without_refs and is_branch publicDavid Turner, Oct 12, 2015
  5. Michael HaggertyOct 13, 2015
  6. Michael HaggertyOct 13, 2015
  7. David TurnerOct 13, 2015
  8. 03/44 refs-be-files.c: rename refs to refs-be-filesDavid Turner, Oct 12, 2015
  9. 04/44 refs.c: add a new refs.c file to hold all common refs codeDavid Turner, Oct 12, 2015
  10. 05/44 refs.c: move update_ref to refs.cDavid Turner, Oct 12, 2015
  11. Michael HaggertyOct 13, 2015
  12. David TurnerOct 13, 2015
  13. David TurnerOct 14, 2015
  14. 06/44 refs.c: move delete_ref and delete_refs to the common codeDavid Turner, Oct 12, 2015
  15. Michael HaggertyOct 13, 2015
  16. 07/44 refs.c: move read_ref_at to the common refs fileDavid Turner, Oct 12, 2015
  17. 08/44 refs.c: move the hidden refs functions to the common codeDavid Turner, Oct 12, 2015
  18. 09/44 refs.c: move dwim and friend functions to the common refs codeDavid Turner, Oct 12, 2015
  19. 10/44 refs.c: move warn_if_dangling_symref* to the common codeDavid Turner, Oct 12, 2015
  20. 11/44 refs.c: move read_ref, read_ref_full and ref_exists to the common codeDavid Turner, Oct 12, 2015
  21. 12/44 refs.c: move resolve_refdup to commonDavid Turner, Oct 12, 2015
  22. 13/44 refs.c: move check_refname_format to the common codeDavid Turner, Oct 12, 2015
  23. 14/44 refs.c: move is_branch to the common codeDavid Turner, Oct 12, 2015
  24. 15/44 refs.c: move prettify_refname to the common codeDavid Turner, Oct 12, 2015
  25. 16/44 refs.c: move ref iterators to the common codeDavid Turner, Oct 12, 2015
  26. Michael HaggertyOct 13, 2015
  27. 17/44 refs.c: move head_ref_namespaced to the common codeDavid Turner, Oct 12, 2015
  28. 18/44 refs: move transaction functions into common codeDavid Turner, Oct 12, 2015
  29. Michael HaggertyOct 13, 2015
  30. Michael HaggertyOct 13, 2015
  31. David TurnerOct 13, 2015
  32. David TurnerOct 13, 2015
  33. 19/44 refs: add a backend method structure with transaction functionsDavid Turner, Oct 12, 2015
  34. 19/44 refs-be-files.c: add a backend method structure with transaction functionsDavid Turner, Oct 12, 2015
  35. David TurnerOct 12, 2015
  36. Michael HaggertyOct 13, 2015
  37. David TurnerOct 13, 2015
  38. Michael HaggertyOct 13, 2015
  39. 20/44 refs-be-files.c: add methods for misc ref operationsDavid Turner, Oct 12, 2015
  40. Michael HaggertyOct 13, 2015
  41. 21/44 refs-be-files.c: add methods for the ref iteratorsDavid Turner, Oct 12, 2015
  42. 22/44 refs-be-files.c: add method for for_each_reftype_...David Turner, Oct 12, 2015
  43. 23/44 refs-be-files.c: add do_for_each_per_worktree_refDavid Turner, Oct 12, 2015
  44. 24/44 refs.c: move refname_is_safe to the common codeDavid Turner, Oct 12, 2015
  45. 25/44 refs.h: document make refname_is_safe and add it to headerDavid Turner, Oct 12, 2015
  46. Michael HaggertyOct 13, 2015
  47. Michael HaggertyOct 13, 2015
  48. David TurnerOct 13, 2015
  49. 26/44 refs.c: move copy_msg to the common codeDavid Turner, Oct 12, 2015
  50. Michael HaggertyOct 13, 2015
  51. 27/44 refs.c: move peel_object to the common codeDavid Turner, Oct 12, 2015
  52. Michael HaggertyOct 13, 2015
  53. 28/44 refs.c: move should_autocreate_reflog to common codeDavid Turner, Oct 12, 2015
  54. 29/44 refs.c: add ref backend init functionDavid Turner, Oct 12, 2015
  55. 30/44 refs.c: add methods for reflogDavid Turner, Oct 12, 2015
  56. 31/44 refs.c: add method for initial ref transaction commitDavid Turner, Oct 12, 2015
  57. 32/44 initdb: move safe_create_dir into common codeDavid Turner, Oct 12, 2015
  58. 33/44 refs.c: add method for initializing refs dbDavid Turner, Oct 12, 2015
  59. 34/44 refs-be-files.c: add method to rename refsDavid Turner, Oct 12, 2015
  60. 35/44 refs: make lock genericDavid Turner, Oct 12, 2015
  61. 36/44 refs: make files_log_ref_write functions publicDavid Turner, Oct 12, 2015
  62. 37/44 refs: break out a ref conflict checkDavid Turner, Oct 12, 2015
  63. Michael HaggertyOct 13, 2015
  64. David TurnerOct 13, 2015
  65. 38/44 refs: move duplicate check to common codeDavid Turner, Oct 12, 2015
  66. 39/44 refs: always handle non-normal refs in files backendDavid Turner, Oct 12, 2015
  67. 40/44 refs: allow ref backend to be set for cloneDavid Turner, Oct 12, 2015
  68. 41/44 refs: add register_refs_backendDavid Turner, Oct 12, 2015
  69. 42/44 introduce "extensions" form of core.repositoryformatversionDavid Turner, Oct 12, 2015
  70. 43/44 refs: add LMDB refs backendDavid Turner, Oct 12, 2015
  71. 44/44 refs: tests for db backendDavid Turner, Oct 12, 2015

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.