Merge branch 'maint'
authorJunio C Hamano <junkio@cox.net>
Sun, 29 Apr 2007 08:52:43 +0000 (01:52 -0700)
committerJunio C Hamano <junkio@cox.net>
Sun, 29 Apr 2007 08:52:43 +0000 (01:52 -0700)
* maint:
http.c: Fix problem with repeated calls of http_init
Add missing reference to GIT_COMMITTER_DATE in git-commit-tree documentation
Fix import-tars fix.
Update .mailmap with "Michael"
Do not barf on too long action description
Catch empty pathnames in trees during fsck
Don't allow empty pathnames in fast-import
import-tars: be nice to wrong directory modes
git-svn: Added 'find-rev' command
git shortlog documentation: add long options and fix a typo

1  2 
Documentation/git.txt
builtin-fetch--tool.c
builtin-fsck.c
contrib/fast-import/import-tars.perl
fast-import.c
diff --combined Documentation/git.txt
index ca1f78f790149d845e7f74fc8456399589e2e5b9,c81162eba5ec50b3b58bc008b2f82060d3fe4e23..08ba53ae010bda8970642f142c1438b73b6c38d2
@@@ -37,11 -37,7 +37,11 @@@ Documentation for older releases are av
  
  * link:RelNotes-1.5.1.txt[release notes for 1.5.1]
  
 -* link:v1.5.0.7/git.html[documentation for release 1.5.0.7]
 +* link:v1.5.1.2/git.html[documentation for release 1.5.1.2]
 +
 +* link:RelNotes-1.5.1.2.txt[release notes for 1.5.1.2]
 +
 +* link:RelNotes-1.5.1.1.txt[release notes for 1.5.1.1]
  
  * link:RelNotes-1.5.0.7.txt[release notes for 1.5.0.7]
  
@@@ -344,6 -340,7 +344,7 @@@ git Commit
  'GIT_AUTHOR_DATE'::
  'GIT_COMMITTER_NAME'::
  'GIT_COMMITTER_EMAIL'::
+ 'GIT_COMMITTER_DATE'::
        see gitlink:git-commit-tree[1]
  
  git Diffs
