Sync with 2.5.2
authorJunio C Hamano <gitster@pobox.com>
Wed, 9 Sep 2015 21:30:35 +0000 (14:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Sep 2015 21:30:35 +0000 (14:30 -0700)
1  2 
Documentation/git.txt
builtin/show-branch.c
sha1_file.c
unpack-trees.c
diff --combined Documentation/git.txt
index 4e5d55be6a2b5db801e651b054160b393e148576,629e62c9255202642884398efafdc9cd0e876042..75ffb16d965d7c5f5b04c8aa342e940566bf8d3c
@@@ -43,15 -43,17 +43,17 @@@ unreleased) version of Git, that is ava
  branch of the `git.git` repository.
  Documentation for older releases are available here:
  
- * link:v2.5.1/git.html[documentation for release 2.5.1]
+ * link:v2.5.2/git.html[documentation for release 2.5.2]
  
  * release notes for
+   link:RelNotes/2.5.2.txt[2.5.2],
    link:RelNotes/2.5.1.txt[2.5.1],
    link:RelNotes/2.5.0.txt[2.5].
  
- * link:v2.4.8/git.html[documentation for release 2.4.8]
+ * link:v2.4.9/git.html[documentation for release 2.4.9]
  
  * release notes for
+   link:RelNotes/2.4.9.txt[2.4.9],
    link:RelNotes/2.4.8.txt[2.4.8],
    link:RelNotes/2.4.7.txt[2.4.7],
    link:RelNotes/2.4.6.txt[2.4.6],
    link:RelNotes/2.4.1.txt[2.4.1],
    link:RelNotes/2.4.0.txt[2.4].
  
- * link:v2.3.8/git.html[documentation for release 2.3.8]
+ * link:v2.3.9/git.html[documentation for release 2.3.9]
  
  * release notes for
+   link:RelNotes/2.3.9.txt[2.3.9],
    link:RelNotes/2.3.8.txt[2.3.8],
    link:RelNotes/2.3.7.txt[2.3.7],
    link:RelNotes/2.3.6.txt[2.3.6],
    link:RelNotes/2.3.1.txt[2.3.1],
    link:RelNotes/2.3.0.txt[2.3].
  
- * link:v2.2.2/git.html[documentation for release 2.2.2]
+ * link:v2.2.3/git.html[documentation for release 2.2.3]
  
  * release notes for
+   link:RelNotes/2.2.3.txt[2.2.3],
    link:RelNotes/2.2.2.txt[2.2.2],
    link:RelNotes/2.2.1.txt[2.2.1],
    link:RelNotes/2.2.0.txt[2.2].
@@@ -1011,20 -1015,9 +1015,20 @@@ Unsetting the variable, or setting it t
        Enables trace messages for all packets coming in or out of a
        given program. This can help with debugging object negotiation
        or other protocol issues. Tracing is turned off at a packet
 -      starting with "PACK".
 +      starting with "PACK" (but see 'GIT_TRACE_PACKFILE' below).
        See 'GIT_TRACE' for available trace output options.
  
 +'GIT_TRACE_PACKFILE'::
 +      Enables tracing of packfiles sent or received by a
 +      given program. Unlike other trace output, this trace is
 +      verbatim: no headers, and no quoting of binary data. You almost
 +      certainly want to direct into a file (e.g.,
 +      `GIT_TRACE_PACKFILE=/tmp/my.pack`) rather than displaying it on
 +      the terminal or mixing it with other trace output.
 ++
 +Note that this is currently only implemented for the client side
 +of clones and fetches.
 +
  'GIT_TRACE_PERFORMANCE'::
        Enables performance related trace messages, e.g. total execution
        time of each Git command.
