Merge branch 'maint-1.6.0' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 14 Jan 2009 07:10:50 +0000 (23:10 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jan 2009 07:10:50 +0000 (23:10 -0800)
* maint-1.6.0:
fast-import: Cleanup mode setting.
Git.pm: call Error::Simple() properly

1  2 
fast-import.c
perl/Git.pm
diff --combined fast-import.c
index a6bce661963812691503116e8d61d9ef90f96526,6d5ee6f4636747d62abd06ae7a37dad8681beacc..f0e08aca70c16e9309dde87954593a76ad37b9ef
@@@ -376,7 -376,7 +376,7 @@@ static void dump_marks_helper(FILE *, u
  
  static void write_crash_report(const char *err)
  {
 -      char *loc = git_path("fast_import_crash_%d", getpid());
 +      char *loc = git_path("fast_import_crash_%"PRIuMAX, (uintmax_t) getpid());
        FILE *rpt = fopen(loc, "w");
        struct branch *b;
        unsigned long lu;
        fprintf(stderr, "fast-import: dumping crash report to %s\n", loc);
  
        fprintf(rpt, "fast-import crash report:\n");
 -      fprintf(rpt, "    fast-import process: %d\n", getpid());
 -      fprintf(rpt, "    parent process     : %d\n", getppid());
 +      fprintf(rpt, "    fast-import process: %"PRIuMAX"\n", (uintmax_t) getpid());
 +      fprintf(rpt, "    parent process     : %"PRIuMAX"\n", (uintmax_t) getppid());
        fprintf(rpt, "    at %s\n", show_date(time(NULL), 0, DATE_LOCAL));
        fputc('\n', rpt);
  
@@@ -554,10 -554,6 +554,10 @@@ static void *pool_alloc(size_t len
        struct mem_pool *p;
        void *r;
  
 +      /* round up to a 'uintmax_t' alignment */
 +      if (len & (sizeof(uintmax_t) - 1))
 +              len += sizeof(uintmax_t) - (len & (sizeof(uintmax_t) - 1));
 +
        for (p = mem_pool; p; p = p->next_pool)
                if ((p->end - p->next_free >= len))
                        break;
        }
  
        r = p->next_free;
 -      /* round out to a 'uintmax_t' alignment */
 -      if (len & (sizeof(uintmax_t) - 1))
 -              len += sizeof(uintmax_t) - (len & (sizeof(uintmax_t) - 1));
        p->next_free += len;
        return r;
  }
@@@ -846,7 -845,7 +846,7 @@@ static int oecmp (const void *a_, cons
  static char *create_index(void)
  {
        static char tmpfile[PATH_MAX];
 -      SHA_CTX ctx;
 +      git_SHA_CTX ctx;
        struct sha1file *f;
        struct object_entry **idx, **c, **last, *e;
        struct object_entry_pool *o;
        idx_fd = xmkstemp(tmpfile);
        f = sha1fd(idx_fd, tmpfile);
        sha1write(f, array, 256 * sizeof(int));
 -      SHA1_Init(&ctx);
 +      git_SHA1_Init(&ctx);
        for (c = idx; c != last; c++) {
                uint32_t offset = htonl((*c)->offset);
                sha1write(f, &offset, 4);
                sha1write(f, (*c)->sha1, sizeof((*c)->sha1));
 -              SHA1_Update(&ctx, (*c)->sha1, 20);
 +              git_SHA1_Update(&ctx, (*c)->sha1, 20);
        }
        sha1write(f, pack_data->sha1, sizeof(pack_data->sha1));
        sha1close(f, NULL, CSUM_FSYNC);
        free(idx);
 -      SHA1_Final(pack_data->sha1, &ctx);
 +      git_SHA1_Final(pack_data->sha1, &ctx);
        return tmpfile;
  }
  
@@@ -1036,15 -1035,15 +1036,15 @@@ static int store_object
        unsigned char hdr[96];
        unsigned char sha1[20];
        unsigned long hdrlen, deltalen;
 -      SHA_CTX c;
 +      git_SHA_CTX c;
        z_stream s;
  
        hdrlen = sprintf((char*)hdr,"%s %lu", typename(type),
                (unsigned long)dat->len) + 1;
 -      SHA1_Init(&c);
 -      SHA1_Update(&c, hdr, hdrlen);
 -      SHA1_Update(&c, dat->buf, dat->len);
 -      SHA1_Final(sha1, &c);
 +      git_SHA1_Init(&c);
 +      git_SHA1_Update(&c, hdr, hdrlen);
 +      git_SHA1_Update(&c, dat->buf, dat->len);
 +      git_SHA1_Final(sha1, &c);
        if (sha1out)
                hashcpy(sha1out, sha1);
  
@@@ -1748,12 -1747,9 +1748,12 @@@ static int validate_raw_date(const cha
  {
        const char *orig_src = src;
        char *endp, sign;
 +      unsigned long date;
 +
 +      errno = 0;
  
 -      strtoul(src, &endp, 10);
 -      if (endp == src || *endp != ' ')
 +      date = strtoul(src, &endp, 10);
 +      if (errno || endp == src || *endp != ' ')
                return -1;
  
        src = endp + 1;
                return -1;
        sign = *src;
  
 -      strtoul(src + 1, &endp, 10);
 -      if (endp == src || *endp || (endp - orig_src) >= maxlen)
 +      date = strtoul(src + 1, &endp, 10);
 +      if (errno || endp == src || *endp || (endp - orig_src) >= maxlen)
                return -1;
  
        strcpy(result, orig_src);
@@@ -1872,12 -1868,13 +1872,13 @@@ static void file_change_m(struct branc
        if (!p)
                die("Corrupt mode: %s", command_buf.buf);
        switch (mode) {
+       case 0644:
+       case 0755:
+               mode |= S_IFREG;
        case S_IFREG | 0644:
        case S_IFREG | 0755:
        case S_IFLNK:
        case S_IFGITLINK:
-       case 0644:
-       case 0755:
                /* ok */
                break;
        default:
                            typename(type), command_buf.buf);
        }
  
-       tree_content_set(&b->branch_tree, p, sha1, S_IFREG | mode, NULL);
+       tree_content_set(&b->branch_tree, p, sha1, mode, NULL);
  }
  
  static void file_change_d(struct branch *b)
diff --combined perl/Git.pm
index 8392a68333cd57b899962ef6a7a9ca80dd5d583d,29a17839f3564bb5518304569e592a738e78d8af..e9f8c9c048f3e9b7c0e3e492078c1d30a2044d78
@@@ -204,14 -204,14 +204,14 @@@ sub repository 
  
                        unless (-d "$dir/refs" and -d "$dir/objects" and -e "$dir/HEAD") {
                                # Mimick git-rev-parse --git-dir error message:
 -                              throw Error::Simple('fatal: Not a git repository');
 +                              throw Error::Simple("fatal: Not a git repository: $dir");
                        }
                        my $search = Git->repository(Repository => $dir);
                        try {
                                $search->command('symbolic-ref', 'HEAD');
                        } catch Git::Error::Command with {
                                # Mimick git-rev-parse --git-dir error message:
 -                              throw Error::Simple('fatal: Not a git repository');
 +                              throw Error::Simple("fatal: Not a git repository: $dir");
                        }
  
                        $opts{Repository} = abs_path($dir);
@@@ -961,7 -961,9 +961,7 @@@ issue
  =cut
  
  sub temp_acquire {
 -      my ($self, $name) = _maybe_self(@_);
 -
 -      my $temp_fd = _temp_cache($name);
 +      my $temp_fd = _temp_cache(@_);
  
        $TEMP_FILES{$temp_fd}{locked} = 1;
        $temp_fd;
@@@ -1003,15 -1005,15 +1003,15 @@@ sub temp_release 
  }
  
  sub _temp_cache {
 -      my ($name) = @_;
 +      my ($self, $name) = _maybe_self(@_);
  
        _verify_require();
  
        my $temp_fd = \$TEMP_FILEMAP{$name};
        if (defined $$temp_fd and $$temp_fd->opened) {
                if ($TEMP_FILES{$$temp_fd}{locked}) {
-                       throw Error::Simple("Temp file with moniker '",
-                               $name, "' already in use");
+                       throw Error::Simple("Temp file with moniker '" .
+                               $name . "' already in use");
                }
        } else {
                if (defined $$temp_fd) {
                                "' was closed. Opening replacement.";
                }
                my $fname;
 +
 +              my $tmpdir;
 +              if (defined $self) {
 +                      $tmpdir = $self->repo_path();
 +              }
 +
                ($$temp_fd, $fname) = File::Temp->tempfile(
 -                      'Git_XXXXXX', UNLINK => 1
 +                      'Git_XXXXXX', UNLINK => 1, DIR => $tmpdir,
                        ) or throw Error::Simple("couldn't open new temp file");
 +
                $$temp_fd->autoflush;
                binmode $$temp_fd;
                $TEMP_FILES{$$temp_fd}{fname} = $fname;