diff --combined builtin-fetch--tool.c
index 3145c01f7e0e81bf28314b92737ccf2abb129dcd,2ad45dcd447c582fc37dc133c9a7bb3260dc31ea..2065466f272dba506e6c34f16b12e4726996e0ec
@@@ -35,16 -35,13 +35,13 @@@ static int update_ref(const char *actio
                      unsigned char *sha1,
                      unsigned char *oldval)
  {
-       int len;
        char msg[1024];
        char *rla = getenv("GIT_REFLOG_ACTION");
        static struct ref_lock *lock;
  
        if (!rla)
                rla = "(reflog update)";
-       len = snprintf(msg, sizeof(msg), "%s: %s", rla, action);
-       if (sizeof(msg) <= len)
-               die("insanely long action");
+       snprintf(msg, sizeof(msg), "%s: %s", rla, action);
        lock = lock_any_ref_for_update(refname, oldval);
        if (!lock)
                return 1;
@@@ -436,87 -433,10 +433,87 @@@ static int expand_refs_wildcard(const c
        return 0;
  }
  
 +static int pick_rref(int sha1_only, const char *rref, const char *ls_remote_result)
 +{
 +      int err = 0;
 +      int lrr_count = lrr_count, i, pass;
 +      const char *cp;
 +      struct lrr {
 +              const char *line;
 +              const char *name;
 +              int namelen;
 +              int shown;
 +      } *lrr_list = lrr_list;
 +
 +      for (pass = 0; pass < 2; pass++) {
 +              /* pass 0 counts and allocates, pass 1 fills... */
 +              cp = ls_remote_result;
 +              i = 0;
 +              while (1) {
 +                      const char *np;
 +                      while (*cp && isspace(*cp))
 +                              cp++;
 +                      if (!*cp)
 +                              break;
 +                      np = strchr(cp, '\n');
 +                      if (!np)
 +                              np = cp + strlen(cp);
 +                      if (pass) {
 +                              lrr_list[i].line = cp;
 +                              lrr_list[i].name = cp + 41;
 +                              lrr_list[i].namelen = np - (cp + 41);
 +                      }
 +                      i++;
 +                      cp = np;
 +              }
 +              if (!pass) {
 +                      lrr_count = i;
 +                      lrr_list = xcalloc(lrr_count, sizeof(*lrr_list));
 +              }
 +      }
 +
 +      while (1) {
 +              const char *next;
 +              int rreflen;
 +              int i;
 +
 +              while (*rref && isspace(*rref))
 +                      rref++;
 +              if (!*rref)
 +                      break;
 +              next = strchr(rref, '\n');
 +              if (!next)
 +                      next = rref + strlen(rref);
 +              rreflen = next - rref;
 +
 +              for (i = 0; i < lrr_count; i++) {
 +                      struct lrr *lrr = &(lrr_list[i]);
 +
 +                      if (rreflen == lrr->namelen &&
 +                          !memcmp(lrr->name, rref, rreflen)) {
 +                              if (!lrr->shown)
 +                                      printf("%.*s\n",
 +                                             sha1_only ? 40 : lrr->namelen + 41,
 +                                             lrr->line);
 +                              lrr->shown = 1;
 +                              break;
 +                      }
 +              }
 +              if (lrr_count <= i) {
 +                      error("pick-rref: %.*s not found", rreflen, rref);
 +                      err = 1;
 +              }
 +              rref = next;
 +      }
 +      free(lrr_list);
 +      return err;
 +}
 +
  int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
  {
        int verbose = 0;
        int force = 0;
 +      int sopt = 0;
  
        while (1 < argc) {
                const char *arg = argv[1];
                        verbose = 1;
                else if (!strcmp("-f", arg))
                        force = 1;
 +              else if (!strcmp("-s", arg))
 +                      sopt = 1;
                else
                        break;
                argc--;
                        reflist = get_stdin();
                return parse_reflist(reflist);
        }
 +      if (!strcmp("pick-rref", argv[1])) {
 +              const char *ls_remote_result;
 +              if (argc != 4)
 +                      return error("pick-rref takes 2 args");
 +              ls_remote_result = argv[3];
 +              if (!strcmp(ls_remote_result, "-"))
 +                      ls_remote_result = get_stdin();
 +              return pick_rref(sopt, argv[2], ls_remote_result);
 +      }
        if (!strcmp("expand-refs-wildcard", argv[1])) {
                const char *reflist;
                if (argc < 4)
diff --combined builtin-fsck.c
index fcb8ed5af1bc50df19a2f533989aa9673ea166e8,75e10e25ecdee18b226fe434c270d5660eb5d74b..44ce629a498f986f239e008a61d32e10968907e0
@@@ -14,7 -14,6 +14,7 @@@
  static int show_root;
  static int show_tags;
  static int show_unreachable;
 +static int include_reflogs = 1;
  static int check_full;
  static int check_strict;
  static int keep_cache_objects;
@@@ -219,6 -218,7 +219,7 @@@ static int fsck_tree(struct tree *item
  {
        int retval;
        int has_full_path = 0;
+       int has_empty_name = 0;
        int has_zero_pad = 0;
        int has_bad_modes = 0;
        int has_dup_entries = 0;
  
                if (strchr(name, '/'))
                        has_full_path = 1;
+               if (!*name)
+                       has_empty_name = 1;
                has_zero_pad |= *(char *)desc.buffer == '0';
                update_tree_entry(&desc);
  
                case S_IFREG | 0644:
                case S_IFLNK:
                case S_IFDIR:
 +              case S_IFDIRLNK:
                        break;
                /*
                 * This is nonstandard, but we had a few of these
        if (has_full_path) {
                objwarning(&item->object, "contains full pathnames");
        }
+       if (has_empty_name) {
+               objwarning(&item->object, "contains empty pathname");
+       }
        if (has_zero_pad) {
                objwarning(&item->object, "contains zero-padded file modes");
        }
@@@ -350,7 -354,7 +356,7 @@@ static int fsck_tag(struct tag *tag
        return 0;
  }
  
 -static int fsck_sha1(unsigned char *sha1)
 +static int fsck_sha1(const unsigned char *sha1)
  {
        struct object *obj = parse_object(sha1);
        if (!obj) {
@@@ -519,8 -523,7 +525,8 @@@ static int fsck_handle_ref(const char *
  static void get_default_heads(void)
  {
        for_each_ref(fsck_handle_ref, NULL);
 -      for_each_reflog(fsck_handle_reflog, NULL);
 +      if (include_reflogs)
 +              for_each_reflog(fsck_handle_reflog, NULL);
  
        /*
         * Not having any default heads isn't really fatal, but
@@@ -627,10 -630,6 +633,10 @@@ int cmd_fsck(int argc, char **argv, con
                        keep_cache_objects = 1;
                        continue;
                }
 +              if (!strcmp(arg, "--no-reflogs")) {
 +                      include_reflogs = 0;
 +                      continue;
 +              }
                if (!strcmp(arg, "--full")) {
                        check_full = 1;
                        continue;
                        verify_pack(p, 0);
  
                for (p = packed_git; p; p = p->next) {
 -                      uint32_t i, num = num_packed_objects(p);
 -                      for (i = 0; i < num; i++) {
 -                              unsigned char sha1[20];
 -                              nth_packed_object_sha1(p, i, sha1);
 -                              fsck_sha1(sha1);
 -                      }
 +                      uint32_t i, num = p->num_objects;
 +                      for (i = 0; i < num; i++)
 +                              fsck_sha1(nth_packed_object_sha1(p, i));
                }
        }
  
                int i;
                read_cache();
                for (i = 0; i < active_nr; i++) {
 -                      struct blob *blob = lookup_blob(active_cache[i]->sha1);
 +                      unsigned int mode;
 +                      struct blob *blob;
                        struct object *obj;
 +
 +                      mode = ntohl(active_cache[i]->ce_mode);
 +                      if (S_ISDIRLNK(mode))
 +                              continue;
 +                      blob = lookup_blob(active_cache[i]->sha1);
                        if (!blob)
                                continue;
                        obj = &blob->object;
index 184214689dfd3f1204546b060adbffd3f6d79bbe,82a90429c8e1a1095851fc706bd456466da40008..d2363a415d5a1a7a77fede7f5573342f9a20e755
@@@ -52,6 -52,7 +52,7 @@@ foreach my $tar_file (@ARGV
                        Z8 Z1 Z100 Z6
                        Z2 Z32 Z32 Z8 Z8 Z*', $_;
                last unless $name;
+               next if $name =~ m{/\z};
                $mode = oct $mode;
                $size = oct $size;
                $mtime = oct $mtime;
                }
                print FI "\n";
  
 -              my $path = "$prefix$name";
 +              my $path;
 +              if ($prefix) {
 +                      $path = "$prefix/$name";
 +              } else {
 +                      $path = "$name";
 +              }
                $files{$path} = [$next_mark++, $mode];
  
                $commit_time = $mtime if $mtime > $commit_time;
diff --combined fast-import.c
index c4c8cb905e3bcdfb131af40da9f7e29ca86b4a01,6c43a0d37f781294a8844ea52c9ce9728396f456..b4cbcd90118c47d47e8940322c8ec2161b33a92a
@@@ -673,7 -673,7 +673,7 @@@ static void fixup_header_footer(void
  
        buf = xmalloc(buf_sz);
        for (;;) {
 -              size_t n = xread(pack_fd, buf, buf_sz);
 +              ssize_t n = xread(pack_fd, buf, buf_sz);
                if (!n)
                        break;
                if (n < 0)
@@@ -904,12 -904,6 +904,12 @@@ static int store_object
        if (e->offset) {
                duplicate_count_by_type[type]++;
                return 1;
 +      } else if (find_sha1_pack(sha1, packed_git)) {
 +              e->type = type;
 +              e->pack_id = MAX_PACK_ID;
 +              e->offset = 1; /* just not zero! */
 +              duplicate_count_by_type[type]++;
 +              return 1;
        }
  
        if (last && last->data && last->depth < max_depth) {
@@@ -1199,6 -1193,8 +1199,8 @@@ static int tree_content_set
                n = slash1 - p;
        else
                n = strlen(p);
+       if (!n)
+               die("Empty path component found in input");
  
        for (i = 0; i < t->entry_count; i++) {
                e = t->entries[i];
@@@ -2027,7 -2023,6 +2029,7 @@@ static void import_marks(const char *in
                        e = insert_object(sha1);
                        e->type = type;
                        e->pack_id = MAX_PACK_ID;
 +                      e->offset = 1; /* just not zero! */
                }
                insert_mark(mark, e);
        }
@@@ -2093,7 -2088,6 +2095,7 @@@ int main(int argc, const char **argv
        if (i != argc)
                usage(fast_import_usage);
  
 +      prepare_packed_git();
        start_packfile();
        for (;;) {
                read_next_command();