Re: [PATCH 09/24] refs.c: pass a list of names to skip to is_refname_available

2014-10-03 Thread Jonathan Nieder
Junio C Hamano wrote:
 Jonathan Nieder jrnie...@gmail.com writes:

 diff --git a/refs.c b/refs.c
 index f124c2b..6820c93 100644
 --- a/refs.c
 +++ b/refs.c
 @@ -801,14 +801,16 @@ static int names_conflict(const char *refname1, const 
 char *refname2)
 
  struct name_conflict_cb {
  const char *refname;
 -const char *oldrefname;
  const char *conflicting_refname;
 +struct string_list *skiplist;
  };

 As cbe73331 (refs: speed up is_refname_available, 2014-09-10)
 touches the same area and is now in 'master', the logic around here
 in this series needs to be reworked.

Thanks for the heads up.  (I hadn't realized the ref-transaction-1 was
part of 'master' --- yay!)  Rebased and reworked:
https://code-review.googlesource.com/1027

I'll give a week or so for review comments on this version of the
series and then post a hopefully final version.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/24] refs.c: pass a list of names to skip to is_refname_available

2014-10-03 Thread Junio C Hamano
Jonathan Nieder jrnie...@gmail.com writes:

 Junio C Hamano wrote:
 ...
 As cbe73331 (refs: speed up is_refname_available, 2014-09-10)
 touches the same area and is now in 'master', the logic around here
 in this series needs to be reworked.

 Thanks for the heads up.  (I hadn't realized the ref-transaction-1 was
 part of 'master' --- yay!)  Rebased and reworked:
 https://code-review.googlesource.com/1027

Heh, I was sort of expecting that heavy-weight contributors that
throw many and/or large patch series would at least be paying
attention to What's cooking reports.

Will take a look over there (I really hate having to context switch
only to review this series, though).

 I'll give a week or so for review comments on this version of the
 series and then post a hopefully final version.

Thanks.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 09/24] refs.c: pass a list of names to skip to is_refname_available

2014-10-02 Thread Junio C Hamano
Jonathan Nieder jrnie...@gmail.com writes:

 diff --git a/refs.c b/refs.c
 index f124c2b..6820c93 100644
 --- a/refs.c
 +++ b/refs.c
 @@ -801,14 +801,16 @@ static int names_conflict(const char *refname1, const 
 char *refname2)
  
  struct name_conflict_cb {
   const char *refname;
 - const char *oldrefname;
   const char *conflicting_refname;
 + struct string_list *skiplist;
  };

As cbe73331 (refs: speed up is_refname_available, 2014-09-10)
touches the same area and is now in 'master', the logic around here
in this series needs to be reworked.

Thanks.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/24] refs.c: pass a list of names to skip to is_refname_available

2014-10-01 Thread Jonathan Nieder
From: Ronnie Sahlberg sahlb...@google.com
Date: Thu, 1 May 2014 11:16:07 -0700

Change is_refname_available to take a list of strings to exclude when
checking for conflicts instead of just one single name. We can already
exclude a single name for the sake of renames. This generalizes that support.

ref_transaction_commit already tracks a set of refs that are being deleted
in an array.  This array is then used to exclude refs from being written to
the packed-refs file.  At some stage we will want to change this array to a
struct string_list and then we can pass it to is_refname_available via the
call to lock_ref_sha1_basic.  That will allow us to perform transactions
that perform multiple renames as long as there are no conflicts within the
starting or ending state.

For example, that would allow a single transaction that contains two
renames that are both individually conflicting:

   m - n/n
   n - m/m

No functional change intended yet.

Signed-off-by: Ronnie Sahlberg sahlb...@google.com
Signed-off-by: Jonathan Nieder jrnie...@gmail.com
---
Since v21:
- clarified commit message
- clarified comments

 refs.c | 44 +---
 1 file changed, 29 insertions(+), 15 deletions(-)

diff --git a/refs.c b/refs.c
index f124c2b..6820c93 100644
--- a/refs.c
+++ b/refs.c
@@ -801,14 +801,16 @@ static int names_conflict(const char *refname1, const 
char *refname2)
 
 struct name_conflict_cb {
const char *refname;
-   const char *oldrefname;
const char *conflicting_refname;
+   struct string_list *skiplist;
 };
 
 static int name_conflict_fn(struct ref_entry *entry, void *cb_data)
 {
struct name_conflict_cb *data = (struct name_conflict_cb *)cb_data;
-   if (data-oldrefname  !strcmp(data-oldrefname, entry-name))
+
+   if (data-skiplist 
+   string_list_has_string(data-skiplist, entry-name))
return 0;
if (names_conflict(data-refname, entry-name)) {
data-conflicting_refname = entry-name;
@@ -820,17 +822,18 @@ static int name_conflict_fn(struct ref_entry *entry, void 
*cb_data)
 /*
  * Return true iff a reference named refname could be created without
  * conflicting with the name of an existing reference in dir.  If
- * oldrefname is non-NULL, ignore potential conflicts with oldrefname
- * (e.g., because oldrefname is scheduled for deletion in the same
- * operation).
+ * skiplist is non-NULL, ignore potential conflicts with names in
+ * skiplist (e.g., because those refs are scheduled for deletion in
+ * the same operation).  skiplist must be sorted.
  */
-static int is_refname_available(const char *refname, const char *oldrefname,
-   struct ref_dir *dir)
+static int is_refname_available(const char *refname,
+   struct ref_dir *dir,
+   struct string_list *skiplist)
 {
struct name_conflict_cb data;
data.refname = refname;
-   data.oldrefname = oldrefname;
data.conflicting_refname = NULL;
+   data.skiplist = skiplist;
 
sort_ref_dir(dir);
if (do_for_each_entry_in_dir(dir, 0, name_conflict_fn, data)) {
@@ -2080,6 +2083,7 @@ int dwim_log(const char *str, int len, unsigned char 
*sha1, char **log)
  */
 static struct ref_lock *lock_ref_sha1_basic(const char *refname,
const unsigned char *old_sha1,
+   struct string_list *skiplist,
int flags, int *type_p)
 {
char *ref_file;
@@ -2129,7 +2133,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char 
*refname,
 * name is a proper prefix of our refname.
 */
if (missing 
-!is_refname_available(refname, NULL, get_packed_refs(ref_cache))) 
{
+!is_refname_available(refname, get_packed_refs(ref_cache),
+  skiplist)) {
last_errno = ENOTDIR;
goto error_return;
}
@@ -2187,7 +2192,7 @@ struct ref_lock *lock_any_ref_for_update(const char 
*refname,
 const unsigned char *old_sha1,
 int flags, int *type_p)
 {
-   return lock_ref_sha1_basic(refname, old_sha1, flags, type_p);
+   return lock_ref_sha1_basic(refname, old_sha1, NULL, flags, type_p);
 }
 
 /*
@@ -2648,6 +2653,7 @@ int rename_ref(const char *oldrefname, const char 
*newrefname, const char *logms
struct stat loginfo;
int log = !lstat(git_path(logs/%s, oldrefname), loginfo);
const char *symref = NULL;
+   struct string_list skiplist = STRING_LIST_INIT_NODUP;
 
if (log  S_ISLNK(loginfo.st_mode))
return error(reflog for %s is a symlink, oldrefname);
@@ -2659,11 +2665,18 @@ int rename_ref(const char *oldrefname, const char 
*newrefname, const char *logms
if (!symref)