public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Michael Haggerty <mhagger@alum•mit.edu>
To: David Turner <dturner@twopensource•com>, git@vger•kernel.org
Cc: Ronnie Sahlberg <sahlberg@google•com>
Subject: Re: [PATCH v3 01/44] refs.c: create a public version of verify_refname_available
Date: Tue, 13 Oct 2015 04:28:23 +0200	[thread overview]
Message-ID: <561C6C47.7090108@alum.mit.edu> (raw)
In-Reply-To: <1444686725-27660-2-git-send-email-dturner@twopensource.com>

On 10/12/2015 11:51 PM, David Turner wrote:
> From: Ronnie Sahlberg <sahlberg@google•com>
> 
> Create a public version of verify_refname_available that backends can
> provide.
> 
> Signed-off-by: Ronnie Sahlberg <sahlberg@google•com>
> Signed-off-by: David Turner <dturner@twopensource•com>
> ---
>  refs.c | 65 ++++++++++++++++++++++++++++++-----------------------------------
>  refs.h | 17 +++++++++++++++++
>  2 files changed, 47 insertions(+), 35 deletions(-)
> 
> diff --git a/refs.c b/refs.c
> index 132eff5..fe71ea0 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -279,7 +279,7 @@ struct ref_dir {
>   * presence of an empty subdirectory does not block the creation of a
>   * similarly-named reference.  (The fact that reference names with the
>   * same leading components can conflict *with each other* is a
> - * separate issue that is regulated by verify_refname_available().)
> + * separate issue that is regulated by verify_refname_available_dir().)
>   *
>   * Please note that the name field contains the fully-qualified
>   * reference (or subdirectory) name.  Space could be saved by only
> @@ -897,25 +897,13 @@ static int nonmatching_ref_fn(struct ref_entry *entry, void *vdata)
>  /*
>   * Return 0 if a reference named refname could be created without
>   * conflicting with the name of an existing reference in dir.
> - * Otherwise, return a negative value and write an explanation to err.
> - * If extras is non-NULL, it is a list of additional refnames with
> - * which refname is not allowed to conflict. If skip is non-NULL,
> - * ignore potential conflicts with refs in skip (e.g., because they
> - * are scheduled for deletion in the same operation). Behavior is
> - * undefined if the same name is listed in both extras and skip.
> - *
> - * Two reference names conflict if one of them exactly matches the
> - * leading components of the other; e.g., "refs/foo/bar" conflicts
> - * with both "refs/foo" and with "refs/foo/bar/baz" but not with
> - * "refs/foo/bar" or "refs/foo/barbados".
> - *
> - * extras and skip must be sorted.
> + * See verify_refname_available for details.
>   */
> -static int verify_refname_available(const char *refname,
> -				    const struct string_list *extras,
> -				    const struct string_list *skip,
> -				    struct ref_dir *dir,
> -				    struct strbuf *err)
> +static int verify_refname_available_dir(const char *refname,
> +					const struct string_list *extras,
> +					const struct string_list *skip,
> +					struct ref_dir *dir,
> +					struct strbuf *err)
>  {
>  	const char *slash;
>  	int pos;
> @@ -2464,9 +2452,12 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
>  		 */
>  		strbuf_git_path(&orig_ref_file, "%s", orig_refname);
>  		if (remove_empty_directories(&orig_ref_file)) {
> +			struct ref_dir *loose_refs;
> +			loose_refs = get_loose_refs(&ref_cache);

It's OK to initialize `loose_refs` on the line where it is declared.

>  			last_errno = errno;
> -			if (!verify_refname_available(orig_refname, extras, skip,
> -						      get_loose_refs(&ref_cache), err))
> +			if (!verify_refname_available_dir(orig_refname, extras,
> +							  skip, loose_refs,
> +							  err))
>  				strbuf_addf(err, "there are still refs under '%s'",
>  					    orig_refname);
>  			goto error_return;
> [...]
> diff --git a/refs.h b/refs.h
> index 6d30c98..79ea220 100644
> --- a/refs.h
> +++ b/refs.h
> @@ -218,6 +218,23 @@ extern void warn_dangling_symrefs(FILE *fp, const char *msg_fmt, const struct st
>  int pack_refs(unsigned int flags);
>  
>  /*
> + * Return true iff a reference named refname could be created without
> + * conflicting with the name of an existing reference.  If
> + * skip is non-NULL, ignore potential conflicts with refs in skip
> + * (e.g., because they are scheduled for deletion in the same
> + * operation).
> + *
> + * Two reference names conflict if one of them exactly matches the
> + * leading components of the other; e.g., "foo/bar" conflicts with
> + * both "foo" and with "foo/bar/baz" but not with "foo/bar" or
> + * "foo/barbados".
> + *
> + * skip must be sorted.
> + */
> +int verify_refname_available(const char *newname, struct string_list *extra,
> +			     struct string_list *skip, struct strbuf *err);

This function has an `extra` parameter but the description of this
parameter disappeared as the docstring was moved from refs.c to here.

> +
> +/*
>   * Flags controlling ref_transaction_update(), ref_transaction_create(), etc.
>   * REF_NODEREF: act on the ref directly, instead of dereferencing
>   *              symbolic references.
> 

Michael

-- 
Michael Haggerty
mhagger@alum•mit.edu

  reply	other threads:[~2015-10-13  2:35 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12 21:51 [PATCH v3 00/44] alternate refs backends David Turner
2015-10-12 21:51 ` [PATCH v3 01/44] refs.c: create a public version of verify_refname_available David Turner
2015-10-13  2:28   ` Michael Haggerty [this message]
2015-10-12 21:51 ` [PATCH v3 02/44] refs: make repack_without_refs and is_branch public David Turner
2015-10-13  2:39   ` Michael Haggerty
2015-10-13  7:23     ` Michael Haggerty
2015-10-13 21:18       ` David Turner
2015-10-12 21:51 ` [PATCH v3 03/44] refs-be-files.c: rename refs to refs-be-files David Turner
2015-10-12 21:51 ` [PATCH v3 04/44] refs.c: add a new refs.c file to hold all common refs code David Turner
2015-10-12 21:51 ` [PATCH v3 05/44] refs.c: move update_ref to refs.c David Turner
2015-10-13  3:41   ` Michael Haggerty
2015-10-13 20:40     ` David Turner
2015-10-14  1:01     ` David Turner
2015-10-12 21:51 ` [PATCH v3 06/44] refs.c: move delete_ref and delete_refs to the common code David Turner
2015-10-13  3:51   ` Michael Haggerty
2015-10-12 21:51 ` [PATCH v3 07/44] refs.c: move read_ref_at to the common refs file David Turner
2015-10-12 21:51 ` [PATCH v3 08/44] refs.c: move the hidden refs functions to the common code David Turner
2015-10-12 21:51 ` [PATCH v3 09/44] refs.c: move dwim and friend functions to the common refs code David Turner
2015-10-12 21:51 ` [PATCH v3 10/44] refs.c: move warn_if_dangling_symref* to the common code David Turner
2015-10-12 21:51 ` [PATCH v3 11/44] refs.c: move read_ref, read_ref_full and ref_exists " David Turner
2015-10-12 21:51 ` [PATCH v3 12/44] refs.c: move resolve_refdup to common David Turner
2015-10-12 21:51 ` [PATCH v3 13/44] refs.c: move check_refname_format to the common code David Turner
2015-10-12 21:51 ` [PATCH v3 14/44] refs.c: move is_branch " David Turner
2015-10-12 21:51 ` [PATCH v3 15/44] refs.c: move prettify_refname " David Turner
2015-10-12 21:51 ` [PATCH v3 16/44] refs.c: move ref iterators " David Turner
2015-10-13  4:12   ` Michael Haggerty
2015-10-12 21:51 ` [PATCH v3 17/44] refs.c: move head_ref_namespaced " David Turner
2015-10-12 21:51 ` [PATCH v3 18/44] refs: move transaction functions into " David Turner
2015-10-13  6:15   ` Michael Haggerty
2015-10-13 11:29   ` Michael Haggerty
2015-10-13 22:21     ` David Turner
2015-10-13 23:05       ` David Turner
2015-10-12 21:51 ` [PATCH v3 19/44] refs: add a backend method structure with transaction functions David Turner
2015-10-12 21:51 ` [PATCH v3 19/44] refs-be-files.c: " David Turner
2015-10-12 22:25   ` David Turner
2015-10-13  7:56   ` Michael Haggerty
2015-10-13 18:28     ` David Turner
2015-10-13 21:12       ` Michael Haggerty
2015-10-12 21:51 ` [PATCH v3 20/44] refs-be-files.c: add methods for misc ref operations David Turner
2015-10-13  7:44   ` Michael Haggerty
2015-10-12 21:51 ` [PATCH v3 21/44] refs-be-files.c: add methods for the ref iterators David Turner
2015-10-12 21:51 ` [PATCH v3 22/44] refs-be-files.c: add method for for_each_reftype_ David Turner
2015-10-12 21:51 ` [PATCH v3 23/44] refs-be-files.c: add do_for_each_per_worktree_ref David Turner
2015-10-12 21:51 ` [PATCH v3 24/44] refs.c: move refname_is_safe to the common code David Turner
2015-10-12 21:51 ` [PATCH v3 25/44] refs.h: document make refname_is_safe and add it to header David Turner
2015-10-13  7:33   ` Michael Haggerty
2015-10-13  9:18     ` Michael Haggerty
2015-10-13 18:32       ` David Turner
2015-10-12 21:51 ` [PATCH v3 26/44] refs.c: move copy_msg to the common code David Turner
2015-10-13  9:25   ` Michael Haggerty
2015-10-12 21:51 ` [PATCH v3 27/44] refs.c: move peel_object " David Turner
2015-10-13  9:34   ` Michael Haggerty
2015-10-12 21:51 ` [PATCH v3 28/44] refs.c: move should_autocreate_reflog to " David Turner
2015-10-12 21:51 ` [PATCH v3 29/44] refs.c: add ref backend init function David Turner
2015-10-12 21:51 ` [PATCH v3 30/44] refs.c: add methods for reflog David Turner
2015-10-12 21:51 ` [PATCH v3 31/44] refs.c: add method for initial ref transaction commit David Turner
2015-10-12 21:51 ` [PATCH v3 32/44] initdb: move safe_create_dir into common code David Turner
2015-10-12 21:51 ` [PATCH v3 33/44] refs.c: add method for initializing refs db David Turner
2015-10-12 21:51 ` [PATCH v3 34/44] refs-be-files.c: add method to rename refs David Turner
2015-10-12 21:51 ` [PATCH v3 35/44] refs: make lock generic David Turner
2015-10-12 21:51 ` [PATCH v3 36/44] refs: make files_log_ref_write functions public David Turner
2015-10-12 21:51 ` [PATCH v3 37/44] refs: break out a ref conflict check David Turner
2015-10-13 10:25   ` Michael Haggerty
2015-10-13 18:46     ` David Turner
2015-10-12 21:51 ` [PATCH v3 38/44] refs: move duplicate check to common code David Turner
2015-10-12 21:52 ` [PATCH v3 39/44] refs: always handle non-normal refs in files backend David Turner
2015-10-12 21:52 ` [PATCH v3 40/44] refs: allow ref backend to be set for clone David Turner
2015-10-12 21:52 ` [PATCH v3 41/44] refs: add register_refs_backend David Turner
2015-10-12 21:52 ` [PATCH v3 42/44] introduce "extensions" form of core.repositoryformatversion David Turner
2015-10-12 21:52 ` [PATCH v3 43/44] refs: add LMDB refs backend David Turner
2015-10-12 21:52 ` [PATCH v3 44/44] refs: tests for db backend David Turner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=561C6C47.7090108@alum.mit.edu \
    --to=mhagger@alum$(echo .)mit.edu \
    --cc=dturner@twopensource$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=sahlberg@google$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox