{"thread":{"id":"28662","subject":"[PATCH 01/14] cache.h: add comments for git_path() and git_path_submodule()","startedAt":"2011-10-13T07:58:21Z","lastAt":"2011-10-14T06:40:53Z","messageCount":28,"participants":["mhagger@alum.mit.edu","Johannes Sixt","Drew Northup","Junio C Hamano","Michael Haggerty"],"isPatch":true,"patchVersion":1,"patchTotal":14},"messages":[{"id":"177518","messageId":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":null,"subject":"[PATCH 00/14] Tidying up references code","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:21Z","receivedAt":"2011-10-13T07:58:21Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nThis is the next installment of the reference changes that I have been\nworking on.  This batch includes a lot of tidying up in preparation\nfor the real changes.\n\nThe last few patches have a little bit of meat on them.  They start\nchanging the innards of refs.c to work less with strings and more with\nobjects.  This work will continue in later patches with the ultimate\ngoal of swapping the data structure used to store cached references\nout from under the module--changing it from a sorted array of pointers\ninto a hierarchical tree shaped like the reference namespace\ntree.\n\nThis patch series should be applied on top of \"[PATCH v3] Provide API\nto invalidate refs cache\".  It has textual dependencies on that patch\nseries, though logically I don't think that they interact.\n\nMichael Haggerty (14):\n  cache.h: add comments for git_path() and git_path_submodule()\n  struct ref_list: document name member\n  refs.c: rename some local \"refname\" variables\n  refs: rename some parameters result -> sha1\n  clear_ref_list(): rename from free_ref_list()\n  resolve_gitlink_ref(): improve docstring\n  is_refname_available(): remove the \"quiet\" argument\n  parse_ref_line(): add docstring\n  add_ref(): add docstring\n  is_dup_ref(): extract function from sort_ref_list()\n  refs: change signatures of get_packed_refs() and get_loose_refs()\n  get_ref_dir(): change signature\n  Pass a (cached_refs *) to the resolve_gitlink_*() functions\n  resolve_gitlink_ref_recursive(): change to work with struct\n    cached_refs\n\n cache.h |   15 +++\n refs.c  |  418 +++++++++++++++++++++++++++++++++-----------------------------\n refs.h  |   34 +++--\n 3 files changed, 258 insertions(+), 209 deletions(-)\n\n-- \n1.7.7.rc2\n"},{"id":"177517","messageId":"1318492715-5931-2-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 01/14] cache.h: add comments for git_path() and git_path_submodule()","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:22Z","receivedAt":"2011-10-13T07:58:22Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n cache.h |   15 +++++++++++++++\n 1 files changed, 15 insertions(+), 0 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex e39e160..b94855e 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -660,7 +660,22 @@ extern char *git_pathdup(const char *fmt, ...)\n \n /* Return a statically allocated filename matching the sha1 signature */\n extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));\n+\n+/*\n+ * Return the path of a file within get_git_dir().  The arguments\n+ * should be printf-like arguments that produce the filename relative\n+ * to get_git_dir().  Return the resulting path, or \"/bad-path/\" if\n+ * there is an error.\n+ */\n extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));\n+\n+/*\n+ * Return the path of a file within the submodule located at path.\n+ * The other arguments should be printf-like arguments that produce\n+ * the filename relative to \"<path>/.git\".  If \"<path>/.git\" is a\n+ * gitlink file, follow it to find the actual submodule git path.\n+ * Return the resulting path, or \"/bad-path/\" if there is an error.\n+ */\n extern char *git_path_submodule(const char *path, const char *fmt, ...)\n \t__attribute__((format (printf, 2, 3)));\n \n-- \n1.7.7.rc2\n"},{"id":"177524","messageId":"1318492715-5931-3-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 02/14] struct ref_list: document name member","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:23Z","receivedAt":"2011-10-13T07:58:23Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 409314d..e4e4bcd 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -12,6 +12,7 @@ struct ref_entry {\n \tunsigned char flag; /* ISSYMREF? ISPACKED? */\n \tunsigned char sha1[20];\n \tunsigned char peeled[20];\n+\t/* The full name of the reference (e.g., \"refs/heads/master\"): */\n \tchar name[FLEX_ARRAY];\n };\n \n-- \n1.7.7.rc2\n"},{"id":"177521","messageId":"1318492715-5931-4-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 03/14] refs.c: rename some local \"refname\" variables","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:24Z","receivedAt":"2011-10-13T07:58:24Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nTry to consistently use the variable name \"refname\" when referring to\na string naming a reference.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |  276 +++++++++++++++++++++++++++++++++-------------------------------\n refs.h |   26 ++++---\n 2 files changed, 157 insertions(+), 145 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex e4e4bcd..2ae5d0d 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -49,7 +49,7 @@ static const char *parse_ref_line(char *line, unsigned char *sha1)\n \treturn line;\n }\n \n-static void add_ref(const char *name, const unsigned char *sha1,\n+static void add_ref(const char *refname, const unsigned char *sha1,\n \t\t    int flag, struct ref_array *refs,\n \t\t    struct ref_entry **new_entry)\n {\n@@ -57,13 +57,13 @@ static void add_ref(const char *name, const unsigned char *sha1,\n \tstruct ref_entry *entry;\n \n \t/* Allocate it and add it in.. */\n-\tlen = strlen(name) + 1;\n+\tlen = strlen(refname) + 1;\n \tentry = xmalloc(sizeof(struct ref_entry) + len);\n \thashcpy(entry->sha1, sha1);\n \thashclr(entry->peeled);\n-\tif (check_refname_format(name, REFNAME_ALLOW_ONELEVEL|REFNAME_DOT_COMPONENT))\n-\t\tdie(\"Reference has invalid format: '%s'\", name);\n-\tmemcpy(entry->name, name, len);\n+\tif (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL|REFNAME_DOT_COMPONENT))\n+\t\tdie(\"Reference has invalid format: '%s'\", refname);\n+\tmemcpy(entry->name, refname, len);\n \tentry->flag = flag;\n \tif (new_entry)\n \t\t*new_entry = entry;\n@@ -106,20 +106,20 @@ static void sort_ref_array(struct ref_array *array)\n \tarray->nr = i + 1;\n }\n \n-static struct ref_entry *search_ref_array(struct ref_array *array, const char *name)\n+static struct ref_entry *search_ref_array(struct ref_array *array, const char *refname)\n {\n \tstruct ref_entry *e, **r;\n \tint len;\n \n-\tif (name == NULL)\n+\tif (refname == NULL)\n \t\treturn NULL;\n \n \tif (!array->nr)\n \t\treturn NULL;\n \n-\tlen = strlen(name) + 1;\n+\tlen = strlen(refname) + 1;\n \te = xmalloc(sizeof(struct ref_entry) + len);\n-\tmemcpy(e->name, name, len);\n+\tmemcpy(e->name, refname, len);\n \n \tr = bsearch(&e, array->refs, array->nr, sizeof(*array->refs), ref_entry_cmp);\n \n@@ -223,7 +223,7 @@ static void read_packed_refs(FILE *f, struct ref_array *array)\n \n \twhile (fgets(refline, sizeof(refline), f)) {\n \t\tunsigned char sha1[20];\n-\t\tconst char *name;\n+\t\tconst char *refname;\n \t\tstatic const char header[] = \"# pack-refs with:\";\n \n \t\tif (!strncmp(refline, header, sizeof(header)-1)) {\n@@ -234,9 +234,9 @@ static void read_packed_refs(FILE *f, struct ref_array *array)\n \t\t\tcontinue;\n \t\t}\n \n-\t\tname = parse_ref_line(refline, sha1);\n-\t\tif (name) {\n-\t\t\tadd_ref(name, sha1, flag, array, &last);\n+\t\trefname = parse_ref_line(refline, sha1);\n+\t\tif (refname) {\n+\t\t\tadd_ref(refname, sha1, flag, array, &last);\n \t\t\tcontinue;\n \t\t}\n \t\tif (last &&\n@@ -249,9 +249,9 @@ static void read_packed_refs(FILE *f, struct ref_array *array)\n \tsort_ref_array(array);\n }\n \n-void add_extra_ref(const char *name, const unsigned char *sha1, int flag)\n+void add_extra_ref(const char *refname, const unsigned char *sha1, int flag)\n {\n-\tadd_ref(name, sha1, flag, &extra_refs, NULL);\n+\tadd_ref(refname, sha1, flag, &extra_refs, NULL);\n }\n \n void clear_extra_refs(void)\n@@ -397,7 +397,8 @@ static struct ref_array *get_loose_refs(const char *submodule)\n #define MAXDEPTH 5\n #define MAXREFLEN (1024)\n \n-static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refname, unsigned char *result)\n+static int resolve_gitlink_packed_ref(char *name, int pathlen,\n+\t\t\t\t      const char *refname, unsigned char *result)\n {\n \tint retval = -1;\n \tstruct ref_entry *ref;\n@@ -411,7 +412,9 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen, const char *refna\n \treturn retval;\n }\n \n-static int resolve_gitlink_ref_recursive(char *name, int pathlen, const char *refname, unsigned char *result, int recursion)\n+static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n+\t\t\t\t\t const char *refname, unsigned char *result,\n+\t\t\t\t\t int recursion)\n {\n \tint fd, len = strlen(refname);\n \tchar buffer[128], *p;\n@@ -478,10 +481,10 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re\n  * Try to read ref from the packed references.  On success, set sha1\n  * and return 0; otherwise, return -1.\n  */\n-static int get_packed_ref(const char *ref, unsigned char *sha1)\n+static int get_packed_ref(const char *refname, unsigned char *sha1)\n {\n \tstruct ref_array *packed = get_packed_refs(NULL);\n-\tstruct ref_entry *entry = search_ref_array(packed, ref);\n+\tstruct ref_entry *entry = search_ref_array(packed, refname);\n \tif (entry) {\n \t\thashcpy(sha1, entry->sha1);\n \t\treturn 0;\n@@ -489,18 +492,18 @@ static int get_packed_ref(const char *ref, unsigned char *sha1)\n \treturn -1;\n }\n \n-const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *flag)\n+const char *resolve_ref(const char *refname, unsigned char *sha1, int reading, int *flag)\n {\n \tint depth = MAXDEPTH;\n \tssize_t len;\n \tchar buffer[256];\n-\tstatic char ref_buffer[256];\n+\tstatic char refname_buffer[256];\n \tchar path[PATH_MAX];\n \n \tif (flag)\n \t\t*flag = 0;\n \n-\tif (check_refname_format(ref, REFNAME_ALLOW_ONELEVEL))\n+\tif (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))\n \t\treturn NULL;\n \n \tfor (;;) {\n@@ -511,7 +514,7 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *\n \t\tif (--depth < 0)\n \t\t\treturn NULL;\n \n-\t\tgit_snpath(path, sizeof(path), \"%s\", ref);\n+\t\tgit_snpath(path, sizeof(path), \"%s\", refname);\n \n \t\tif (lstat(path, &st) < 0) {\n \t\t\tif (errno != ENOENT)\n@@ -520,17 +523,17 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *\n \t\t\t * The loose reference file does not exist;\n \t\t\t * check for a packed reference.\n \t\t\t */\n-\t\t\tif (!get_packed_ref(ref, sha1)) {\n+\t\t\tif (!get_packed_ref(refname, sha1)) {\n \t\t\t\tif (flag)\n \t\t\t\t\t*flag |= REF_ISPACKED;\n-\t\t\t\treturn ref;\n+\t\t\t\treturn refname;\n \t\t\t}\n \t\t\t/* The reference is not a packed reference, either. */\n \t\t\tif (reading) {\n \t\t\t\treturn NULL;\n \t\t\t} else {\n \t\t\t\thashclr(sha1);\n-\t\t\t\treturn ref;\n+\t\t\t\treturn refname;\n \t\t\t}\n \t\t}\n \n@@ -542,8 +545,8 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *\n \t\t\tbuffer[len] = 0;\n \t\t\tif (!prefixcmp(buffer, \"refs/\") &&\n \t\t\t\t\t!check_refname_format(buffer, 0)) {\n-\t\t\t\tstrcpy(ref_buffer, buffer);\n-\t\t\t\tref = ref_buffer;\n+\t\t\t\tstrcpy(refname_buffer, buffer);\n+\t\t\t\trefname = refname_buffer;\n \t\t\t\tif (flag)\n \t\t\t\t\t*flag |= REF_ISSYMREF;\n \t\t\t\tcontinue;\n@@ -584,7 +587,7 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *\n \t\t\t\tpath);\n \t\t\treturn NULL;\n \t\t}\n-\t\tref = strcpy(ref_buffer, buf);\n+\t\trefname = strcpy(refname_buffer, buf);\n \t\tif (flag)\n \t\t\t*flag |= REF_ISSYMREF;\n \t}\n@@ -593,7 +596,7 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *\n \t\twarning(\"reference in %s is formatted incorrectly\", path);\n \t\treturn NULL;\n \t}\n-\treturn ref;\n+\treturn refname;\n }\n \n /* The argument to filter_refs */\n@@ -603,9 +606,9 @@ struct ref_filter {\n \tvoid *cb_data;\n };\n \n-int read_ref(const char *ref, unsigned char *sha1)\n+int read_ref(const char *refname, unsigned char *sha1)\n {\n-\tif (resolve_ref(ref, sha1, 1, NULL))\n+\tif (resolve_ref(refname, sha1, 1, NULL))\n \t\treturn 0;\n \treturn -1;\n }\n@@ -629,23 +632,23 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,\n \treturn fn(entry->name + trim, entry->sha1, entry->flag, cb_data);\n }\n \n-static int filter_refs(const char *ref, const unsigned char *sha, int flags,\n+static int filter_refs(const char *refname, const unsigned char *sha, int flags,\n \tvoid *data)\n {\n \tstruct ref_filter *filter = (struct ref_filter *)data;\n-\tif (fnmatch(filter->pattern, ref, 0))\n+\tif (fnmatch(filter->pattern, refname, 0))\n \t\treturn 0;\n-\treturn filter->fn(ref, sha, flags, filter->cb_data);\n+\treturn filter->fn(refname, sha, flags, filter->cb_data);\n }\n \n-int peel_ref(const char *ref, unsigned char *sha1)\n+int peel_ref(const char *refname, unsigned char *sha1)\n {\n \tint flag;\n \tunsigned char base[20];\n \tstruct object *o;\n \n-\tif (current_ref && (current_ref->name == ref\n-\t\t|| !strcmp(current_ref->name, ref))) {\n+\tif (current_ref && (current_ref->name == refname\n+\t\t|| !strcmp(current_ref->name, refname))) {\n \t\tif (current_ref->flag & REF_KNOWS_PEELED) {\n \t\t\thashcpy(sha1, current_ref->peeled);\n \t\t\treturn 0;\n@@ -654,12 +657,12 @@ int peel_ref(const char *ref, unsigned char *sha1)\n \t\tgoto fallback;\n \t}\n \n-\tif (!resolve_ref(ref, base, 1, &flag))\n+\tif (!resolve_ref(refname, base, 1, &flag))\n \t\treturn -1;\n \n \tif ((flag & REF_ISPACKED)) {\n \t\tstruct ref_array *array = get_packed_refs(NULL);\n-\t\tstruct ref_entry *r = search_ref_array(array, ref);\n+\t\tstruct ref_entry *r = search_ref_array(array, refname);\n \n \t\tif (r != NULL && r->flag & REF_KNOWS_PEELED) {\n \t\t\thashcpy(sha1, r->peeled);\n@@ -670,7 +673,7 @@ int peel_ref(const char *ref, unsigned char *sha1)\n fallback:\n \to = parse_object(base);\n \tif (o && o->type == OBJ_TAG) {\n-\t\to = deref_tag(o, ref, 0);\n+\t\to = deref_tag(o, refname, 0);\n \t\tif (o) {\n \t\t\thashcpy(sha1, o->sha1);\n \t\t\treturn 0;\n@@ -900,16 +903,16 @@ static inline int bad_ref_char(int ch)\n }\n \n /*\n- * Try to read one refname component from the front of ref.  Return\n+ * Try to read one refname component from the front of refname.  Return\n  * the length of the component found, or -1 if the component is not\n  * legal.\n  */\n-static int check_refname_component(const char *ref, int flags)\n+static int check_refname_component(const char *refname, int flags)\n {\n \tconst char *cp;\n \tchar last = '\\0';\n \n-\tfor (cp = ref; ; cp++) {\n+\tfor (cp = refname; ; cp++) {\n \t\tchar ch = *cp;\n \t\tif (ch == '\\0' || ch == '/')\n \t\t\tbreak;\n@@ -921,34 +924,34 @@ static int check_refname_component(const char *ref, int flags)\n \t\t\treturn -1; /* Refname contains \"@{\". */\n \t\tlast = ch;\n \t}\n-\tif (cp == ref)\n+\tif (cp == refname)\n \t\treturn -1; /* Component has zero length. */\n-\tif (ref[0] == '.') {\n+\tif (refname[0] == '.') {\n \t\tif (!(flags & REFNAME_DOT_COMPONENT))\n \t\t\treturn -1; /* Component starts with '.'. */\n \t\t/*\n \t\t * Even if leading dots are allowed, don't allow \".\"\n \t\t * as a component (\"..\" is prevented by a rule above).\n \t\t */\n-\t\tif (ref[1] == '\\0')\n+\t\tif (refname[1] == '\\0')\n \t\t\treturn -1; /* Component equals \".\". */\n \t}\n-\tif (cp - ref >= 5 && !memcmp(cp - 5, \".lock\", 5))\n+\tif (cp - refname >= 5 && !memcmp(cp - 5, \".lock\", 5))\n \t\treturn -1; /* Refname ends with \".lock\". */\n-\treturn cp - ref;\n+\treturn cp - refname;\n }\n \n-int check_refname_format(const char *ref, int flags)\n+int check_refname_format(const char *refname, int flags)\n {\n \tint component_len, component_count = 0;\n \n \twhile (1) {\n \t\t/* We are at the start of a path component. */\n-\t\tcomponent_len = check_refname_component(ref, flags);\n+\t\tcomponent_len = check_refname_component(refname, flags);\n \t\tif (component_len < 0) {\n \t\t\tif ((flags & REFNAME_REFSPEC_PATTERN) &&\n-\t\t\t\t\tref[0] == '*' &&\n-\t\t\t\t\t(ref[1] == '\\0' || ref[1] == '/')) {\n+\t\t\t\t\trefname[0] == '*' &&\n+\t\t\t\t\t(refname[1] == '\\0' || refname[1] == '/')) {\n \t\t\t\t/* Accept one wildcard as a full refname component. */\n \t\t\t\tflags &= ~REFNAME_REFSPEC_PATTERN;\n \t\t\t\tcomponent_len = 1;\n@@ -957,13 +960,13 @@ int check_refname_format(const char *ref, int flags)\n \t\t\t}\n \t\t}\n \t\tcomponent_count++;\n-\t\tif (ref[component_len] == '\\0')\n+\t\tif (refname[component_len] == '\\0')\n \t\t\tbreak;\n \t\t/* Skip to next component. */\n-\t\tref += component_len + 1;\n+\t\trefname += component_len + 1;\n \t}\n \n-\tif (ref[component_len - 1] == '.')\n+\tif (refname[component_len - 1] == '.')\n \t\treturn -1; /* Refname ends with '.'. */\n \tif (!(flags & REFNAME_ALLOW_ONELEVEL) && component_count < 2)\n \t\treturn -1; /* Refname has only one component. */\n@@ -1046,22 +1049,22 @@ static int remove_empty_directories(const char *file)\n \treturn result;\n }\n \n-static int is_refname_available(const char *ref, const char *oldref,\n+static int is_refname_available(const char *refname, const char *oldrefname,\n \t\t\t\tstruct ref_array *array, int quiet)\n {\n-\tint i, namlen = strlen(ref); /* e.g. 'foo/bar' */\n+\tint i, namlen = strlen(refname); /* e.g. 'foo/bar' */\n \tfor (i = 0; i < array->nr; i++ ) {\n \t\tstruct ref_entry *entry = array->refs[i];\n \t\t/* entry->name could be 'foo' or 'foo/bar/baz' */\n-\t\tif (!oldref || strcmp(oldref, entry->name)) {\n+\t\tif (!oldrefname || strcmp(oldrefname, entry->name)) {\n \t\t\tint len = strlen(entry->name);\n \t\t\tint cmplen = (namlen < len) ? namlen : len;\n-\t\t\tconst char *lead = (namlen < len) ? entry->name : ref;\n-\t\t\tif (!strncmp(ref, entry->name, cmplen) &&\n+\t\t\tconst char *lead = (namlen < len) ? entry->name : refname;\n+\t\t\tif (!strncmp(refname, entry->name, cmplen) &&\n \t\t\t    lead[cmplen] == '/') {\n \t\t\t\tif (!quiet)\n \t\t\t\t\terror(\"'%s' exists; cannot create '%s'\",\n-\t\t\t\t\t      entry->name, ref);\n+\t\t\t\t\t      entry->name, refname);\n \t\t\t\treturn 0;\n \t\t\t}\n \t\t}\n@@ -1069,10 +1072,12 @@ static int is_refname_available(const char *ref, const char *oldref,\n \treturn 1;\n }\n \n-static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char *old_sha1, int flags, int *type_p)\n+static struct ref_lock *lock_ref_sha1_basic(const char *refname,\n+\t\t\t\t\t    const unsigned char *old_sha1,\n+\t\t\t\t\t    int flags, int *type_p)\n {\n \tchar *ref_file;\n-\tconst char *orig_ref = ref;\n+\tconst char *orig_refname = refname;\n \tstruct ref_lock *lock;\n \tint last_errno = 0;\n \tint type, lflags;\n@@ -1082,27 +1087,27 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char\n \tlock = xcalloc(1, sizeof(struct ref_lock));\n \tlock->lock_fd = -1;\n \n-\tref = resolve_ref(ref, lock->old_sha1, mustexist, &type);\n-\tif (!ref && errno == EISDIR) {\n+\trefname = resolve_ref(refname, lock->old_sha1, mustexist, &type);\n+\tif (!refname && errno == EISDIR) {\n \t\t/* we are trying to lock foo but we used to\n \t\t * have foo/bar which now does not exist;\n \t\t * it is normal for the empty directory 'foo'\n \t\t * to remain.\n \t\t */\n-\t\tref_file = git_path(\"%s\", orig_ref);\n+\t\tref_file = git_path(\"%s\", orig_refname);\n \t\tif (remove_empty_directories(ref_file)) {\n \t\t\tlast_errno = errno;\n-\t\t\terror(\"there are still refs under '%s'\", orig_ref);\n+\t\t\terror(\"there are still refs under '%s'\", orig_refname);\n \t\t\tgoto error_return;\n \t\t}\n-\t\tref = resolve_ref(orig_ref, lock->old_sha1, mustexist, &type);\n+\t\trefname = resolve_ref(orig_refname, lock->old_sha1, mustexist, &type);\n \t}\n \tif (type_p)\n \t    *type_p = type;\n-\tif (!ref) {\n+\tif (!refname) {\n \t\tlast_errno = errno;\n \t\terror(\"unable to resolve reference %s: %s\",\n-\t\t\torig_ref, strerror(errno));\n+\t\t\torig_refname, strerror(errno));\n \t\tgoto error_return;\n \t}\n \tmissing = is_null_sha1(lock->old_sha1);\n@@ -1112,7 +1117,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char\n \t * name is a proper prefix of our refname.\n \t */\n \tif (missing &&\n-\t     !is_refname_available(ref, NULL, get_packed_refs(NULL), 0)) {\n+\t     !is_refname_available(refname, NULL, get_packed_refs(NULL), 0)) {\n \t\tlast_errno = ENOTDIR;\n \t\tgoto error_return;\n \t}\n@@ -1121,12 +1126,12 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char\n \n \tlflags = LOCK_DIE_ON_ERROR;\n \tif (flags & REF_NODEREF) {\n-\t\tref = orig_ref;\n+\t\trefname = orig_refname;\n \t\tlflags |= LOCK_NODEREF;\n \t}\n-\tlock->ref_name = xstrdup(ref);\n-\tlock->orig_ref_name = xstrdup(orig_ref);\n-\tref_file = git_path(\"%s\", ref);\n+\tlock->ref_name = xstrdup(refname);\n+\tlock->orig_ref_name = xstrdup(orig_refname);\n+\tref_file = git_path(\"%s\", refname);\n \tif (missing)\n \t\tlock->force_write = 1;\n \tif ((flags & REF_NODEREF) && (type & REF_ISSYMREF))\n@@ -1147,20 +1152,21 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char\n \treturn NULL;\n }\n \n-struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)\n+struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha1)\n {\n \tchar refpath[PATH_MAX];\n-\tif (check_refname_format(ref, 0))\n+\tif (check_refname_format(refname, 0))\n \t\treturn NULL;\n-\tstrcpy(refpath, mkpath(\"refs/%s\", ref));\n+\tstrcpy(refpath, mkpath(\"refs/%s\", refname));\n \treturn lock_ref_sha1_basic(refpath, old_sha1, 0, NULL);\n }\n \n-struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags)\n+struct ref_lock *lock_any_ref_for_update(const char *refname,\n+\t\t\t\t\t const unsigned char *old_sha1, int flags)\n {\n-\tif (check_refname_format(ref, REFNAME_ALLOW_ONELEVEL))\n+\tif (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL))\n \t\treturn NULL;\n-\treturn lock_ref_sha1_basic(ref, old_sha1, flags, NULL);\n+\treturn lock_ref_sha1_basic(refname, old_sha1, flags, NULL);\n }\n \n static struct lock_file packlock;\n@@ -1246,30 +1252,30 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)\n  */\n #define TMP_RENAMED_LOG  \"logs/refs/.tmp-renamed-log\"\n \n-int rename_ref(const char *oldref, const char *newref, const char *logmsg)\n+int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg)\n {\n \tstatic const char renamed_ref[] = \"RENAMED-REF\";\n \tunsigned char sha1[20], orig_sha1[20];\n \tint flag = 0, logmoved = 0;\n \tstruct ref_lock *lock;\n \tstruct stat loginfo;\n-\tint log = !lstat(git_path(\"logs/%s\", oldref), &loginfo);\n+\tint log = !lstat(git_path(\"logs/%s\", oldrefname), &loginfo);\n \tconst char *symref = NULL;\n \n \tif (log && S_ISLNK(loginfo.st_mode))\n-\t\treturn error(\"reflog for %s is a symlink\", oldref);\n+\t\treturn error(\"reflog for %s is a symlink\", oldrefname);\n \n-\tsymref = resolve_ref(oldref, orig_sha1, 1, &flag);\n+\tsymref = resolve_ref(oldrefname, orig_sha1, 1, &flag);\n \tif (flag & REF_ISSYMREF)\n \t\treturn error(\"refname %s is a symbolic ref, renaming it is not supported\",\n-\t\t\toldref);\n+\t\t\toldrefname);\n \tif (!symref)\n-\t\treturn error(\"refname %s not found\", oldref);\n+\t\treturn error(\"refname %s not found\", oldrefname);\n \n-\tif (!is_refname_available(newref, oldref, get_packed_refs(NULL), 0))\n+\tif (!is_refname_available(newrefname, oldrefname, get_packed_refs(NULL), 0))\n \t\treturn 1;\n \n-\tif (!is_refname_available(newref, oldref, get_loose_refs(NULL), 0))\n+\tif (!is_refname_available(newrefname, oldrefname, get_loose_refs(NULL), 0))\n \t\treturn 1;\n \n \tlock = lock_ref_sha1_basic(renamed_ref, NULL, 0, NULL);\n@@ -1279,71 +1285,71 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)\n \tif (write_ref_sha1(lock, orig_sha1, logmsg))\n \t\treturn error(\"unable to save current sha1 in %s\", renamed_ref);\n \n-\tif (log && rename(git_path(\"logs/%s\", oldref), git_path(TMP_RENAMED_LOG)))\n+\tif (log && rename(git_path(\"logs/%s\", oldrefname), git_path(TMP_RENAMED_LOG)))\n \t\treturn error(\"unable to move logfile logs/%s to \"TMP_RENAMED_LOG\": %s\",\n-\t\t\toldref, strerror(errno));\n+\t\t\toldrefname, strerror(errno));\n \n-\tif (delete_ref(oldref, orig_sha1, REF_NODEREF)) {\n-\t\terror(\"unable to delete old %s\", oldref);\n+\tif (delete_ref(oldrefname, orig_sha1, REF_NODEREF)) {\n+\t\terror(\"unable to delete old %s\", oldrefname);\n \t\tgoto rollback;\n \t}\n \n-\tif (resolve_ref(newref, sha1, 1, &flag) && delete_ref(newref, sha1, REF_NODEREF)) {\n+\tif (resolve_ref(newrefname, sha1, 1, &flag) && delete_ref(newrefname, sha1, REF_NODEREF)) {\n \t\tif (errno==EISDIR) {\n-\t\t\tif (remove_empty_directories(git_path(\"%s\", newref))) {\n-\t\t\t\terror(\"Directory not empty: %s\", newref);\n+\t\t\tif (remove_empty_directories(git_path(\"%s\", newrefname))) {\n+\t\t\t\terror(\"Directory not empty: %s\", newrefname);\n \t\t\t\tgoto rollback;\n \t\t\t}\n \t\t} else {\n-\t\t\terror(\"unable to delete existing %s\", newref);\n+\t\t\terror(\"unable to delete existing %s\", newrefname);\n \t\t\tgoto rollback;\n \t\t}\n \t}\n \n-\tif (log && safe_create_leading_directories(git_path(\"logs/%s\", newref))) {\n-\t\terror(\"unable to create directory for %s\", newref);\n+\tif (log && safe_create_leading_directories(git_path(\"logs/%s\", newrefname))) {\n+\t\terror(\"unable to create directory for %s\", newrefname);\n \t\tgoto rollback;\n \t}\n \n  retry:\n-\tif (log && rename(git_path(TMP_RENAMED_LOG), git_path(\"logs/%s\", newref))) {\n+\tif (log && rename(git_path(TMP_RENAMED_LOG), git_path(\"logs/%s\", newrefname))) {\n \t\tif (errno==EISDIR || errno==ENOTDIR) {\n \t\t\t/*\n \t\t\t * rename(a, b) when b is an existing\n \t\t\t * directory ought to result in ISDIR, but\n \t\t\t * Solaris 5.8 gives ENOTDIR.  Sheesh.\n \t\t\t */\n-\t\t\tif (remove_empty_directories(git_path(\"logs/%s\", newref))) {\n-\t\t\t\terror(\"Directory not empty: logs/%s\", newref);\n+\t\t\tif (remove_empty_directories(git_path(\"logs/%s\", newrefname))) {\n+\t\t\t\terror(\"Directory not empty: logs/%s\", newrefname);\n \t\t\t\tgoto rollback;\n \t\t\t}\n \t\t\tgoto retry;\n \t\t} else {\n \t\t\terror(\"unable to move logfile \"TMP_RENAMED_LOG\" to logs/%s: %s\",\n-\t\t\t\tnewref, strerror(errno));\n+\t\t\t\tnewrefname, strerror(errno));\n \t\t\tgoto rollback;\n \t\t}\n \t}\n \tlogmoved = log;\n \n-\tlock = lock_ref_sha1_basic(newref, NULL, 0, NULL);\n+\tlock = lock_ref_sha1_basic(newrefname, NULL, 0, NULL);\n \tif (!lock) {\n-\t\terror(\"unable to lock %s for update\", newref);\n+\t\terror(\"unable to lock %s for update\", newrefname);\n \t\tgoto rollback;\n \t}\n \tlock->force_write = 1;\n \thashcpy(lock->old_sha1, orig_sha1);\n \tif (write_ref_sha1(lock, orig_sha1, logmsg)) {\n-\t\terror(\"unable to write current sha1 into %s\", newref);\n+\t\terror(\"unable to write current sha1 into %s\", newrefname);\n \t\tgoto rollback;\n \t}\n \n \treturn 0;\n \n  rollback:\n-\tlock = lock_ref_sha1_basic(oldref, NULL, 0, NULL);\n+\tlock = lock_ref_sha1_basic(oldrefname, NULL, 0, NULL);\n \tif (!lock) {\n-\t\terror(\"unable to lock %s for rollback\", oldref);\n+\t\terror(\"unable to lock %s for rollback\", oldrefname);\n \t\tgoto rollbacklog;\n \t}\n \n@@ -1351,17 +1357,17 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)\n \tflag = log_all_ref_updates;\n \tlog_all_ref_updates = 0;\n \tif (write_ref_sha1(lock, orig_sha1, NULL))\n-\t\terror(\"unable to write current sha1 into %s\", oldref);\n+\t\terror(\"unable to write current sha1 into %s\", oldrefname);\n \tlog_all_ref_updates = flag;\n \n  rollbacklog:\n-\tif (logmoved && rename(git_path(\"logs/%s\", newref), git_path(\"logs/%s\", oldref)))\n+\tif (logmoved && rename(git_path(\"logs/%s\", newrefname), git_path(\"logs/%s\", oldrefname)))\n \t\terror(\"unable to restore logfile %s from %s: %s\",\n-\t\t\toldref, newref, strerror(errno));\n+\t\t\toldrefname, newrefname, strerror(errno));\n \tif (!logmoved && log &&\n-\t    rename(git_path(TMP_RENAMED_LOG), git_path(\"logs/%s\", oldref)))\n+\t    rename(git_path(TMP_RENAMED_LOG), git_path(\"logs/%s\", oldrefname)))\n \t\terror(\"unable to restore logfile %s from \"TMP_RENAMED_LOG\": %s\",\n-\t\t\toldref, strerror(errno));\n+\t\t\toldrefname, strerror(errno));\n \n \treturn 1;\n }\n@@ -1418,16 +1424,16 @@ static int copy_msg(char *buf, const char *msg)\n \treturn cp - buf;\n }\n \n-int log_ref_setup(const char *ref_name, char *logfile, int bufsize)\n+int log_ref_setup(const char *refname, char *logfile, int bufsize)\n {\n \tint logfd, oflags = O_APPEND | O_WRONLY;\n \n-\tgit_snpath(logfile, bufsize, \"logs/%s\", ref_name);\n+\tgit_snpath(logfile, bufsize, \"logs/%s\", refname);\n \tif (log_all_ref_updates &&\n-\t    (!prefixcmp(ref_name, \"refs/heads/\") ||\n-\t     !prefixcmp(ref_name, \"refs/remotes/\") ||\n-\t     !prefixcmp(ref_name, \"refs/notes/\") ||\n-\t     !strcmp(ref_name, \"HEAD\"))) {\n+\t    (!prefixcmp(refname, \"refs/heads/\") ||\n+\t     !prefixcmp(refname, \"refs/remotes/\") ||\n+\t     !prefixcmp(refname, \"refs/notes/\") ||\n+\t     !strcmp(refname, \"HEAD\"))) {\n \t\tif (safe_create_leading_directories(logfile) < 0)\n \t\t\treturn error(\"unable to create directory for %s\",\n \t\t\t\t     logfile);\n@@ -1457,7 +1463,7 @@ int log_ref_setup(const char *ref_name, char *logfile, int bufsize)\n \treturn 0;\n }\n \n-static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,\n+static int log_ref_write(const char *refname, const unsigned char *old_sha1,\n \t\t\t const unsigned char *new_sha1, const char *msg)\n {\n \tint logfd, result, written, oflags = O_APPEND | O_WRONLY;\n@@ -1470,7 +1476,7 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,\n \tif (log_all_ref_updates < 0)\n \t\tlog_all_ref_updates = !is_bare_repository();\n \n-\tresult = log_ref_setup(ref_name, log_file, sizeof(log_file));\n+\tresult = log_ref_setup(refname, log_file, sizeof(log_file));\n \tif (result)\n \t\treturn result;\n \n@@ -1641,7 +1647,9 @@ static char *ref_msg(const char *line, const char *endp)\n \treturn xmemdupz(line, ep - line);\n }\n \n-int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)\n+int read_ref_at(const char *refname, unsigned long at_time, int cnt,\n+\t\tunsigned char *sha1, char **msg,\n+\t\tunsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)\n {\n \tconst char *logfile, *logdata, *logend, *rec, *lastgt, *lastrec;\n \tchar *tz_c;\n@@ -1652,7 +1660,7 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *\n \tvoid *log_mapped;\n \tsize_t mapsz;\n \n-\tlogfile = git_path(\"logs/%s\", ref);\n+\tlogfile = git_path(\"logs/%s\", refname);\n \tlogfd = open(logfile, O_RDONLY, 0);\n \tif (logfd < 0)\n \t\tdie_errno(\"Unable to read log '%s'\", logfile);\n@@ -1745,14 +1753,14 @@ int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *\n \treturn 1;\n }\n \n-int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs, void *cb_data)\n+int for_each_recent_reflog_ent(const char *refname, each_reflog_ent_fn fn, long ofs, void *cb_data)\n {\n \tconst char *logfile;\n \tFILE *logfp;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint ret = 0;\n \n-\tlogfile = git_path(\"logs/%s\", ref);\n+\tlogfile = git_path(\"logs/%s\", refname);\n \tlogfp = fopen(logfile, \"r\");\n \tif (!logfp)\n \t\treturn -1;\n@@ -1803,9 +1811,9 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs,\n \treturn ret;\n }\n \n-int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)\n+int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn, void *cb_data)\n {\n-\treturn for_each_recent_reflog_ent(ref, fn, 0, cb_data);\n+\treturn for_each_recent_reflog_ent(refname, fn, 0, cb_data);\n }\n \n static int do_for_each_reflog(const char *base, each_ref_fn fn, void *cb_data)\n@@ -1925,7 +1933,7 @@ static void gen_scanf_fmt(char *scanf_fmt, const char *rule)\n \treturn;\n }\n \n-char *shorten_unambiguous_ref(const char *ref, int strict)\n+char *shorten_unambiguous_ref(const char *refname, int strict)\n {\n \tint i;\n \tstatic char **scanf_fmts;\n@@ -1954,10 +1962,10 @@ char *shorten_unambiguous_ref(const char *ref, int strict)\n \n \t/* bail out if there are no rules */\n \tif (!nr_rules)\n-\t\treturn xstrdup(ref);\n+\t\treturn xstrdup(refname);\n \n-\t/* buffer for scanf result, at most ref must fit */\n-\tshort_name = xstrdup(ref);\n+\t/* buffer for scanf result, at most refname must fit */\n+\tshort_name = xstrdup(refname);\n \n \t/* skip first rule, it will always match */\n \tfor (i = nr_rules - 1; i > 0 ; --i) {\n@@ -1965,7 +1973,7 @@ char *shorten_unambiguous_ref(const char *ref, int strict)\n \t\tint rules_to_fail = i;\n \t\tint short_name_len;\n \n-\t\tif (1 != sscanf(ref, scanf_fmts[i], short_name))\n+\t\tif (1 != sscanf(refname, scanf_fmts[i], short_name))\n \t\t\tcontinue;\n \n \t\tshort_name_len = strlen(short_name);\n@@ -2010,5 +2018,5 @@ char *shorten_unambiguous_ref(const char *ref, int strict)\n \t}\n \n \tfree(short_name);\n-\treturn xstrdup(ref);\n+\treturn xstrdup(refname);\n }\ndiff --git a/refs.h b/refs.h\nindex f439c54..13e2aa3 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -59,14 +59,16 @@ extern void add_extra_ref(const char *refname, const unsigned char *sha1, int fl\n extern void clear_extra_refs(void);\n extern int ref_exists(const char *);\n \n-extern int peel_ref(const char *, unsigned char *);\n+extern int peel_ref(const char *refname, unsigned char *sha1);\n \n /** Locks a \"refs/\" ref returning the lock on success and NULL on failure. **/\n-extern struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1);\n+extern struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha1);\n \n /** Locks any ref (for 'HEAD' type refs). */\n #define REF_NODEREF\t0x01\n-extern struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags);\n+extern struct ref_lock *lock_any_ref_for_update(const char *refname,\n+\t\t\t\t\t\tconst unsigned char *old_sha1,\n+\t\t\t\t\t\tint flags);\n \n /** Close the file descriptor owned by a lock and return the status */\n extern int close_ref(struct ref_lock *lock);\n@@ -92,12 +94,14 @@ extern void invalidate_ref_cache(const char *submodule);\n int log_ref_setup(const char *ref_name, char *logfile, int bufsize);\n \n /** Reads log for the value of ref during at_time. **/\n-extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);\n+extern int read_ref_at(const char *refname, unsigned long at_time, int cnt,\n+\t\t       unsigned char *sha1, char **msg,\n+\t\t       unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);\n \n /* iterate over reflog entries */\n typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *);\n-int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data);\n-int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long, void *cb_data);\n+int for_each_reflog_ent(const char *refname, each_reflog_ent_fn fn, void *cb_data);\n+int for_each_recent_reflog_ent(const char *refname, each_reflog_ent_fn fn, long, void *cb_data);\n \n /*\n  * Calls the specified function for each reflog file until it returns nonzero,\n@@ -110,9 +114,9 @@ extern int for_each_reflog(each_ref_fn, void *);\n #define REFNAME_DOT_COMPONENT 4\n \n /*\n- * Return 0 iff ref has the correct format for a refname according to\n- * the rules described in Documentation/git-check-ref-format.txt.  If\n- * REFNAME_ALLOW_ONELEVEL is set in flags, then accept one-level\n+ * Return 0 iff refname has the correct format for a refname according\n+ * to the rules described in Documentation/git-check-ref-format.txt.\n+ * If REFNAME_ALLOW_ONELEVEL is set in flags, then accept one-level\n  * reference names.  If REFNAME_REFSPEC_PATTERN is set in flags, then\n  * allow a \"*\" wildcard character in place of one of the name\n  * components.  No leading or repeated slashes are accepted.  If\n@@ -120,10 +124,10 @@ extern int for_each_reflog(each_ref_fn, void *);\n  * components to start with \".\" (but not a whole component equal to\n  * \".\" or \"..\").\n  */\n-extern int check_refname_format(const char *ref, int flags);\n+extern int check_refname_format(const char *refname, int flags);\n \n extern const char *prettify_refname(const char *refname);\n-extern char *shorten_unambiguous_ref(const char *ref, int strict);\n+extern char *shorten_unambiguous_ref(const char *refname, int strict);\n \n /** rename ref, return 0 on success **/\n extern int rename_ref(const char *oldref, const char *newref, const char *logmsg);\n-- \n1.7.7.rc2\n"},{"id":"177523","messageId":"1318492715-5931-5-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 04/14] refs: rename some parameters result -> sha1","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:25Z","receivedAt":"2011-10-13T07:58:25Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |   16 ++++++++--------\n refs.h |    2 +-\n 2 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 2ae5d0d..c466fcd 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -398,7 +398,7 @@ static struct ref_array *get_loose_refs(const char *submodule)\n #define MAXREFLEN (1024)\n \n static int resolve_gitlink_packed_ref(char *name, int pathlen,\n-\t\t\t\t      const char *refname, unsigned char *result)\n+\t\t\t\t      const char *refname, unsigned char *sha1)\n {\n \tint retval = -1;\n \tstruct ref_entry *ref;\n@@ -406,14 +406,14 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen,\n \n \tref = search_ref_array(array, refname);\n \tif (ref != NULL) {\n-\t\tmemcpy(result, ref->sha1, 20);\n+\t\tmemcpy(sha1, ref->sha1, 20);\n \t\tretval = 0;\n \t}\n \treturn retval;\n }\n \n static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n-\t\t\t\t\t const char *refname, unsigned char *result,\n+\t\t\t\t\t const char *refname, unsigned char *sha1,\n \t\t\t\t\t int recursion)\n {\n \tint fd, len = strlen(refname);\n@@ -424,7 +424,7 @@ static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n \tmemcpy(name + pathlen, refname, len+1);\n \tfd = open(name, O_RDONLY);\n \tif (fd < 0)\n-\t\treturn resolve_gitlink_packed_ref(name, pathlen, refname, result);\n+\t\treturn resolve_gitlink_packed_ref(name, pathlen, refname, sha1);\n \n \tlen = read(fd, buffer, sizeof(buffer)-1);\n \tclose(fd);\n@@ -435,7 +435,7 @@ static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n \tbuffer[len] = 0;\n \n \t/* Was it a detached head or an old-fashioned symlink? */\n-\tif (!get_sha1_hex(buffer, result))\n+\tif (!get_sha1_hex(buffer, sha1))\n \t\treturn 0;\n \n \t/* Symref? */\n@@ -445,10 +445,10 @@ static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n \twhile (isspace(*p))\n \t\tp++;\n \n-\treturn resolve_gitlink_ref_recursive(name, pathlen, p, result, recursion+1);\n+\treturn resolve_gitlink_ref_recursive(name, pathlen, p, sha1, recursion+1);\n }\n \n-int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *result)\n+int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sha1)\n {\n \tint len = strlen(path), retval;\n \tchar *gitdir;\n@@ -472,7 +472,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re\n \t}\n \tgitdir[len] = '/';\n \tgitdir[++len] = '\\0';\n-\tretval = resolve_gitlink_ref_recursive(gitdir, len, refname, result, 0);\n+\tretval = resolve_gitlink_ref_recursive(gitdir, len, refname, sha1, 0);\n \tfree(gitdir);\n \treturn retval;\n }\ndiff --git a/refs.h b/refs.h\nindex 13e2aa3..c6b8749 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -133,7 +133,7 @@ extern char *shorten_unambiguous_ref(const char *refname, int strict);\n extern int rename_ref(const char *oldref, const char *newref, const char *logmsg);\n \n /** resolve ref in nested \"gitlink\" repository */\n-extern int resolve_gitlink_ref(const char *name, const char *refname, unsigned char *result);\n+extern int resolve_gitlink_ref(const char *name, const char *refname, unsigned char *sha1);\n \n /** lock a ref and then write its file */\n enum action_on_err { MSG_ON_ERR, DIE_ON_ERR, QUIET_ON_ERR };\n-- \n1.7.7.rc2\n"},{"id":"177520","messageId":"1318492715-5931-6-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 05/14] clear_ref_list(): rename from free_ref_list()","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:26Z","receivedAt":"2011-10-13T07:58:26Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nRename the function since it doesn't actually free the array object\nthat is passed to it.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex c466fcd..a2e48e4 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -149,7 +149,7 @@ static struct ref_entry *current_ref;\n \n static struct ref_array extra_refs;\n \n-static void free_ref_array(struct ref_array *array)\n+static void clear_ref_array(struct ref_array *array)\n {\n \tint i;\n \tfor (i = 0; i < array->nr; i++)\n@@ -162,14 +162,14 @@ static void free_ref_array(struct ref_array *array)\n static void clear_cached_packed_refs(struct cached_refs *refs)\n {\n \tif (refs->did_packed)\n-\t\tfree_ref_array(&refs->packed);\n+\t\tclear_ref_array(&refs->packed);\n \trefs->did_packed = 0;\n }\n \n static void clear_cached_loose_refs(struct cached_refs *refs)\n {\n \tif (refs->did_loose)\n-\t\tfree_ref_array(&refs->loose);\n+\t\tclear_ref_array(&refs->loose);\n \trefs->did_loose = 0;\n }\n \n@@ -256,7 +256,7 @@ void add_extra_ref(const char *refname, const unsigned char *sha1, int flag)\n \n void clear_extra_refs(void)\n {\n-\tfree_ref_array(&extra_refs);\n+\tclear_ref_array(&extra_refs);\n }\n \n static struct ref_array *get_packed_refs(const char *submodule)\n-- \n1.7.7.rc2\n"},{"id":"177519","messageId":"1318492715-5931-7-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 06/14] resolve_gitlink_ref(): improve docstring","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:27Z","receivedAt":"2011-10-13T07:58:27Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.h |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/refs.h b/refs.h\nindex c6b8749..d9c90cf 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -132,7 +132,11 @@ extern char *shorten_unambiguous_ref(const char *refname, int strict);\n /** rename ref, return 0 on success **/\n extern int rename_ref(const char *oldref, const char *newref, const char *logmsg);\n \n-/** resolve ref in nested \"gitlink\" repository */\n+/**\n+ * Resolve refname in the nested \"gitlink\" repository that is located\n+ * at name.  If the resolution is successful, return 0 and set sha1 to\n+ * the name of the object; otherwise, return a non-zero value.\n+ */\n extern int resolve_gitlink_ref(const char *name, const char *refname, unsigned char *sha1);\n \n /** lock a ref and then write its file */\n-- \n1.7.7.rc2\n"},{"id":"177522","messageId":"1318492715-5931-8-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 07/14] is_refname_available(): remove the \"quiet\" argument","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:28Z","receivedAt":"2011-10-13T07:58:28Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nquiet was always set to 0, so get rid of it.  Add a function docstring\nfor good measure.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |   20 +++++++++++++-------\n 1 files changed, 13 insertions(+), 7 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex a2e48e4..7e84b63 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1049,8 +1049,15 @@ static int remove_empty_directories(const char *file)\n \treturn result;\n }\n \n+/*\n+ * Return true iff a reference named refname could be created without\n+ * conflicting with the name of an existing reference.  If oldrefname\n+ * is non-NULL, ignore potential conflicts with oldrefname (e.g.,\n+ * because oldrefname is scheduled for deletion in the same\n+ * operation).\n+ */\n static int is_refname_available(const char *refname, const char *oldrefname,\n-\t\t\t\tstruct ref_array *array, int quiet)\n+\t\t\t\tstruct ref_array *array)\n {\n \tint i, namlen = strlen(refname); /* e.g. 'foo/bar' */\n \tfor (i = 0; i < array->nr; i++ ) {\n@@ -1062,9 +1069,8 @@ static int is_refname_available(const char *refname, const char *oldrefname,\n \t\t\tconst char *lead = (namlen < len) ? entry->name : refname;\n \t\t\tif (!strncmp(refname, entry->name, cmplen) &&\n \t\t\t    lead[cmplen] == '/') {\n-\t\t\t\tif (!quiet)\n-\t\t\t\t\terror(\"'%s' exists; cannot create '%s'\",\n-\t\t\t\t\t      entry->name, refname);\n+\t\t\t\terror(\"'%s' exists; cannot create '%s'\",\n+\t\t\t\t      entry->name, refname);\n \t\t\t\treturn 0;\n \t\t\t}\n \t\t}\n@@ -1117,7 +1123,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,\n \t * name is a proper prefix of our refname.\n \t */\n \tif (missing &&\n-\t     !is_refname_available(refname, NULL, get_packed_refs(NULL), 0)) {\n+\t     !is_refname_available(refname, NULL, get_packed_refs(NULL))) {\n \t\tlast_errno = ENOTDIR;\n \t\tgoto error_return;\n \t}\n@@ -1272,10 +1278,10 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms\n \tif (!symref)\n \t\treturn error(\"refname %s not found\", oldrefname);\n \n-\tif (!is_refname_available(newrefname, oldrefname, get_packed_refs(NULL), 0))\n+\tif (!is_refname_available(newrefname, oldrefname, get_packed_refs(NULL)))\n \t\treturn 1;\n \n-\tif (!is_refname_available(newrefname, oldrefname, get_loose_refs(NULL), 0))\n+\tif (!is_refname_available(newrefname, oldrefname, get_loose_refs(NULL)))\n \t\treturn 1;\n \n \tlock = lock_ref_sha1_basic(renamed_ref, NULL, 0, NULL);\n-- \n1.7.7.rc2\n"},{"id":"177526","messageId":"1318492715-5931-9-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 08/14] parse_ref_line(): add docstring","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:29Z","receivedAt":"2011-10-13T07:58:29Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 7e84b63..abb03f7 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -21,6 +21,11 @@ struct ref_array {\n \tstruct ref_entry **refs;\n };\n \n+/*\n+ * Parse one line from a packed-refs file.  Return a pointer to the\n+ * name within the line (null-terminated), or NULL if there is a\n+ * problem.\n+ */\n static const char *parse_ref_line(char *line, unsigned char *sha1)\n {\n \t/*\n-- \n1.7.7.rc2\n"},{"id":"177525","messageId":"1318492715-5931-10-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 09/14] add_ref(): add docstring","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:30Z","receivedAt":"2011-10-13T07:58:30Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex abb03f7..cb5bb18 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -54,6 +54,7 @@ static const char *parse_ref_line(char *line, unsigned char *sha1)\n \treturn line;\n }\n \n+/* Add a ref_entry to the end of the ref_array (unsorted). */\n static void add_ref(const char *refname, const unsigned char *sha1,\n \t\t    int flag, struct ref_array *refs,\n \t\t    struct ref_entry **new_entry)\n-- \n1.7.7.rc2\n"},{"id":"177529","messageId":"1318492715-5931-11-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 10/14] is_dup_ref(): extract function from sort_ref_list()","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:31Z","receivedAt":"2011-10-13T07:58:31Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nGiving it a name makes the code easier to understand.  And the new\nfunction will be convenient later when it has to be called from\nmultiple places.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |   27 +++++++++++++++++++++------\n 1 files changed, 21 insertions(+), 6 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex cb5bb18..715a41a 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -84,6 +84,25 @@ static int ref_entry_cmp(const void *a, const void *b)\n \treturn strcmp(one->name, two->name);\n }\n \n+/*\n+ * Emit a warning and return true iff ref1 and ref2 have the same name\n+ * and the same sha1.  Die if they have the same name but different\n+ * sha1s.\n+ */\n+static int is_dup_ref(const struct ref_entry *ref1, const struct ref_entry *ref2)\n+{\n+\tif (!strcmp(ref1->name, ref2->name)) {\n+\t\t/* Duplicate name; make sure that the SHA1s match: */\n+\t\tif (hashcmp(ref1->sha1, ref2->sha1))\n+\t\t\tdie(\"Duplicated ref, and SHA1s don't match: %s\",\n+\t\t\t    ref1->name);\n+\t\twarning(\"Duplicated ref: %s\", ref1->name);\n+\t\treturn 1;\n+\t} else {\n+\t\treturn 0;\n+\t}\n+}\n+\n static void sort_ref_array(struct ref_array *array)\n {\n \tint i = 0, j = 1;\n@@ -94,15 +113,11 @@ static void sort_ref_array(struct ref_array *array)\n \n \tqsort(array->refs, array->nr, sizeof(*array->refs), ref_entry_cmp);\n \n-\t/* Remove any duplicates from the ref_array */\n+\t/* Remove any duplicates from the ref_list */\n \tfor (; j < array->nr; j++) {\n \t\tstruct ref_entry *a = array->refs[i];\n \t\tstruct ref_entry *b = array->refs[j];\n-\t\tif (!strcmp(a->name, b->name)) {\n-\t\t\tif (hashcmp(a->sha1, b->sha1))\n-\t\t\t\tdie(\"Duplicated ref, and SHA1s don't match: %s\",\n-\t\t\t\t    a->name);\n-\t\t\twarning(\"Duplicated ref: %s\", a->name);\n+\t\tif (is_dup_ref(a, b)) {\n \t\t\tfree(b);\n \t\t\tcontinue;\n \t\t}\n-- \n1.7.7.rc2\n"},{"id":"177527","messageId":"1318492715-5931-12-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 11/14] refs: change signatures of get_packed_refs() and get_loose_refs()","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:32Z","receivedAt":"2011-10-13T07:58:32Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nChange get_packed_refs() and get_loose_refs() to take a (struct\ncached_refs *) instead of the name of the submodule.\n\nChange get_ref_dir() to take a submodule name (i.e., \"\" for the main\nmodule) rather than a submodule pointer (i.e., NULL for the main\nmodule) so that refs->name can be used as its argument.  (In a moment\nthis function will also be changed to take a (struct cached_refs *),\ntoo.)\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |   36 +++++++++++++++++-------------------\n 1 files changed, 17 insertions(+), 19 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 715a41a..1109c9f 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -280,16 +280,14 @@ void clear_extra_refs(void)\n \tclear_ref_array(&extra_refs);\n }\n \n-static struct ref_array *get_packed_refs(const char *submodule)\n+static struct ref_array *get_packed_refs(struct cached_refs *refs)\n {\n-\tstruct cached_refs *refs = get_cached_refs(submodule);\n-\n \tif (!refs->did_packed) {\n \t\tconst char *packed_refs_file;\n \t\tFILE *f;\n \n-\t\tif (submodule)\n-\t\t\tpacked_refs_file = git_path_submodule(submodule, \"packed-refs\");\n+\t\tif (*refs->name)\n+\t\t\tpacked_refs_file = git_path_submodule(refs->name, \"packed-refs\");\n \t\telse\n \t\t\tpacked_refs_file = git_path(\"packed-refs\");\n \t\tf = fopen(packed_refs_file, \"r\");\n@@ -308,7 +306,7 @@ static void get_ref_dir(const char *submodule, const char *base,\n \tDIR *dir;\n \tconst char *path;\n \n-\tif (submodule)\n+\tif (*submodule)\n \t\tpath = git_path_submodule(submodule, \"%s\", base);\n \telse\n \t\tpath = git_path(\"%s\", base);\n@@ -402,12 +400,10 @@ void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)\n \tfor_each_rawref(warn_if_dangling_symref, &data);\n }\n \n-static struct ref_array *get_loose_refs(const char *submodule)\n+static struct ref_array *get_loose_refs(struct cached_refs *refs)\n {\n-\tstruct cached_refs *refs = get_cached_refs(submodule);\n-\n \tif (!refs->did_loose) {\n-\t\tget_ref_dir(submodule, \"refs\", &refs->loose);\n+\t\tget_ref_dir(refs->name, \"refs\", &refs->loose);\n \t\tsort_ref_array(&refs->loose);\n \t\trefs->did_loose = 1;\n \t}\n@@ -423,7 +419,7 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen,\n {\n \tint retval = -1;\n \tstruct ref_entry *ref;\n-\tstruct ref_array *array = get_packed_refs(name);\n+\tstruct ref_array *array = get_packed_refs(get_cached_refs(name));\n \n \tref = search_ref_array(array, refname);\n \tif (ref != NULL) {\n@@ -504,7 +500,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sh\n  */\n static int get_packed_ref(const char *refname, unsigned char *sha1)\n {\n-\tstruct ref_array *packed = get_packed_refs(NULL);\n+\tstruct ref_array *packed = get_packed_refs(get_cached_refs(NULL));\n \tstruct ref_entry *entry = search_ref_array(packed, refname);\n \tif (entry) {\n \t\thashcpy(sha1, entry->sha1);\n@@ -682,7 +678,7 @@ int peel_ref(const char *refname, unsigned char *sha1)\n \t\treturn -1;\n \n \tif ((flag & REF_ISPACKED)) {\n-\t\tstruct ref_array *array = get_packed_refs(NULL);\n+\t\tstruct ref_array *array = get_packed_refs(get_cached_refs(NULL));\n \t\tstruct ref_entry *r = search_ref_array(array, refname);\n \n \t\tif (r != NULL && r->flag & REF_KNOWS_PEELED) {\n@@ -707,8 +703,9 @@ static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn\n \t\t\t   int trim, int flags, void *cb_data)\n {\n \tint retval = 0, i, p = 0, l = 0;\n-\tstruct ref_array *packed = get_packed_refs(submodule);\n-\tstruct ref_array *loose = get_loose_refs(submodule);\n+\tstruct cached_refs *refs = get_cached_refs(submodule);\n+\tstruct ref_array *packed = get_packed_refs(refs);\n+\tstruct ref_array *loose = get_loose_refs(refs);\n \n \tstruct ref_array *extra = &extra_refs;\n \n@@ -1144,7 +1141,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,\n \t * name is a proper prefix of our refname.\n \t */\n \tif (missing &&\n-\t     !is_refname_available(refname, NULL, get_packed_refs(NULL))) {\n+\t     !is_refname_available(refname, NULL, get_packed_refs(get_cached_refs(NULL)))) {\n \t\tlast_errno = ENOTDIR;\n \t\tgoto error_return;\n \t}\n@@ -1204,7 +1201,7 @@ static int repack_without_ref(const char *refname)\n \tstruct ref_entry *ref;\n \tint fd, i;\n \n-\tpacked = get_packed_refs(NULL);\n+\tpacked = get_packed_refs(get_cached_refs(NULL));\n \tref = search_ref_array(packed, refname);\n \tif (ref == NULL)\n \t\treturn 0;\n@@ -1288,6 +1285,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms\n \tstruct stat loginfo;\n \tint log = !lstat(git_path(\"logs/%s\", oldrefname), &loginfo);\n \tconst char *symref = NULL;\n+\tstruct cached_refs *refs = get_cached_refs(NULL);\n \n \tif (log && S_ISLNK(loginfo.st_mode))\n \t\treturn error(\"reflog for %s is a symlink\", oldrefname);\n@@ -1299,10 +1297,10 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms\n \tif (!symref)\n \t\treturn error(\"refname %s not found\", oldrefname);\n \n-\tif (!is_refname_available(newrefname, oldrefname, get_packed_refs(NULL)))\n+\tif (!is_refname_available(newrefname, oldrefname, get_packed_refs(refs)))\n \t\treturn 1;\n \n-\tif (!is_refname_available(newrefname, oldrefname, get_loose_refs(NULL)))\n+\tif (!is_refname_available(newrefname, oldrefname, get_loose_refs(refs)))\n \t\treturn 1;\n \n \tlock = lock_ref_sha1_basic(renamed_ref, NULL, 0, NULL);\n-- \n1.7.7.rc2\n"},{"id":"177528","messageId":"1318492715-5931-13-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 12/14] get_ref_dir(): change signature","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:33Z","receivedAt":"2011-10-13T07:58:33Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nChange get_ref_dir() to take a (struct cached_refs *) in place of the\nsubmodule name.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |   18 +++++++++---------\n 1 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 1109c9f..01b8efd 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -300,14 +300,14 @@ static struct ref_array *get_packed_refs(struct cached_refs *refs)\n \treturn &refs->packed;\n }\n \n-static void get_ref_dir(const char *submodule, const char *base,\n+static void get_ref_dir(struct cached_refs *refs, const char *base,\n \t\t\tstruct ref_array *array)\n {\n \tDIR *dir;\n \tconst char *path;\n \n-\tif (*submodule)\n-\t\tpath = git_path_submodule(submodule, \"%s\", base);\n+\tif (*refs->name)\n+\t\tpath = git_path_submodule(refs->name, \"%s\", base);\n \telse\n \t\tpath = git_path(\"%s\", base);\n \n@@ -338,19 +338,19 @@ static void get_ref_dir(const char *submodule, const char *base,\n \t\t\tif (has_extension(de->d_name, \".lock\"))\n \t\t\t\tcontinue;\n \t\t\tmemcpy(ref + baselen, de->d_name, namelen+1);\n-\t\t\trefdir = submodule\n-\t\t\t\t? git_path_submodule(submodule, \"%s\", ref)\n+\t\t\trefdir = *refs->name\n+\t\t\t\t? git_path_submodule(refs->name, \"%s\", ref)\n \t\t\t\t: git_path(\"%s\", ref);\n \t\t\tif (stat(refdir, &st) < 0)\n \t\t\t\tcontinue;\n \t\t\tif (S_ISDIR(st.st_mode)) {\n-\t\t\t\tget_ref_dir(submodule, ref, array);\n+\t\t\t\tget_ref_dir(refs, ref, array);\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (submodule) {\n+\t\t\tif (*refs->name) {\n \t\t\t\thashclr(sha1);\n \t\t\t\tflag = 0;\n-\t\t\t\tif (resolve_gitlink_ref(submodule, ref, sha1) < 0) {\n+\t\t\t\tif (resolve_gitlink_ref(refs->name, ref, sha1) < 0) {\n \t\t\t\t\thashclr(sha1);\n \t\t\t\t\tflag |= REF_BROKEN;\n \t\t\t\t}\n@@ -403,7 +403,7 @@ void warn_dangling_symref(FILE *fp, const char *msg_fmt, const char *refname)\n static struct ref_array *get_loose_refs(struct cached_refs *refs)\n {\n \tif (!refs->did_loose) {\n-\t\tget_ref_dir(refs->name, \"refs\", &refs->loose);\n+\t\tget_ref_dir(refs, \"refs\", &refs->loose);\n \t\tsort_ref_array(&refs->loose);\n \t\trefs->did_loose = 1;\n \t}\n-- \n1.7.7.rc2\n"},{"id":"177530","messageId":"1318492715-5931-14-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 13/14] Pass a (cached_refs *) to the resolve_gitlink_*() functions","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:34Z","receivedAt":"2011-10-13T07:58:34Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nAnd remove some redundant arguments from resolve_gitlink_packed_ref().\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |   20 +++++++++++++-------\n 1 files changed, 13 insertions(+), 7 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 01b8efd..8776195 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -414,12 +414,12 @@ static struct ref_array *get_loose_refs(struct cached_refs *refs)\n #define MAXDEPTH 5\n #define MAXREFLEN (1024)\n \n-static int resolve_gitlink_packed_ref(char *name, int pathlen,\n+static int resolve_gitlink_packed_ref(struct cached_refs *refs,\n \t\t\t\t      const char *refname, unsigned char *sha1)\n {\n \tint retval = -1;\n \tstruct ref_entry *ref;\n-\tstruct ref_array *array = get_packed_refs(get_cached_refs(name));\n+\tstruct ref_array *array = get_packed_refs(refs);\n \n \tref = search_ref_array(array, refname);\n \tif (ref != NULL) {\n@@ -429,7 +429,8 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen,\n \treturn retval;\n }\n \n-static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n+static int resolve_gitlink_ref_recursive(struct cached_refs *refs,\n+\t\t\t\t\t char *name, int pathlen,\n \t\t\t\t\t const char *refname, unsigned char *sha1,\n \t\t\t\t\t int recursion)\n {\n@@ -441,7 +442,7 @@ static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n \tmemcpy(name + pathlen, refname, len+1);\n \tfd = open(name, O_RDONLY);\n \tif (fd < 0)\n-\t\treturn resolve_gitlink_packed_ref(name, pathlen, refname, sha1);\n+\t\treturn resolve_gitlink_packed_ref(refs, refname, sha1);\n \n \tlen = read(fd, buffer, sizeof(buffer)-1);\n \tclose(fd);\n@@ -462,19 +463,24 @@ static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n \twhile (isspace(*p))\n \t\tp++;\n \n-\treturn resolve_gitlink_ref_recursive(name, pathlen, p, sha1, recursion+1);\n+\treturn resolve_gitlink_ref_recursive(refs, name, pathlen, p, sha1, recursion+1);\n }\n \n int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sha1)\n {\n \tint len = strlen(path), retval;\n-\tchar *gitdir;\n+\tchar *submodule, *gitdir;\n+\tstruct cached_refs *refs;\n \tconst char *tmp;\n \n \twhile (len && path[len-1] == '/')\n \t\tlen--;\n \tif (!len)\n \t\treturn -1;\n+\tsubmodule = xstrndup(path, len);\n+\trefs = get_cached_refs(submodule);\n+\tfree(submodule);\n+\n \tgitdir = xmalloc(len + MAXREFLEN + 8);\n \tmemcpy(gitdir, path, len);\n \tmemcpy(gitdir + len, \"/.git\", 6);\n@@ -489,7 +495,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sh\n \t}\n \tgitdir[len] = '/';\n \tgitdir[++len] = '\\0';\n-\tretval = resolve_gitlink_ref_recursive(gitdir, len, refname, sha1, 0);\n+\tretval = resolve_gitlink_ref_recursive(refs, gitdir, len, refname, sha1, 0);\n \tfree(gitdir);\n \treturn retval;\n }\n-- \n1.7.7.rc2\n"},{"id":"177531","messageId":"1318492715-5931-15-git-send-email-mhagger@alum.mit.edu","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 14/14] resolve_gitlink_ref_recursive(): change to work with struct cached_refs","fromName":"","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-13T07:58:35Z","receivedAt":"2011-10-13T07:58:35Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"From: Michael Haggerty <mhagger@alum.mit.edu>\n\nresolve_gitlink_ref() and resolve_gitlink_ref_recursive(), together,\nbasically duplicated the code in git_path_submodule().  So use that\nfunction instead.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n refs.c |   34 ++++++++++------------------------\n 1 files changed, 10 insertions(+), 24 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 8776195..748ef1b 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -430,17 +430,19 @@ static int resolve_gitlink_packed_ref(struct cached_refs *refs,\n }\n \n static int resolve_gitlink_ref_recursive(struct cached_refs *refs,\n-\t\t\t\t\t char *name, int pathlen,\n \t\t\t\t\t const char *refname, unsigned char *sha1,\n \t\t\t\t\t int recursion)\n {\n-\tint fd, len = strlen(refname);\n+\tint fd, len;\n \tchar buffer[128], *p;\n+\tchar *path;\n \n-\tif (recursion > MAXDEPTH || len > MAXREFLEN)\n+\tif (recursion > MAXDEPTH || strlen(refname) > MAXREFLEN)\n \t\treturn -1;\n-\tmemcpy(name + pathlen, refname, len+1);\n-\tfd = open(name, O_RDONLY);\n+\tpath = *refs->name\n+\t\t? git_path_submodule(refs->name, \"%s\", refname)\n+\t\t: git_path(\"%s\", refname);\n+\tfd = open(path, O_RDONLY);\n \tif (fd < 0)\n \t\treturn resolve_gitlink_packed_ref(refs, refname, sha1);\n \n@@ -463,15 +465,14 @@ static int resolve_gitlink_ref_recursive(struct cached_refs *refs,\n \twhile (isspace(*p))\n \t\tp++;\n \n-\treturn resolve_gitlink_ref_recursive(refs, name, pathlen, p, sha1, recursion+1);\n+\treturn resolve_gitlink_ref_recursive(refs, p, sha1, recursion+1);\n }\n \n int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sha1)\n {\n \tint len = strlen(path), retval;\n-\tchar *submodule, *gitdir;\n+\tchar *submodule;\n \tstruct cached_refs *refs;\n-\tconst char *tmp;\n \n \twhile (len && path[len-1] == '/')\n \t\tlen--;\n@@ -481,22 +482,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sh\n \trefs = get_cached_refs(submodule);\n \tfree(submodule);\n \n-\tgitdir = xmalloc(len + MAXREFLEN + 8);\n-\tmemcpy(gitdir, path, len);\n-\tmemcpy(gitdir + len, \"/.git\", 6);\n-\tlen += 5;\n-\n-\ttmp = read_gitfile(gitdir);\n-\tif (tmp) {\n-\t\tfree(gitdir);\n-\t\tlen = strlen(tmp);\n-\t\tgitdir = xmalloc(len + MAXREFLEN + 3);\n-\t\tmemcpy(gitdir, tmp, len);\n-\t}\n-\tgitdir[len] = '/';\n-\tgitdir[++len] = '\\0';\n-\tretval = resolve_gitlink_ref_recursive(refs, gitdir, len, refname, sha1, 0);\n-\tfree(gitdir);\n+\tretval = resolve_gitlink_ref_recursive(refs, refname, sha1, 0);\n \treturn retval;\n }\n \n-- \n1.7.7.rc2\n"},{"id":"177532","messageId":"4E969BFC.50706@viscovery.net","threadId":"28662","inReplyTo":"1318492715-5931-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH] t1402-check-ref-format: skip tests of refs beginning with slash on Windows","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-10-13T08:06:20Z","receivedAt":"2011-10-13T08:06:20Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <j6t@kdbg.org>\n\nBash on Windows converts program arguments that look like absolute POSIX\npaths to their Windows form, i.e., drive-letter-colon format. For this\nreason, those tests in t1402 that check refs that begin with a slash do not\nwork as expected on Windows: valid_ref tests are doomed to fail, and\ninvalid_ref tests fail for the wrong reason (that there is a colon rather\nthan that they begin with a slash).\n\nSkip these tests.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\n---\nAm 10/13/2011 9:58, schrieb mhagger@alum.mit.edu:\n> From: Michael Haggerty <mhagger@alum.mit.edu>\n> \n> This is the next installment of the reference changes that I have been\n> working on.  This batch includes a lot of tidying up in preparation\n> for the real changes.\n\nThis patch is needed on top of mh/check-ref-format-3, or it could be\ninserted in front of this batch (which probably amounts to the same\nthing :-)\n\n-- Hannes\n\n t/t1402-check-ref-format.sh |   64 +++++++++++++++++++++---------------------\n 1 files changed, 32 insertions(+), 32 deletions(-)\n\ndiff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh\nindex 710fcca..dba5e97 100755\n--- a/t/t1402-check-ref-format.sh\n+++ b/t/t1402-check-ref-format.sh\n@@ -5,38 +5,38 @@ test_description='Test git check-ref-format'\n . ./test-lib.sh\n \n valid_ref() {\n-\tif test \"$#\" = 1\n-\tthen\n-\t\ttest_expect_success \"ref name '$1' is valid\" \\\n-\t\t\t\"git check-ref-format '$1'\"\n-\telse\n-\t\ttest_expect_success \"ref name '$1' is valid with options $2\" \\\n+\tprereq=\n+\tcase $1 in\n+\t[A-Z]*)\n+\t\tprereq=$1\n+\t\tshift\n+\tesac\n+\ttest_expect_success $prereq \"ref name '$1' is valid${2:+ with options $2}\" \\\n \t\t\t\"git check-ref-format $2 '$1'\"\n-\tfi\n }\n invalid_ref() {\n-\tif test \"$#\" = 1\n-\tthen\n-\t\ttest_expect_success \"ref name '$1' is invalid\" \\\n-\t\t\t\"test_must_fail git check-ref-format '$1'\"\n-\telse\n-\t\ttest_expect_success \"ref name '$1' is invalid with options $2\" \\\n+\tprereq=\n+\tcase $1 in\n+\t[A-Z]*)\n+\t\tprereq=$1\n+\t\tshift\n+\tesac\n+\ttest_expect_success $prereq \"ref name '$1' is invalid${2:+ with options $2}\" \\\n \t\t\t\"test_must_fail git check-ref-format $2 '$1'\"\n-\tfi\n }\n \n invalid_ref ''\n-invalid_ref '/'\n-invalid_ref '/' --allow-onelevel\n-invalid_ref '/' --normalize\n-invalid_ref '/' '--allow-onelevel --normalize'\n+invalid_ref NOT_MINGW '/'\n+invalid_ref NOT_MINGW '/' --allow-onelevel\n+invalid_ref NOT_MINGW '/' --normalize\n+invalid_ref NOT_MINGW '/' '--allow-onelevel --normalize'\n valid_ref 'foo/bar/baz'\n valid_ref 'foo/bar/baz' --normalize\n invalid_ref 'refs///heads/foo'\n valid_ref 'refs///heads/foo' --normalize\n invalid_ref 'heads/foo/'\n-invalid_ref '/heads/foo'\n-valid_ref '/heads/foo' --normalize\n+invalid_ref NOT_MINGW '/heads/foo'\n+valid_ref NOT_MINGW '/heads/foo' --normalize\n invalid_ref '///heads/foo'\n valid_ref '///heads/foo' --normalize\n invalid_ref './foo'\n@@ -115,14 +115,14 @@ invalid_ref \"$ref\" --refspec-pattern\n invalid_ref \"$ref\" '--refspec-pattern --allow-onelevel'\n \n ref='/foo'\n-invalid_ref \"$ref\"\n-invalid_ref \"$ref\" --allow-onelevel\n-invalid_ref \"$ref\" --refspec-pattern\n-invalid_ref \"$ref\" '--refspec-pattern --allow-onelevel'\n-invalid_ref \"$ref\" --normalize\n-valid_ref \"$ref\" '--allow-onelevel --normalize'\n-invalid_ref \"$ref\" '--refspec-pattern --normalize'\n-valid_ref \"$ref\" '--refspec-pattern --allow-onelevel --normalize'\n+invalid_ref NOT_MINGW \"$ref\"\n+invalid_ref NOT_MINGW \"$ref\" --allow-onelevel\n+invalid_ref NOT_MINGW \"$ref\" --refspec-pattern\n+invalid_ref NOT_MINGW \"$ref\" '--refspec-pattern --allow-onelevel'\n+invalid_ref NOT_MINGW \"$ref\" --normalize\n+valid_ref NOT_MINGW \"$ref\" '--allow-onelevel --normalize'\n+invalid_ref NOT_MINGW \"$ref\" '--refspec-pattern --normalize'\n+valid_ref NOT_MINGW \"$ref\" '--refspec-pattern --allow-onelevel --normalize'\n \n test_expect_success \"check-ref-format --branch @{-1}\" '\n \tT=$(git write-tree) &&\n@@ -155,21 +155,21 @@ test_expect_success 'check-ref-format --branch from subdir' '\n '\n \n valid_ref_normalized() {\n-\ttest_expect_success \"ref name '$1' simplifies to '$2'\" \"\n+\ttest_expect_success $3 \"ref name '$1' simplifies to '$2'\" \"\n \t\trefname=\\$(git check-ref-format --normalize '$1') &&\n \t\ttest \\\"\\$refname\\\" = '$2'\"\n }\n invalid_ref_normalized() {\n-\ttest_expect_success \"check-ref-format --normalize rejects '$1'\" \"\n+\ttest_expect_success $2 \"check-ref-format --normalize rejects '$1'\" \"\n \t\ttest_must_fail git check-ref-format --normalize '$1'\"\n }\n \n valid_ref_normalized 'heads/foo' 'heads/foo'\n valid_ref_normalized 'refs///heads/foo' 'refs/heads/foo'\n-valid_ref_normalized '/heads/foo' 'heads/foo'\n+valid_ref_normalized '/heads/foo' 'heads/foo' NOT_MINGW\n valid_ref_normalized '///heads/foo' 'heads/foo'\n invalid_ref_normalized 'foo'\n-invalid_ref_normalized '/foo'\n+invalid_ref_normalized '/foo' NOT_MINGW\n invalid_ref_normalized 'heads/foo/../bar'\n invalid_ref_normalized 'heads/./foo'\n invalid_ref_normalized 'heads\\foo'\n-- \n\"Atomic objects are neither active nor radioactive.\" --\nProgramming Languages -- C++, Final Committee Draft (Doc.N3092)\n"},{"id":"177543","messageId":"1318509685.7231.6.camel@drew-northup.unet.maine.edu","threadId":"28662","inReplyTo":"1318492715-5931-8-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH 07/14] is_refname_available(): remove the \"quiet\" argument","fromName":"Drew Northup","fromEmail":"drew.northup@maine.edu","sentAt":"2011-10-13T12:41:25Z","receivedAt":"2011-10-13T12:41:25Z","isPatch":true,"sender":{"key":"drew.northup@maine.edu","avatar":"https://avatars.githubusercontent.com/u/18331571?v=4"},"body":"\nOn Thu, 2011-10-13 at 09:58 +0200, mhagger@alum.mit.edu wrote:\n> From: Michael Haggerty <mhagger@alum.mit.edu>\n> \n> quiet was always set to 0, so get rid of it.  Add a function docstring\n> for good measure.\n\nI would like to know if perhaps it was an unfinished project somewhere\nto propagate the \"quiet\" option down to this level before removing the\nfunction argument. Comments?\n\n> +/*\n> + * Return true iff a reference named refname could be created without\n\nDid you really mean \"iff\" (as in \"if and only if\") or just plain \"if\"\nhere?\n\n> + * conflicting with the name of an existing reference.  If oldrefname\n> + * is non-NULL, ignore potential conflicts with oldrefname (e.g.,\n> + * because oldrefname is scheduled for deletion in the same\n> + * operation).\n> + */\n>  static int is_refname_available(const char *refname, const char *oldrefname,\n> -\t\t\t\tstruct ref_array *array, int quiet)\n> +\t\t\t\tstruct ref_array *array)\n>  {\n>  \tint i, namlen = strlen(refname); /* e.g. 'foo/bar' */\n>  \tfor (i = 0; i < array->nr; i++ ) {\n> @@ -1062,9 +1069,8 @@ static int is_refname_available(const char *refname, const char *oldrefname,\n>  \t\t\tconst char *lead = (namlen < len) ? entry->name : refname;\n>  \t\t\tif (!strncmp(refname, entry->name, cmplen) &&\n>  \t\t\t    lead[cmplen] == '/') {\n> -\t\t\t\tif (!quiet)\n> -\t\t\t\t\terror(\"'%s' exists; cannot create '%s'\",\n> -\t\t\t\t\t      entry->name, refname);\n> +\t\t\t\terror(\"'%s' exists; cannot create '%s'\",\n> +\t\t\t\t      entry->name, refname);\n>  \t\t\t\treturn 0;\n>  \t\t\t}\n>  \t\t}\n> @@ -1117,7 +1123,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,\n>  \t * name is a proper prefix of our refname.\n>  \t */\n>  \tif (missing &&\n> -\t     !is_refname_available(refname, NULL, get_packed_refs(NULL), 0)) {\n> +\t     !is_refname_available(refname, NULL, get_packed_refs(NULL))) {\n>  \t\tlast_errno = ENOTDIR;\n>  \t\tgoto error_return;\n>  \t}\n> @@ -1272,10 +1278,10 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms\n>  \tif (!symref)\n>  \t\treturn error(\"refname %s not found\", oldrefname);\n>  \n> -\tif (!is_refname_available(newrefname, oldrefname, get_packed_refs(NULL), 0))\n> +\tif (!is_refname_available(newrefname, oldrefname, get_packed_refs(NULL)))\n>  \t\treturn 1;\n>  \n> -\tif (!is_refname_available(newrefname, oldrefname, get_loose_refs(NULL), 0))\n> +\tif (!is_refname_available(newrefname, oldrefname, get_loose_refs(NULL)))\n>  \t\treturn 1;\n>  \n>  \tlock = lock_ref_sha1_basic(renamed_ref, NULL, 0, NULL);\n-- \n-Drew Northup\n________________________________________________\n\"As opposed to vegetable or mineral error?\"\n-John Pescatore, SANS NewsBites Vol. 12 Num. 59\n"},{"id":"177578","messageId":"7vvcrs4u2b.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"1318492715-5931-2-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH 01/14] cache.h: add comments for git_path() and git_path_submodule()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T18:37:00Z","receivedAt":"2011-10-13T18:37:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"mhagger@alum.mit.edu writes:\n\n> +\n> +/*\n> + * Return the path of a file within get_git_dir().  The arguments\n> + * should be printf-like arguments that produce the filename relative\n> + * to get_git_dir().  Return the resulting path, or \"/bad-path/\" if\n> + * there is an error.\n> + */\n>  extern char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));\n\nOk.\n\n> +/*\n> + * Return the path of a file within the submodule located at path.\n\nThis is confusing. Does this \"file within the submodule\" refer to files\nlike \"Makefile\" tracked in a submodule at \"dir\"?  Your description for\ngit_path() above makes it clear that the function is about files like\n\"index\" and \"HEAD\" that are part of the control information for the\ncurrent project, but the above gives an impression that you are talking\nabout files in the working tree of the submodule.\n\n> + * The other arguments should be printf-like arguments that produce\n> + * the filename relative to \"<path>/.git\".  If \"<path>/.git\" is a\n\nAnd the reader is puzzled by the sudden mention of <path>/.git here.\n\n> + * gitlink file, follow it to find the actual submodule git path.\n> + * Return the resulting path, or \"/bad-path/\" if there is an error.\n> + */\n>  extern char *git_path_submodule(const char *path, const char *fmt, ...)\n>  \t__attribute__((format (printf, 2, 3)));\n"},{"id":"177579","messageId":"7vr52g4u13.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"1318492715-5931-3-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH 02/14] struct ref_list: document name member","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T18:37:44Z","receivedAt":"2011-10-13T18:37:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"mhagger@alum.mit.edu writes:\n\n> From: Michael Haggerty <mhagger@alum.mit.edu>\n>\n>\n> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n> ---\n>  refs.c |    1 +\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n>\n> diff --git a/refs.c b/refs.c\n> index 409314d..e4e4bcd 100644\n> --- a/refs.c\n> +++ b/refs.c\n> @@ -12,6 +12,7 @@ struct ref_entry {\n>  \tunsigned char flag; /* ISSYMREF? ISPACKED? */\n>  \tunsigned char sha1[20];\n>  \tunsigned char peeled[20];\n> +\t/* The full name of the reference (e.g., \"refs/heads/master\"): */\n>  \tchar name[FLEX_ARRAY];\n>  };\n\nThanks. Needs retitling the patch, though.\n"},{"id":"177580","messageId":"7vmxd44ttt.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"1318492715-5931-5-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH 04/14] refs: rename some parameters result -> sha1","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T18:42:06Z","receivedAt":"2011-10-13T18:42:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"mhagger@alum.mit.edu writes:\n\n> From: Michael Haggerty <mhagger@alum.mit.edu>\n>\n>\n> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n\n[PATCH 03/14] was about a similar topic and explained itself a lot\nbetter.\n\nEven though it hinted as if it may be incomplete by saying \"some\" in the\nsubject, it was clear from the description that it consistently renamed\nall the \"name\"s that are about references, not just \"some\" randomly chosen\nones. It would have been better if the subject did not say \"some\" to avoid\nsuch implications.\n\nPlease give similar love to these sha1[] object names in this patch.\n\n> ---\n>  refs.c |   16 ++++++++--------\n>  refs.h |    2 +-\n>  2 files changed, 9 insertions(+), 9 deletions(-)\n>\n> diff --git a/refs.c b/refs.c\n> index 2ae5d0d..c466fcd 100644\n> --- a/refs.c\n> +++ b/refs.c\n> @@ -398,7 +398,7 @@ static struct ref_array *get_loose_refs(const char *submodule)\n>  #define MAXREFLEN (1024)\n>  \n>  static int resolve_gitlink_packed_ref(char *name, int pathlen,\n> -\t\t\t\t      const char *refname, unsigned char *result)\n> +\t\t\t\t      const char *refname, unsigned char *sha1)\n>  {\n>  \tint retval = -1;\n>  \tstruct ref_entry *ref;\n> @@ -406,14 +406,14 @@ static int resolve_gitlink_packed_ref(char *name, int pathlen,\n>  \n>  \tref = search_ref_array(array, refname);\n>  \tif (ref != NULL) {\n> -\t\tmemcpy(result, ref->sha1, 20);\n> +\t\tmemcpy(sha1, ref->sha1, 20);\n>  \t\tretval = 0;\n>  \t}\n>  \treturn retval;\n>  }\n>  \n>  static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n> -\t\t\t\t\t const char *refname, unsigned char *result,\n> +\t\t\t\t\t const char *refname, unsigned char *sha1,\n>  \t\t\t\t\t int recursion)\n>  {\n>  \tint fd, len = strlen(refname);\n> @@ -424,7 +424,7 @@ static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n>  \tmemcpy(name + pathlen, refname, len+1);\n>  \tfd = open(name, O_RDONLY);\n>  \tif (fd < 0)\n> -\t\treturn resolve_gitlink_packed_ref(name, pathlen, refname, result);\n> +\t\treturn resolve_gitlink_packed_ref(name, pathlen, refname, sha1);\n>  \n>  \tlen = read(fd, buffer, sizeof(buffer)-1);\n>  \tclose(fd);\n> @@ -435,7 +435,7 @@ static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n>  \tbuffer[len] = 0;\n>  \n>  \t/* Was it a detached head or an old-fashioned symlink? */\n> -\tif (!get_sha1_hex(buffer, result))\n> +\tif (!get_sha1_hex(buffer, sha1))\n>  \t\treturn 0;\n>  \n>  \t/* Symref? */\n> @@ -445,10 +445,10 @@ static int resolve_gitlink_ref_recursive(char *name, int pathlen,\n>  \twhile (isspace(*p))\n>  \t\tp++;\n>  \n> -\treturn resolve_gitlink_ref_recursive(name, pathlen, p, result, recursion+1);\n> +\treturn resolve_gitlink_ref_recursive(name, pathlen, p, sha1, recursion+1);\n>  }\n>  \n> -int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *result)\n> +int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *sha1)\n>  {\n>  \tint len = strlen(path), retval;\n>  \tchar *gitdir;\n> @@ -472,7 +472,7 @@ int resolve_gitlink_ref(const char *path, const char *refname, unsigned char *re\n>  \t}\n>  \tgitdir[len] = '/';\n>  \tgitdir[++len] = '\\0';\n> -\tretval = resolve_gitlink_ref_recursive(gitdir, len, refname, result, 0);\n> +\tretval = resolve_gitlink_ref_recursive(gitdir, len, refname, sha1, 0);\n>  \tfree(gitdir);\n>  \treturn retval;\n>  }\n> diff --git a/refs.h b/refs.h\n> index 13e2aa3..c6b8749 100644\n> --- a/refs.h\n> +++ b/refs.h\n> @@ -133,7 +133,7 @@ extern char *shorten_unambiguous_ref(const char *refname, int strict);\n>  extern int rename_ref(const char *oldref, const char *newref, const char *logmsg);\n>  \n>  /** resolve ref in nested \"gitlink\" repository */\n> -extern int resolve_gitlink_ref(const char *name, const char *refname, unsigned char *result);\n> +extern int resolve_gitlink_ref(const char *name, const char *refname, unsigned char *sha1);\n>  \n>  /** lock a ref and then write its file */\n>  enum action_on_err { MSG_ON_ERR, DIE_ON_ERR, QUIET_ON_ERR };\n"},{"id":"177581","messageId":"7vipns4trp.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"1318492715-5931-6-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH 05/14] clear_ref_list(): rename from free_ref_list()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T18:43:22Z","receivedAt":"2011-10-13T18:43:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"mhagger@alum.mit.edu writes:\n\n> From: Michael Haggerty <mhagger@alum.mit.edu>\n>\n> Rename the function since it doesn't actually free the array object\n> that is passed to it.\n\nThe commit log message correctly refers to the \"array-ness\" of the object\nbeing cleared. Needs retitling the patch to match.\n\n>\n> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n> ---\n>  refs.c |    8 ++++----\n>  1 files changed, 4 insertions(+), 4 deletions(-)\n>\n> diff --git a/refs.c b/refs.c\n> index c466fcd..a2e48e4 100644\n> --- a/refs.c\n> +++ b/refs.c\n> @@ -149,7 +149,7 @@ static struct ref_entry *current_ref;\n>  \n>  static struct ref_array extra_refs;\n>  \n> -static void free_ref_array(struct ref_array *array)\n> +static void clear_ref_array(struct ref_array *array)\n>  {\n>  \tint i;\n>  \tfor (i = 0; i < array->nr; i++)\n> @@ -162,14 +162,14 @@ static void free_ref_array(struct ref_array *array)\n>  static void clear_cached_packed_refs(struct cached_refs *refs)\n>  {\n>  \tif (refs->did_packed)\n> -\t\tfree_ref_array(&refs->packed);\n> +\t\tclear_ref_array(&refs->packed);\n>  \trefs->did_packed = 0;\n>  }\n>  \n>  static void clear_cached_loose_refs(struct cached_refs *refs)\n>  {\n>  \tif (refs->did_loose)\n> -\t\tfree_ref_array(&refs->loose);\n> +\t\tclear_ref_array(&refs->loose);\n>  \trefs->did_loose = 0;\n>  }\n>  \n> @@ -256,7 +256,7 @@ void add_extra_ref(const char *refname, const unsigned char *sha1, int flag)\n>  \n>  void clear_extra_refs(void)\n>  {\n> -\tfree_ref_array(&extra_refs);\n> +\tclear_ref_array(&extra_refs);\n>  }\n>  \n>  static struct ref_array *get_packed_refs(const char *submodule)\n"},{"id":"177582","messageId":"7vehyg4tj0.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"1318492715-5931-7-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH 06/14] resolve_gitlink_ref(): improve docstring","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T18:48:35Z","receivedAt":"2011-10-13T18:48:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"mhagger@alum.mit.edu writes:\n\n> From: Michael Haggerty <mhagger@alum.mit.edu>\n>\n>\n> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n\n> -/** resolve ref in nested \"gitlink\" repository */\n> +/**\n> + * Resolve refname in the nested \"gitlink\" repository that is located\n> + * at name.  If the resolution is successful, return 0 and set sha1 to\n> + * the name of the object; otherwise, return a non-zero value.\n> + */\n\nIt is clear that \"refname\" would refer to things like \"refs/heads/master\",\nbut \"name\" is still not clear enough with the description. 'repository\nthat is located at name' hints that we may be dealing with more than one\nrepository and 'name' is a way to identify which one, but perhaps \"path\"\nor \"submodule\" a much clearer way to indicate what the code is doing.\n\nAt the UI level, a submodule has \"name\" and \"path\" that are often the same\nbut can be different (e.g. when the superproject moves a submodule that\nused to be bound to path \"dir\" to a different location, only the latter\nshould change). I do not think resolve_gitlink_ref() takes the submodule\nname, but it takes the path to the submodule in the superproject. In that\nsense, \"submodule_path\" would be the clearest descriptive name for this\nparameter.\n\n>  extern int resolve_gitlink_ref(const char *name, const char *refname, unsigned char *sha1);\n"},{"id":"177583","messageId":"7vaa944thz.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"1318509685.7231.6.camel@drew-northup.unet.maine.edu","subject":"Re: [PATCH 07/14] is_refname_available(): remove the \"quiet\" argument","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T18:49:12Z","receivedAt":"2011-10-13T18:49:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Drew Northup <drew.northup@maine.edu> writes:\n\n> On Thu, 2011-10-13 at 09:58 +0200, mhagger@alum.mit.edu wrote:\n>> From: Michael Haggerty <mhagger@alum.mit.edu>\n>> \n>> quiet was always set to 0, so get rid of it.  Add a function docstring\n>> for good measure.\n>\n> I would like to know if perhaps it was an unfinished project somewhere\n> to propagate the \"quiet\" option down to this level before removing the\n> function argument. Comments?\n\nHave you tried blaming?\n"},{"id":"177594","messageId":"7v1uug4o6q.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"1318492715-5931-11-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH 10/14] is_dup_ref(): extract function from sort_ref_list()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T20:43:57Z","receivedAt":"2011-10-13T20:43:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"mhagger@alum.mit.edu writes:\n\n> ...\n> @@ -94,15 +113,11 @@ static void sort_ref_array(struct ref_array *array)\n>  \n>  \tqsort(array->refs, array->nr, sizeof(*array->refs), ref_entry_cmp);\n>  \n> -\t/* Remove any duplicates from the ref_array */\n> +\t/* Remove any duplicates from the ref_list */\n\nEh... Also needs retitled.\n\n>  \tfor (; j < array->nr; j++) {\n>  \t\tstruct ref_entry *a = array->refs[i];\n>  \t\tstruct ref_entry *b = array->refs[j];\n> -\t\tif (!strcmp(a->name, b->name)) {\n> -\t\t\tif (hashcmp(a->sha1, b->sha1))\n> -\t\t\t\tdie(\"Duplicated ref, and SHA1s don't match: %s\",\n> -\t\t\t\t    a->name);\n> -\t\t\twarning(\"Duplicated ref: %s\", a->name);\n> +\t\tif (is_dup_ref(a, b)) {\n>  \t\t\tfree(b);\n>  \t\t\tcontinue;\n>  \t\t}\n"},{"id":"177598","messageId":"7vfwiw33bf.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"4E969BFC.50706@viscovery.net","subject":"Re: [PATCH] t1402-check-ref-format: skip tests of refs beginning with slash on Windows","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T23:00:04Z","receivedAt":"2011-10-13T23:00:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j.sixt@viscovery.net> writes:\n\n> This patch is needed on top of mh/check-ref-format-3, or it could be\n> inserted in front of this batch (which probably amounts to the same\n> thing :-)\n\nHow about applying directly on 'master' then?\n\n> +invalid_ref NOT_MINGW '/'\n> ...\n> @@ -155,21 +155,21 @@ test_expect_success 'check-ref-format --branch from subdir' '\n>  '\n>  \n>  valid_ref_normalized() {\n> -\ttest_expect_success \"ref name '$1' simplifies to '$2'\" \"\n> +\ttest_expect_success $3 \"ref name '$1' simplifies to '$2'\" \"\n>  \t\trefname=\\$(git check-ref-format --normalize '$1') &&\n>  \t\ttest \\\"\\$refname\\\" = '$2'\"\n>  }\n>  invalid_ref_normalized() {\n> -\ttest_expect_success \"check-ref-format --normalize rejects '$1'\" \"\n> +\ttest_expect_success $2 \"check-ref-format --normalize rejects '$1'\" \"\n>  \t\ttest_must_fail git check-ref-format --normalize '$1'\"\n>  }\n> ...\n> +valid_ref_normalized '/heads/foo' 'heads/foo' NOT_MINGW\n\nThe inconsistencies strikes me a bit.\n\nPerhaps update to something like this?\n\n\tvalid_ref_normalized () {\n\t\tif test $# = 3\n                then\n\t\t\tprereq=$1\n                        shift\n\t\tfi\n                test_expect_success $prereq \"ref name '$1' simplifies to '$2'\"\n\t\t...\n\t}\n"},{"id":"177599","messageId":"7vbotk32zm.fsf@alter.siamese.dyndns.org","threadId":"28662","inReplyTo":"7vfwiw33bf.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t1402-check-ref-format: skip tests of refs beginning with slash on Windows","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-13T23:07:09Z","receivedAt":"2011-10-13T23:07:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Bash on Windows converts program arguments that look like absolute POSIX\npaths to their Windows form, i.e., drive-letter-colon format. For this\nreason, those tests in t1402 that check refs that begin with a slash do not\nwork as expected on Windows: valid_ref tests are doomed to fail, and\ninvalid_ref tests fail for the wrong reason (that there is a colon rather\nthan that they begin with a slash).\n\nSkip these tests.\n\nSigned-off-by: Johannes Sixt <j6t@kdbg.org>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\nJunio C Hamano <gitster@pobox.com> writes:\n\n>> +invalid_ref NOT_MINGW '/'\n>> ...\n>> +valid_ref_normalized '/heads/foo' 'heads/foo' NOT_MINGW\n>\n> The inconsistencies strikes me a bit.\n\nHere is what I tentatively will queue.\n\nThe interdiff from yours looks like this:\n\n    diff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh\n    index dba5e97..1ae4d87 100755\n    --- a/t/t1402-check-ref-format.sh\n    +++ b/t/t1402-check-ref-format.sh\n    @@ -11,8 +11,9 @@ valid_ref() {\n                    prereq=$1\n                    shift\n            esac\n    -\ttest_expect_success $prereq \"ref name '$1' is valid${2:+ with options $2}\" \\\n    -\t\t\t\"git check-ref-format $2 '$1'\"\n    +\ttest_expect_success $prereq \"ref name '$1' is valid${2:+ with options $2}\" \"\n    +\t\tgit check-ref-format $2 '$1'\n    +\t\"\n     }\n     invalid_ref() {\n            prereq=\n    @@ -21,8 +22,9 @@ invalid_ref() {\n                    prereq=$1\n                    shift\n            esac\n    -\ttest_expect_success $prereq \"ref name '$1' is invalid${2:+ with options $2}\" \\\n    -\t\t\t\"test_must_fail git check-ref-format $2 '$1'\"\n    +\ttest_expect_success $prereq \"ref name '$1' is invalid${2:+ with options $2}\" \"\n    +\t\ttest_must_fail git check-ref-format $2 '$1'\n    +\t\"\n     }\n\n     invalid_ref ''\n    @@ -155,21 +157,35 @@ test_expect_success 'check-ref-format --branch from subdir' '\n     '\n\n     valid_ref_normalized() {\n    -\ttest_expect_success $3 \"ref name '$1' simplifies to '$2'\" \"\n    +\tprereq=\n    +\tcase $1 in\n    +\t[A-Z]*)\n    +\t\tprereq=$1\n    +\t\tshift\n    +\tesac\n    +\ttest_expect_success $prereq \"ref name '$1' simplifies to '$2'\" \"\n                    refname=\\$(git check-ref-format --normalize '$1') &&\n    -\t\ttest \\\"\\$refname\\\" = '$2'\"\n    +\t\ttest \\\"\\$refname\\\" = '$2'\n    +\t\"\n     }\n     invalid_ref_normalized() {\n    -\ttest_expect_success $2 \"check-ref-format --normalize rejects '$1'\" \"\n    -\t\ttest_must_fail git check-ref-format --normalize '$1'\"\n    +\tprereq=\n    +\tcase $1 in\n    +\t[A-Z]*)\n    +\t\tprereq=$1\n    +\t\tshift\n    +\tesac\n    +\ttest_expect_success $prereq \"check-ref-format --normalize rejects '$1'\" \"\n    +\t\ttest_must_fail git check-ref-format --normalize '$1'\n    +\t\"\n     }\n\n     valid_ref_normalized 'heads/foo' 'heads/foo'\n     valid_ref_normalized 'refs///heads/foo' 'refs/heads/foo'\n    -valid_ref_normalized '/heads/foo' 'heads/foo' NOT_MINGW\n    +valid_ref_normalized NOT_MINGW '/heads/foo' 'heads/foo'\n     valid_ref_normalized '///heads/foo' 'heads/foo'\n     invalid_ref_normalized 'foo'\n    -invalid_ref_normalized '/foo' NOT_MINGW\n    +invalid_ref_normalized NOT_MINGW '/foo'\n     invalid_ref_normalized 'heads/foo/../bar'\n     invalid_ref_normalized 'heads/./foo'\n     invalid_ref_normalized 'heads\\foo'\n\nThanks.\n\n t/t1402-check-ref-format.sh |   88 +++++++++++++++++++++++++-----------------\n 1 files changed, 52 insertions(+), 36 deletions(-)\n\ndiff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh\nindex 710fcca..1ae4d87 100755\n--- a/t/t1402-check-ref-format.sh\n+++ b/t/t1402-check-ref-format.sh\n@@ -5,38 +5,40 @@ test_description='Test git check-ref-format'\n . ./test-lib.sh\n \n valid_ref() {\n-\tif test \"$#\" = 1\n-\tthen\n-\t\ttest_expect_success \"ref name '$1' is valid\" \\\n-\t\t\t\"git check-ref-format '$1'\"\n-\telse\n-\t\ttest_expect_success \"ref name '$1' is valid with options $2\" \\\n-\t\t\t\"git check-ref-format $2 '$1'\"\n-\tfi\n+\tprereq=\n+\tcase $1 in\n+\t[A-Z]*)\n+\t\tprereq=$1\n+\t\tshift\n+\tesac\n+\ttest_expect_success $prereq \"ref name '$1' is valid${2:+ with options $2}\" \"\n+\t\tgit check-ref-format $2 '$1'\n+\t\"\n }\n invalid_ref() {\n-\tif test \"$#\" = 1\n-\tthen\n-\t\ttest_expect_success \"ref name '$1' is invalid\" \\\n-\t\t\t\"test_must_fail git check-ref-format '$1'\"\n-\telse\n-\t\ttest_expect_success \"ref name '$1' is invalid with options $2\" \\\n-\t\t\t\"test_must_fail git check-ref-format $2 '$1'\"\n-\tfi\n+\tprereq=\n+\tcase $1 in\n+\t[A-Z]*)\n+\t\tprereq=$1\n+\t\tshift\n+\tesac\n+\ttest_expect_success $prereq \"ref name '$1' is invalid${2:+ with options $2}\" \"\n+\t\ttest_must_fail git check-ref-format $2 '$1'\n+\t\"\n }\n \n invalid_ref ''\n-invalid_ref '/'\n-invalid_ref '/' --allow-onelevel\n-invalid_ref '/' --normalize\n-invalid_ref '/' '--allow-onelevel --normalize'\n+invalid_ref NOT_MINGW '/'\n+invalid_ref NOT_MINGW '/' --allow-onelevel\n+invalid_ref NOT_MINGW '/' --normalize\n+invalid_ref NOT_MINGW '/' '--allow-onelevel --normalize'\n valid_ref 'foo/bar/baz'\n valid_ref 'foo/bar/baz' --normalize\n invalid_ref 'refs///heads/foo'\n valid_ref 'refs///heads/foo' --normalize\n invalid_ref 'heads/foo/'\n-invalid_ref '/heads/foo'\n-valid_ref '/heads/foo' --normalize\n+invalid_ref NOT_MINGW '/heads/foo'\n+valid_ref NOT_MINGW '/heads/foo' --normalize\n invalid_ref '///heads/foo'\n valid_ref '///heads/foo' --normalize\n invalid_ref './foo'\n@@ -115,14 +117,14 @@ invalid_ref \"$ref\" --refspec-pattern\n invalid_ref \"$ref\" '--refspec-pattern --allow-onelevel'\n \n ref='/foo'\n-invalid_ref \"$ref\"\n-invalid_ref \"$ref\" --allow-onelevel\n-invalid_ref \"$ref\" --refspec-pattern\n-invalid_ref \"$ref\" '--refspec-pattern --allow-onelevel'\n-invalid_ref \"$ref\" --normalize\n-valid_ref \"$ref\" '--allow-onelevel --normalize'\n-invalid_ref \"$ref\" '--refspec-pattern --normalize'\n-valid_ref \"$ref\" '--refspec-pattern --allow-onelevel --normalize'\n+invalid_ref NOT_MINGW \"$ref\"\n+invalid_ref NOT_MINGW \"$ref\" --allow-onelevel\n+invalid_ref NOT_MINGW \"$ref\" --refspec-pattern\n+invalid_ref NOT_MINGW \"$ref\" '--refspec-pattern --allow-onelevel'\n+invalid_ref NOT_MINGW \"$ref\" --normalize\n+valid_ref NOT_MINGW \"$ref\" '--allow-onelevel --normalize'\n+invalid_ref NOT_MINGW \"$ref\" '--refspec-pattern --normalize'\n+valid_ref NOT_MINGW \"$ref\" '--refspec-pattern --allow-onelevel --normalize'\n \n test_expect_success \"check-ref-format --branch @{-1}\" '\n \tT=$(git write-tree) &&\n@@ -155,21 +157,35 @@ test_expect_success 'check-ref-format --branch from subdir' '\n '\n \n valid_ref_normalized() {\n-\ttest_expect_success \"ref name '$1' simplifies to '$2'\" \"\n+\tprereq=\n+\tcase $1 in\n+\t[A-Z]*)\n+\t\tprereq=$1\n+\t\tshift\n+\tesac\n+\ttest_expect_success $prereq \"ref name '$1' simplifies to '$2'\" \"\n \t\trefname=\\$(git check-ref-format --normalize '$1') &&\n-\t\ttest \\\"\\$refname\\\" = '$2'\"\n+\t\ttest \\\"\\$refname\\\" = '$2'\n+\t\"\n }\n invalid_ref_normalized() {\n-\ttest_expect_success \"check-ref-format --normalize rejects '$1'\" \"\n-\t\ttest_must_fail git check-ref-format --normalize '$1'\"\n+\tprereq=\n+\tcase $1 in\n+\t[A-Z]*)\n+\t\tprereq=$1\n+\t\tshift\n+\tesac\n+\ttest_expect_success $prereq \"check-ref-format --normalize rejects '$1'\" \"\n+\t\ttest_must_fail git check-ref-format --normalize '$1'\n+\t\"\n }\n \n valid_ref_normalized 'heads/foo' 'heads/foo'\n valid_ref_normalized 'refs///heads/foo' 'refs/heads/foo'\n-valid_ref_normalized '/heads/foo' 'heads/foo'\n+valid_ref_normalized NOT_MINGW '/heads/foo' 'heads/foo'\n valid_ref_normalized '///heads/foo' 'heads/foo'\n invalid_ref_normalized 'foo'\n-invalid_ref_normalized '/foo'\n+invalid_ref_normalized NOT_MINGW '/foo'\n invalid_ref_normalized 'heads/foo/../bar'\n invalid_ref_normalized 'heads/./foo'\n invalid_ref_normalized 'heads\\foo'\n-- \n1.7.7.289.gd0d4bb\n"},{"id":"177610","messageId":"4E97CA2B.6080202@alum.mit.edu","threadId":"28662","inReplyTo":"1318509685.7231.6.camel@drew-northup.unet.maine.edu","subject":"Re: [PATCH 07/14] is_refname_available(): remove the \"quiet\" argument","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-10-14T05:35:39Z","receivedAt":"2011-10-14T05:35:39Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 10/13/2011 02:41 PM, Drew Northup wrote:\n> \n> On Thu, 2011-10-13 at 09:58 +0200, mhagger@alum.mit.edu wrote:\n>> From: Michael Haggerty <mhagger@alum.mit.edu>\n>>\n>> quiet was always set to 0, so get rid of it.  Add a function docstring\n>> for good measure.\n> \n> I would like to know if perhaps it was an unfinished project somewhere\n> to propagate the \"quiet\" option down to this level before removing the\n> function argument. Comments?\n\nThe is_refname_available() function, including the quiet option, was\nadded in c976d415e53 (coincidentally the same commit that added\nRENAME-REF).  I am unable to find any use of the function with quiet=1\nanywhere in history.\n\n>> +/*\n>> + * Return true iff a reference named refname could be created without\n> \n> Did you really mean \"iff\" (as in \"if and only if\") or just plain \"if\"\n> here?\n\nI did indeed mean \"if and only if\".  Are you asking because you think\nthat abbreviation is too obscure, or because you think that \"if and only\nif\" is logically incorrect here and I should have used \"if\"?\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"177611","messageId":"4E97D975.6070305@viscovery.net","threadId":"28662","inReplyTo":"7vbotk32zm.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t1402-check-ref-format: skip tests of refs beginning with slash on Windows","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2011-10-14T06:40:53Z","receivedAt":"2011-10-14T06:40:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 10/14/2011 1:07, schrieb Junio C Hamano:\n> Junio C Hamano <gitster@pobox.com> writes:\n> \n>>> +invalid_ref NOT_MINGW '/'\n>>> ...\n>>> +valid_ref_normalized '/heads/foo' 'heads/foo' NOT_MINGW\n>>\n>> The inconsistencies strikes me a bit.\n> \n> Here is what I tentatively will queue.\n\nThe patch looks good, and the test cases pass as expected.\n\nThank you very much,\n-- Hannes\n"}]}