diff --combined builtin/show-branch.c
index c87c46eb387a8093af92864081673be1a36b5999,344ae4ce2a8d95f0aca6f93ef2d714db059e6431..408ce7030731f765228de93066a815bd4db59e30
@@@ -730,7 -730,6 +730,6 @@@ int cmd_show_branch(int ac, const char 
  
        if (reflog) {
                struct object_id oid;
-               char nth_desc[256];
                char *ref;
                int base = 0;
                unsigned int flags = 0;
  
                for (i = 0; i < reflog; i++) {
                        char *logmsg;
+                       char *nth_desc;
                        const char *msg;
                        unsigned long timestamp;
                        int tz;
                        else
                                msg++;
                        reflog_msg[i] = xstrfmt("(%s) %s",
 -                                              show_date(timestamp, tz, 1),
 +                                              show_date(timestamp, tz,
 +                                                        DATE_MODE(RELATIVE)),
                                                msg);
                        free(logmsg);
-                       sprintf(nth_desc, "%s@{%d}", *av, base+i);
+                       nth_desc = xstrfmt("%s@{%d}", *av, base+i);
                        append_ref(nth_desc, &oid, 1);
+                       free(nth_desc);
                }
                free(ref);
        }
diff --combined sha1_file.c
index 08302f5857b8ad298809adf04a6bffc136f843a4,17262e18269e0fa97236fc6a39e9731a2752736a..d295a3225a1e083708812f99746773d0ec8fdff4
@@@ -377,15 -377,12 +377,12 @@@ void read_info_alternates(const char * 
        char *map;
        size_t mapsz;
        struct stat st;
-       const char alt_file_name[] = "info/alternates";
-       /* Given that relative_base is no longer than PATH_MAX,
-          ensure that "path" has enough space to append "/", the
-          file name, "info/alternates", and a trailing NUL.  */
-       char path[PATH_MAX + 1 + sizeof alt_file_name];
+       char *path;
        int fd;
  
-       sprintf(path, "%s/%s", relative_base, alt_file_name);
+       path = xstrfmt("%s/info/alternates", relative_base);
        fd = git_open_noatime(path);
+       free(path);
        if (fd < 0)
                return;
        if (fstat(fd, &st) || (st.st_size == 0)) {
  void add_to_alternates_file(const char *reference)
  {
        struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
 -      int fd = hold_lock_file_for_append(lock, git_path("objects/info/alternates"), LOCK_DIE_ON_ERROR);
 -      const char *alt = mkpath("%s\n", reference);
 -      write_or_die(fd, alt, strlen(alt));
 -      if (commit_lock_file(lock))
 -              die("could not close alternates file");
 -      if (alt_odb_tail)
 -              link_alt_odb_entries(alt, strlen(alt), '\n', NULL, 0);
 +      char *alts = git_pathdup("objects/info/alternates");
 +      FILE *in, *out;
 +
 +      hold_lock_file_for_update(lock, alts, LOCK_DIE_ON_ERROR);
 +      out = fdopen_lock_file(lock, "w");
 +      if (!out)
 +              die_errno("unable to fdopen alternates lockfile");
 +
 +      in = fopen(alts, "r");
 +      if (in) {
 +              struct strbuf line = STRBUF_INIT;
 +              int found = 0;
 +
 +              while (strbuf_getline(&line, in, '\n') != EOF) {
 +                      if (!strcmp(reference, line.buf)) {
 +                              found = 1;
 +                              break;
 +                      }
 +                      fprintf_or_die(out, "%s\n", line.buf);
 +              }
 +
 +              strbuf_release(&line);
 +              fclose(in);
 +
 +              if (found) {
 +                      rollback_lock_file(lock);
 +                      lock = NULL;
 +              }
 +      }
 +      else if (errno != ENOENT)
 +              die_errno("unable to read alternates file");
 +
 +      if (lock) {
 +              fprintf_or_die(out, "%s\n", reference);
 +              if (commit_lock_file(lock))
 +                      die_errno("unable to move new alternates file into place");
 +              if (alt_odb_tail)
 +                      link_alt_odb_entries(reference, strlen(reference), '\n', NULL, 0);
 +      }
 +      free(alts);
  }
  
  int foreach_alt_odb(alt_odb_fn fn, void *cb)
@@@ -2944,8 -2908,11 +2941,8 @@@ static void write_sha1_file_prepare(con
  
  /*
   * Move the just written object into its final resting place.
 - * NEEDSWORK: this should be renamed to finalize_temp_file() as
 - * "moving" is only a part of what it does, when no patch between
 - * master to pu changes the call sites of this function.
   */
 -int move_temp_to_file(const char *tmpfile, const char *filename)
 +int finalize_object_file(const char *tmpfile, const char *filename)
  {
        int ret = 0;
  
@@@ -3118,7 -3085,7 +3115,7 @@@ static int write_loose_object(const uns
                                tmp_file, strerror(errno));
        }
  
 -      return move_temp_to_file(tmp_file, filename);
 +      return finalize_object_file(tmp_file, filename);
  }
  
  static int freshen_loose_object(const unsigned char *sha1)
diff --combined unpack-trees.c
index bb09b1ed27a6c973c93f5ec855973e277279549f,6e9f75549dde32781d6a2b032ab9edb1b7a5e079..f932e80e862cfafb7b909059b460dcb688c6dc0b
@@@ -1029,12 -1029,10 +1029,12 @@@ int unpack_trees(unsigned len, struct t
        if (!core_apply_sparse_checkout || !o->update)
                o->skip_sparse_checkout = 1;
        if (!o->skip_sparse_checkout) {
 -              if (add_excludes_from_file_to_list(git_path("info/sparse-checkout"), "", 0, &el, 0) < 0)
 +              char *sparse = git_pathdup("info/sparse-checkout");
 +              if (add_excludes_from_file_to_list(sparse, "", 0, &el, 0) < 0)
                        o->skip_sparse_checkout = 1;
                else
                        o->el = &el;
 +              free(sparse);
        }
  
        memset(&o->result, 0, sizeof(o->result));
        o->src_index = NULL;
        ret = check_updates(o) ? (-2) : 0;
        if (o->dst_index) {
 +              if (!ret) {
 +                      if (!o->result.cache_tree)
 +                              o->result.cache_tree = cache_tree();
 +                      if (!cache_tree_fully_valid(o->result.cache_tree))
 +                              cache_tree_update(&o->result,
 +                                                WRITE_TREE_SILENT |
 +                                                WRITE_TREE_REPAIR);
 +              }
                discard_index(o->dst_index);
                *o->dst_index = o->result;
        } else {
@@@ -1451,15 -1441,18 +1451,18 @@@ static int verify_absent_1(const struc
        if (!len)
                return 0;
        else if (len > 0) {
-               char path[PATH_MAX + 1];
-               memcpy(path, ce->name, len);
-               path[len] = 0;
+               char *path;
+               int ret;
+               path = xmemdupz(ce->name, len);
                if (lstat(path, &st))
-                       return error("cannot stat '%s': %s", path,
+                       ret = error("cannot stat '%s': %s", path,
                                        strerror(errno));
-               return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st,
-                               error_type, o);
+               else
+                       ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
+                                                &st, error_type, o);
+               free(path);
+               return ret;
        } else if (lstat(ce->name, &st)) {
                if (errno != ENOENT)
                        return error("cannot stat '%s': %s", ce->name,