Merge branch 'gfi-maint' into gfi-master
authorShawn O. Pearce <spearce@spearce.org>
Sun, 29 Apr 2007 00:05:58 +0000 (20:05 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 29 Apr 2007 00:05:58 +0000 (20:05 -0400)
* gfi-maint:
Don't allow empty pathnames in fast-import
import-tars: be nice to wrong directory modes

1  2 
contrib/fast-import/import-tars.perl
fast-import.c
index 184214689dfd3f1204546b060adbffd3f6d79bbe,e84647770abbac3090bd92d256edf23565a0bae6..557508015788f203c37c6a7402a147e53ab3943b
@@@ -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 =~ '/$';
                $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();