Code

Merge branch 'maint-1.5.4' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 23 Apr 2008 06:37:06 +0000 (23:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Apr 2008 06:37:06 +0000 (23:37 -0700)
* maint-1.5.4:
  svn-git: Use binmode for reading/writing binary rev maps
  diff options documentation: refer to --diff-filter in --name-status
  git-svn bug with blank commits and author file
  archive.c: format_subst - fixed bogus argument to memchr
  copy.c: copy_fd - correctly report write errors
  gitattributes: Fix subdirectory attributes specified from root directory

1  2 
Documentation/diff-options.txt
git-svn.perl
t/t0003-attributes.sh

index 01e7a578510f50af7365ec20e96d1538da424faa,60d0e53a78974a99af3178fb11745fdaa51fd6fe..13234fa280b279bfccad0a9aec6989727957567a
@@@ -58,14 -58,6 +58,14 @@@ endif::git-format-patch[
        number of modified files, as well as number of added and deleted
        lines.
  
 +--dirstat[=limit]::
 +      Output only the sub-directories that are impacted by a diff,
 +      and to what degree they are impacted.  You can override the
 +      default cut-off in percent (3) by "--dirstat=limit".  If you
 +      want to enable "cumulative" directory statistics, you can use
 +      the "--cumulative" flag, which adds up percentages recursively
 +      even when they have been already reported for a sub-directory.
 +
  --summary::
        Output a condensed summary of extended header information
        such as creations, renames and mode changes.
@@@ -83,7 -75,8 +83,8 @@@
        Show only names of changed files.
  
  --name-status::
-       Show only names and status of changed files.
+       Show only names and status of changed files. See the description
+       of the `--diff-filter` option on what the status letters mean.
  
  --color::
        Show colored diff.
        Swap two inputs; that is, show differences from index or
        on-disk file to tree contents.
  
 +--relative[=<path>]::
 +      When run from a subdirectory of the project, it can be
 +      told to exclude changes outside the directory and show
 +      pathnames relative to it with this option.  When you are
 +      not in a subdirectory (e.g. in a bare repository), you
 +      can name which subdirectory to make the output relative
 +      to by giving a <path> as an argument.
 +
  --text::
        Treat all files as text.
  
diff --combined git-svn.perl
index b864b54a4440537900cab47e71ee93bd01d72d28,49dd80644b11d8e44a103a6cc1c3a606ad3b4bbd..b1510495a7f003991a37d0810c551404c6c1252c
@@@ -186,9 -186,6 +186,9 @@@ my %cmd = 
                    "Show info about the latest SVN revision
                     on the current branch",
                    { 'url' => \$_url, } ],
 +      'blame' => [ \&Git::SVN::Log::cmd_blame,
 +                  "Show what revision and author last modified each line of a file",
 +                  {} ],
  );
  
  my $cmd;
@@@ -1120,7 -1117,7 +1120,7 @@@ sub cmt_metadata 
  
  sub working_head_info {
        my ($head, $refs) = @_;
 -      my @args = ('log', '--no-color', '--first-parent');
 +      my @args = ('log', '--no-color', '--first-parent', '--pretty=medium');
        my ($fh, $ctx) = command_output_pipe(@args, $head);
        my $hash;
        my %max;
@@@ -1252,8 -1249,7 +1252,8 @@@ use File::Path qw/mkpath/
  use File::Copy qw/copy/;
  use IPC::Open3;
  
 -my $_repack_nr;
 +my ($_gc_nr, $_gc_period);
 +
  # properties that we do not log:
  my %SKIP_PROP;
  BEGIN {
@@@ -1414,10 -1410,9 +1414,10 @@@ sub read_all_remotes 
  }
  
  sub init_vars {
 -      $_repack = 1000 unless (defined $_repack && $_repack > 0);
 -      $_repack_nr = $_repack;
 -      $_repack_flags ||= '-d';
 +      $_gc_nr = $_gc_period = 1000;
 +      if (defined $_repack || defined $_repack_flags) {
 +             warn "Repack options are obsolete; they have no effect.\n";
 +      }
  }
  
  sub verify_remotes_sanity {
@@@ -1900,7 -1895,7 +1900,7 @@@ sub prop_walk 
  
        foreach (sort keys %$dirent) {
                next if $dirent->{$_}->{kind} != $SVN::Node::dir;
 -              $self->prop_walk($path . '/' . $_, $rev, $sub);
 +              $self->prop_walk($p . $_, $rev, $sub);
        }
  }
  
@@@ -2108,10 -2103,6 +2108,10 @@@ sub restore_commit_header_env 
        }
  }
  
 +sub gc {
 +      command_noisy('gc', '--auto');
 +};
 +
  sub do_git_commit {
        my ($self, $log_entry) = @_;
        my $lr = $self->last_rev;
                                   0, $self->svm_uuid);
        }
        print " = $commit ($self->{ref_id})\n";
 -      if ($_repack && (--$_repack_nr == 0)) {
 -              $_repack_nr = $_repack;
 -              # repack doesn't use any arguments with spaces in them, does it?
 -              print "Running git repack $_repack_flags ...\n";
 -              command_noisy('repack', split(/\s+/, $_repack_flags));
 -              print "Done repacking\n";
 +      if (--$_gc_nr == 0) {
 +              $_gc_nr = $_gc_period;
 +              gc();
        }
        return $commit;
  }
