Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Tue, 26 May 2009 02:44:52 +0000 (19:44 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 26 May 2009 02:44:52 +0000 (19:44 -0700)
* maint:
Prepare for 1.6.3.2
fix cat-file usage message and documentation
fetch: report ref storage DF errors more accurately
lock_ref: inform callers of unavailable ref
merge-options.txt: Clarify merge --squash

Conflicts:
RelNotes

1  2 
builtin-fetch.c
refs.c
diff --combined builtin-fetch.c
index 77acabfcc71aaee02ea99d2cd10e51dd0feaea6e,1f7a3f1ce66434a84ff96ef352245862fe088a70..1eec64e9c4f624f035dc8c155316964c3b87470f
@@@ -167,6 -167,9 +167,9 @@@ static struct ref *get_ref_map(struct t
        return ref_map;
  }
  
+ #define STORE_REF_ERROR_OTHER 1
+ #define STORE_REF_ERROR_DF_CONFLICT 2
  static int s_update_ref(const char *action,
                        struct ref *ref,
                        int check_old)
        lock = lock_any_ref_for_update(ref->name,
                                       check_old ? ref->old_sha1 : NULL, 0);
        if (!lock)
-               return 2;
+               return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
+                                         STORE_REF_ERROR_OTHER;
        if (write_ref_sha1(lock, ref->new_sha1, msg) < 0)
-               return 2;
+               return errno == ENOTDIR ? STORE_REF_ERROR_DF_CONFLICT :
+                                         STORE_REF_ERROR_OTHER;
        return 0;
  }
  
@@@ -197,7 -202,7 +202,7 @@@ static int update_local_ref(struct ref 
        struct commit *current = NULL, *updated;
        enum object_type type;
        struct branch *current_branch = branch_get(NULL);
 -      const char *pretty_ref = prettify_ref(ref);
 +      const char *pretty_ref = prettify_refname(ref->name);
  
        *display = 0;
        type = sha1_object_info(ref->new_sha1, NULL);
        }
  }
  
 -static int store_updated_refs(const char *url, const char *remote_name,
 +static int store_updated_refs(const char *raw_url, const char *remote_name,
                struct ref *ref_map)
  {
        FILE *fp;
        char note[1024];
        const char *what, *kind;
        struct ref *rm;
 -      char *filename = git_path("FETCH_HEAD");
 +      char *url, *filename = git_path("FETCH_HEAD");
  
        fp = fopen(filename, "a");
        if (!fp)
                return error("cannot open %s: %s\n", filename, strerror(errno));
 +
 +      url = transport_anonymize_url(raw_url);
        for (rm = ref_map; rm; rm = rm->next) {
                struct ref *ref = NULL;
  
                                                    kind);
                        note_len += sprintf(note + note_len, "'%s' of ", what);
                }
 -              note_len += sprintf(note + note_len, "%.*s", url_len, url);
 -              fprintf(fp, "%s\t%s\t%s\n",
 +              note[note_len] = '\0';
 +              fprintf(fp, "%s\t%s\t%s",
                        sha1_to_hex(commit ? commit->object.sha1 :
                                    rm->old_sha1),
                        rm->merge ? "" : "not-for-merge",
                        note);
 +              for (i = 0; i < url_len; ++i)
 +                      if ('\n' == url[i])
 +                              fputs("\\n", fp);
 +                      else
 +                              fputc(url[i], fp);
 +              fputc('\n', fp);
  
                if (ref)
                        rc |= update_local_ref(ref, what, note);
                                fprintf(stderr, " %s\n", note);
                }
        }
 +      free(url);
        fclose(fp);
-       if (rc & 2)
+       if (rc & STORE_REF_ERROR_DF_CONFLICT)
                error("some local refs could not be updated; try running\n"
                      " 'git remote prune %s' to remove any old, conflicting "
                      "branches", remote_name);
diff --combined refs.c
index 45ad55693dbaff8e85687a1ed48f1cc901332b3a,90163bdc56868151e4fd45ff77aa3bd56db45573..24438c652fe4e09aaa1ba6dab283b8e59c24c1a7
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -682,13 -682,12 +682,13 @@@ int for_each_rawref(each_ref_fn fn, voi
   * - it has ASCII control character, "~", "^", ":" or SP, anywhere, or
   * - it ends with a "/".
   * - it ends with ".lock"
 + * - it contains a "\" (backslash)
   */
  
  static inline int bad_ref_char(int ch)
  {
        if (((unsigned) ch) <= ' ' ||
 -          ch == '~' || ch == '^' || ch == ':')
 +          ch == '~' || ch == '^' || ch == ':' || ch == '\\')
                return 1;
        /* 2.13 Pattern Matching Notation */
        if (ch == '?' || ch == '[') /* Unsupported */
@@@ -751,8 -750,9 +751,8 @@@ int check_ref_format(const char *ref
        }
  }
  
 -const char *prettify_ref(const struct ref *ref)
 +const char *prettify_refname(const char *name)
  {
 -      const char *name = ref->name;
        return name + (
                !prefixcmp(name, "refs/heads/") ? 11 :
                !prefixcmp(name, "refs/tags/") ? 10 :
@@@ -893,8 -893,10 +893,10 @@@ static struct ref_lock *lock_ref_sha1_b
         * name is a proper prefix of our refname.
         */
        if (missing &&
-             !is_refname_available(ref, NULL, get_packed_refs(), 0))
+            !is_refname_available(ref, NULL, get_packed_refs(), 0)) {
+               last_errno = ENOTDIR;
                goto error_return;
+       }
  
        lock->lk = xcalloc(1, sizeof(struct lock_file));