Merge branch 'maint-1.7.6' into maint-1.7.7
authorJunio C Hamano <gitster@pobox.com>
Wed, 14 Dec 2011 05:44:56 +0000 (21:44 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Dec 2011 05:44:56 +0000 (21:44 -0800)
* maint-1.7.6:
Git 1.7.6.5
blame: don't overflow time buffer
fetch: create status table using strbuf

Conflicts:
Documentation/git.txt
GIT-VERSION-GEN
RelNotes

1  2 
Documentation/git.txt
builtin/fetch.c
diff --combined Documentation/git.txt
index 5e80cfd71a5529225b607bd3f1732d19f05d0c1d,bcedfc1a54aeeac067d4eb45d8ba88a3821ac4f3..4a29f47b41057d5f4681d299dd9ed47c1fef2009
@@@ -10,8 -10,8 +10,8 @@@ SYNOPSI
  --------
  [verse]
  'git' [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
 -    [-p|--paginate|--no-pager] [--no-replace-objects]
 -    [--bare] [--git-dir=<path>] [--work-tree=<path>]
 +    [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
 +    [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
      [-c <name>=<value>]
      [--help] <command> [<args>]
  
@@@ -44,15 -44,10 +44,16 @@@ unreleased) version of git, that is ava
  branch of the `git.git` repository.
  Documentation for older releases are available here:
  
- * link:v1.7.6.4/git.html[documentation for release 1.7.6.4]
 +* link:v1.7.7.1/git.html[documentation for release 1.7.7.1]
 +
 +* release notes for
 +  link:RelNotes/1.7.7.1.txt[1.7.7.1],
 +  link:RelNotes/1.7.7.txt[1.7.7].
 +
+ * link:v1.7.6.5/git.html[documentation for release 1.7.6.5]
  
  * release notes for
+   link:RelNotes/1.7.6.5.txt[1.7.6.5],
    link:RelNotes/1.7.6.4.txt[1.7.6.4],
    link:RelNotes/1.7.6.3.txt[1.7.6.3],
    link:RelNotes/1.7.6.2.txt[1.7.6.2],
@@@ -340,11 -335,6 +341,11 @@@ help ...`
        variable (see core.worktree in linkgit:git-config[1] for a
        more detailed discussion).
  
 +--namespace=<path>::
 +      Set the git namespace.  See linkgit:gitnamespaces[7] for more
 +      details.  Equivalent to setting the `GIT_NAMESPACE` environment
 +      variable.
 +
  --bare::
        Treat the repository as a bare repository.  If GIT_DIR
        environment is not set, it is set to the current working
@@@ -608,10 -598,6 +609,10 @@@ git so take care if using Cogito etc
        This can also be controlled by the '--work-tree' command line
        option and the core.worktree configuration variable.
  
 +'GIT_NAMESPACE'::
 +      Set the git namespace; see linkgit:gitnamespaces[7] for details.
 +      The '--namespace' command-line option also sets this value.
 +
  'GIT_CEILING_DIRECTORIES'::
        This should be a colon-separated list of absolute paths.
        If set, it is a list of directories that git should not chdir
diff --combined builtin/fetch.c
index 9d481f8ca9d9470311b356e9bd5356fa362ffd6a,914cb919d05516325323f9355e45ec337348756d..59dfba5180d2373f0e52563f4db928a25708822d
@@@ -239,23 -239,23 +239,23 @@@ static int s_update_ref(const char *act
  
  static int update_local_ref(struct ref *ref,
                            const char *remote,
-                           char *display)
+                           struct strbuf *display)
  {
        struct commit *current = NULL, *updated;
        enum object_type type;
        struct branch *current_branch = branch_get(NULL);
        const char *pretty_ref = prettify_refname(ref->name);
  
-       *display = 0;
        type = sha1_object_info(ref->new_sha1, NULL);
        if (type < 0)
                die(_("object %s not found"), sha1_to_hex(ref->new_sha1));
  
        if (!hashcmp(ref->old_sha1, ref->new_sha1)) {
                if (verbosity > 0)
-                       sprintf(display, "= %-*s %-*s -> %s", TRANSPORT_SUMMARY_WIDTH,
-                               _("[up to date]"), REFCOL_WIDTH, remote,
-                               pretty_ref);
+                       strbuf_addf(display, "= %-*s %-*s -> %s",
+                                   TRANSPORT_SUMMARY_WIDTH,
+                                   _("[up to date]"), REFCOL_WIDTH,
+                                   remote, pretty_ref);
                return 0;
        }
  
                 * If this is the head, and it's not okay to update
                 * the head, and the old value of the head isn't empty...
                 */
-               sprintf(display, _("! %-*s %-*s -> %s  (can't fetch in current branch)"),
-                       TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,
-                       pretty_ref);
+               strbuf_addf(display,
+                           _("! %-*s %-*s -> %s  (can't fetch in current branch)"),
+                           TRANSPORT_SUMMARY_WIDTH, _("[rejected]"),
+                           REFCOL_WIDTH, remote, pretty_ref);
                return 1;
        }
  
            !prefixcmp(ref->name, "refs/tags/")) {
                int r;
                r = s_update_ref("updating tag", ref, 0);
-               sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '-',
-                       TRANSPORT_SUMMARY_WIDTH, _("[tag update]"), REFCOL_WIDTH, remote,
-                       pretty_ref, r ? _("  (unable to update local ref)") : "");
+               strbuf_addf(display, "%c %-*s %-*s -> %s%s",
+                           r ? '!' : '-',
+                           TRANSPORT_SUMMARY_WIDTH, _("[tag update]"),
+                           REFCOL_WIDTH, remote, pretty_ref,
+                           r ? _("  (unable to update local ref)") : "");
                return r;
        }
  
                }
  
                r = s_update_ref(msg, ref, 0);
-               sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : '*',
-                       TRANSPORT_SUMMARY_WIDTH, what, REFCOL_WIDTH, remote, pretty_ref,
-                       r ? _("  (unable to update local ref)") : "");
+               strbuf_addf(display, "%c %-*s %-*s -> %s%s",
+                           r ? '!' : '*',
+                           TRANSPORT_SUMMARY_WIDTH, what,
+                           REFCOL_WIDTH, remote, pretty_ref,
+                           r ? _("  (unable to update local ref)") : "");
                return r;
        }
  
                    (recurse_submodules != RECURSE_SUBMODULES_ON))
                        check_for_new_submodule_commits(ref->new_sha1);
                r = s_update_ref("fast-forward", ref, 1);
-               sprintf(display, "%c %-*s %-*s -> %s%s", r ? '!' : ' ',
-                       TRANSPORT_SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote,
-                       pretty_ref, r ? _("  (unable to update local ref)") : "");
+               strbuf_addf(display, "%c %-*s %-*s -> %s%s",
+                           r ? '!' : ' ',
+                           TRANSPORT_SUMMARY_WIDTH, quickref,
+                           REFCOL_WIDTH, remote, pretty_ref,
+                           r ? _("  (unable to update local ref)") : "");
                return r;
        } else if (force || ref->force) {
                char quickref[84];
                    (recurse_submodules != RECURSE_SUBMODULES_ON))
                        check_for_new_submodule_commits(ref->new_sha1);
                r = s_update_ref("forced-update", ref, 1);
-               sprintf(display, "%c %-*s %-*s -> %s  (%s)", r ? '!' : '+',
-                       TRANSPORT_SUMMARY_WIDTH, quickref, REFCOL_WIDTH, remote,
-                       pretty_ref,
-                       r ? _("unable to update local ref") : _("forced update"));
+               strbuf_addf(display, "%c %-*s %-*s -> %s  (%s)",
+                           r ? '!' : '+',
+                           TRANSPORT_SUMMARY_WIDTH, quickref,
+                           REFCOL_WIDTH, remote, pretty_ref,
+                           r ? _("unable to update local ref") : _("forced update"));
                return r;
        } else {
-               sprintf(display, "! %-*s %-*s -> %s  %s",
-                       TRANSPORT_SUMMARY_WIDTH, _("[rejected]"), REFCOL_WIDTH, remote,
-                       pretty_ref, _("(non-fast-forward)"));
+               strbuf_addf(display, "! %-*s %-*s -> %s  %s",
+                           TRANSPORT_SUMMARY_WIDTH, _("[rejected]"),
+                           REFCOL_WIDTH, remote, pretty_ref,
+                           _("(non-fast-forward)"));
                return 1;
        }
  }
@@@ -350,8 -359,8 +359,8 @@@ static int store_updated_refs(const cha
  {
        FILE *fp;
        struct commit *commit;
-       int url_len, i, note_len, shown_url = 0, rc = 0;
-       char note[1024];
+       int url_len, i, shown_url = 0, rc = 0;
+       struct strbuf note = STRBUF_INIT;
        const char *what, *kind;
        struct ref *rm;
        char *url, *filename = dry_run ? "/dev/null" : git_path("FETCH_HEAD");
                if (4 < i && !strncmp(".git", url + i - 3, 4))
                        url_len = i - 3;
  
-               note_len = 0;
+               strbuf_reset(&note);
                if (*what) {
                        if (*kind)
-                               note_len += sprintf(note + note_len, "%s ",
-                                                   kind);
-                       note_len += sprintf(note + note_len, "'%s' of ", what);
+                               strbuf_addf(&note, "%s ", kind);
+                       strbuf_addf(&note, "'%s' of ", what);
                }
-               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);
+                       note.buf);
                for (i = 0; i < url_len; ++i)
                        if ('\n' == url[i])
                                fputs("\\n", fp);
                                fputc(url[i], fp);
                fputc('\n', fp);
  
+               strbuf_reset(&note);
                if (ref) {
-                       rc |= update_local_ref(ref, what, note);
+                       rc |= update_local_ref(ref, what, &note);
                        free(ref);
                } else
-                       sprintf(note, "* %-*s %-*s -> FETCH_HEAD",
-                               TRANSPORT_SUMMARY_WIDTH, *kind ? kind : "branch",
-                                REFCOL_WIDTH, *what ? what : "HEAD");
-               if (*note) {
+                       strbuf_addf(&note, "* %-*s %-*s -> FETCH_HEAD",
+                                   TRANSPORT_SUMMARY_WIDTH,
+                                   *kind ? kind : "branch",
+                                   REFCOL_WIDTH,
+                                   *what ? what : "HEAD");
+               if (note.len) {
                        if (verbosity >= 0 && !shown_url) {
                                fprintf(stderr, _("From %.*s\n"),
                                                url_len, url);
                                shown_url = 1;
                        }
                        if (verbosity >= 0)
-                               fprintf(stderr, " %s\n", note);
+                               fprintf(stderr, " %s\n", note.buf);
                }
        }
        free(url);
                error(_("some local refs could not be updated; try running\n"
                      " 'git remote prune %s' to remove any old, conflicting "
                      "branches"), remote_name);
+       strbuf_release(&note);
        return rc;
  }
  
@@@ -540,10 -551,10 +551,10 @@@ static int fetch_refs(struct transport 
        return ret;
  }
  
 -static int prune_refs(struct transport *transport, struct ref *ref_map)
 +static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map)
  {
        int result = 0;
 -      struct ref *ref, *stale_refs = get_stale_heads(transport->remote, ref_map);
 +      struct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);
        const char *dangling_msg = dry_run
                ? _("   (%s will become dangling)\n")
                : _("   (%s has become dangling)\n");
@@@ -734,31 -745,8 +745,31 @@@ static int do_fetch(struct transport *t
                free_refs(ref_map);
                return 1;
        }
 -      if (prune)
 -              prune_refs(transport, ref_map);
 +      if (prune) {
 +              /* If --tags was specified, pretend the user gave us the canonical tags refspec */
 +              if (tags == TAGS_SET) {
 +                      const char *tags_str = "refs/tags/*:refs/tags/*";
 +                      struct refspec *tags_refspec, *refspec;
 +
 +                      /* Copy the refspec and add the tags to it */
 +                      refspec = xcalloc(ref_count + 1, sizeof(struct refspec));
 +                      tags_refspec = parse_fetch_refspec(1, &tags_str);
 +                      memcpy(refspec, refs, ref_count * sizeof(struct refspec));
 +                      memcpy(&refspec[ref_count], tags_refspec, sizeof(struct refspec));
 +                      ref_count++;
 +
 +                      prune_refs(refspec, ref_count, ref_map);
 +
 +                      ref_count--;
 +                      /* The rest of the strings belong to fetch_one */
 +                      free_refspec(1, tags_refspec);
 +                      free(refspec);
 +              } else if (ref_count) {
 +                      prune_refs(refs, ref_count, ref_map);
 +              } else {
 +                      prune_refs(transport->remote->fetch, transport->remote->fetch_refspec_nr, ref_map);
 +              }
 +      }
        free_refs(ref_map);
  
        /* if neither --no-tags nor --tags was specified, do automated tag
@@@ -941,7 -929,7 +952,7 @@@ static int fetch_one(struct remote *rem
        atexit(unlock_pack);
        refspec = parse_fetch_refspec(ref_nr, refs);
        exit_code = do_fetch(transport, refspec, ref_nr);
 -      free(refspec);
 +      free_refspec(ref_nr, refspec);
        transport_disconnect(transport);
        transport = NULL;
        return exit_code;