@@@ -2239,13 -2233,7 +2239,13 @@@ sub find_parent_branch 
                # just grow a tail if we're not unique enough :x
                $ref_id .= '-' while find_ref($ref_id);
                print STDERR "Initializing parent: $ref_id\n";
 -              $gs = Git::SVN->init($new_url, '', $ref_id, $ref_id, 1);
 +              my ($u, $p, $repo_id) = ($new_url, '', $ref_id);
 +              if ($u =~ s#^\Q$url\E(/|$)##) {
 +                      $p = $u;
 +                      $u = $url;
 +                      $repo_id = $self->{repo_id};
 +              }
 +              $gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
        }
        my ($r0, $parent) = $gs->find_rev_before($r, 1);
        if (!defined $r0 || !defined $parent) {
@@@ -2375,8 -2363,7 +2375,7 @@@ sub check_author 
        my ($author) = @_;
        if (!defined $author || length $author == 0) {
                $author = '(no author)';
-       }
-       if (defined $::_authors && ! defined $::users{$author}) {
+       } elsif (defined $::_authors && ! defined $::users{$author}) {
                die "Author: $author not defined in $::_authors file\n";
        }
        $author;
@@@ -2519,6 -2506,7 +2518,7 @@@ sub rebuild_from_rev_db 
        my ($self, $path) = @_;
        my $r = -1;
        open my $fh, '<', $path or croak "open: $!";
+       binmode $fh or croak "binmode: $!";
        while (<$fh>) {
                length($_) == 41 or croak "inconsistent size in ($_) != 41";
                chomp($_);
@@@ -2616,6 -2604,7 +2616,7 @@@ sub rebuild 
  sub _rev_map_set {
        my ($fh, $rev, $commit) = @_;
  
+       binmode $fh or croak "binmode: $!";
        my $size = (stat($fh))[7];
        ($size % 24) == 0 or croak "inconsistent size: $size";
  
@@@ -2719,6 -2708,7 +2720,7 @@@ sub rev_map_max 
        my $map_path = $self->map_path;
        stat $map_path or return $want_commit ? (0, undef) : 0;
        sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
+       binmode $fh or croak "binmode: $!";
        my $size = (stat($fh))[7];
        ($size % 24) == 0 or croak "inconsistent size: $size";
  
@@@ -2751,6 -2741,7 +2753,7 @@@ sub rev_map_get 
        return undef unless -e $map_path;
  
        sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
+       binmode $fh or croak "binmode: $!";
        my $size = (stat($fh))[7];
        ($size % 24) == 0 or croak "inconsistent size: $size";
  
@@@ -3666,7 -3657,7 +3669,7 @@@ sub escape_uri_only 
        my ($uri) = @_;
        my @tmp;
        foreach (split m{/}, $uri) {
 -              s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
 +              s/([^\w.%-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
                push @tmp, $_;
        }
        join('/', @tmp);
@@@ -4003,7 -3994,6 +4006,7 @@@ sub gs_fetch_loop_common 
                $max += $inc;
                $max = $head if ($max > $head);
        }
 +      Git::SVN::gc();
  }
  
  sub match_globs {
        print commit_log_separator unless $incremental || $oneline;
  }
  
 +sub cmd_blame {
 +      my $path = shift;
 +
 +      config_pager();
 +      run_pager();
 +
 +      my ($fh, $ctx) = command_output_pipe('blame', @_, $path);
 +      while (my $line = <$fh>) {
 +              if ($line =~ /^\^?([[:xdigit:]]+)\s/) {
 +                      my (undef, $rev, undef) = ::cmt_metadata($1);
 +                      $rev = sprintf('%-10s', $rev);
 +                      $line =~ s/^\^?[[:xdigit:]]+(\s)/$rev$1/;
 +              }
 +              print $line;
 +      }
 +      command_close_pipe($fh, $ctx);
 +}
 +
  package Git::SVN::Migration;
  # these version numbers do NOT correspond to actual version numbers
  # of git nor git-svn.  They are just relative.
diff --combined t/t0003-attributes.sh
index 3faf135e38ccbe71241679da464d7cf709ae73d7,e7fa4f5d43ffb95e79a295b3969ea1ad0160a82e..c56d2fbabaa0fdd90547ce8b629a629c21fbbc0e
@@@ -11,7 -11,7 +11,7 @@@ attr_check () 
  
        git check-attr test -- "$path" >actual &&
        echo "$path: test: $2" >expect &&
 -      diff -u expect actual
 +      test_cmp expect actual
  
  }
  
@@@ -21,6 -21,7 +21,7 @@@ test_expect_success 'setup' 
        mkdir -p a/b/d a/c &&
        (
                echo "f test=f"
+               echo "a/i test=a/i"
        ) >.gitattributes &&
        (
                echo "g test=a/g" &&
@@@ -46,4 -47,11 +47,11 @@@ test_expect_success 'attribute test' 
  
  '
  
+ test_expect_success 'root subdir attribute test' '
+       attr_check a/i a/i &&
+       attr_check subdir/a/i unspecified
+ '
  test_done