Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Mar 2008 04:40:47 +0000 (21:40 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Mar 2008 04:40:47 +0000 (21:40 -0700)
* maint:
git-svn: fix find-rev error message when missing arg
t0021: tr portability fix for Solaris
launch_editor(): allow spaces in the filename
git rebase --abort: always restore the right commit

1  2 
builtin-tag.c
git-svn.perl
diff --combined builtin-tag.c
index 28c36fdcd1658968ff7c3e2f1d6ba6f364f99592,9a59caf70d74cae9b7eae858402233ad6f7c3984..8dd959fe1c74507023f8e82c7f4682c1588ebac6
@@@ -50,12 -50,15 +50,15 @@@ void launch_editor(const char *path, st
                size_t len = strlen(editor);
                int i = 0;
                const char *args[6];
+               struct strbuf arg0;
  
+               strbuf_init(&arg0, 0);
                if (strcspn(editor, "$ \t'") != len) {
                        /* there are specials */
+                       strbuf_addf(&arg0, "%s \"$@\"", editor);
                        args[i++] = "sh";
                        args[i++] = "-c";
-                       args[i++] = "$0 \"$@\"";
+                       args[i++] = arg0.buf;
                }
                args[i++] = editor;
                args[i++] = path;
@@@ -63,6 -66,7 +66,7 @@@
  
                if (run_command_v_opt_cd_env(args, 0, NULL, env))
                        die("There was a problem with the editor %s.", editor);
+               strbuf_release(&arg0);
        }
  
        if (!buffer)
@@@ -226,17 -230,19 +230,17 @@@ static int do_sign(struct strbuf *buffe
  
        if (write_in_full(gpg.in, buffer->buf, buffer->len) != buffer->len) {
                close(gpg.in);
 +              close(gpg.out);
                finish_command(&gpg);
                return error("gpg did not accept the tag data");
        }
        close(gpg.in);
 -      gpg.close_in = 0;
        len = strbuf_read(buffer, gpg.out, 1024);
 +      close(gpg.out);
  
        if (finish_command(&gpg) || !len || len < 0)
                return error("gpg failed to sign the tag");
  
 -      if (len < 0)
 -              return error("could not read the entire signature from gpg.");
 -
        return 0;
  }
  
diff --combined git-svn.perl
index 1195569529401fd1c62414c8683a6b577721c1c7,38e1d5944d309f6b1f4b58fd5857a1bfb0545cc9..d8b38c9a47c0b77dd55781a66e42e4dec26fd4b7
@@@ -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;
@@@ -522,7 -519,8 +522,8 @@@ sub cmd_dcommit 
  }
  
  sub cmd_find_rev {
-       my $revision_or_hash = shift;
+       my $revision_or_hash = shift or die "SVN or git revision required ",
+                                           "as a command-line argument\n";
        my $result;
        if ($revision_or_hash =~ /^r\d+$/) {
                my $head = shift;
@@@ -1250,8 -1248,7 +1251,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 {
@@@ -1412,10 -1409,9 +1413,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 {
@@@ -2106,10 -2102,6 +2107,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;
  }
@@@ -2237,12 -2232,7 +2238,12 @@@ 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) = ($new_url, '');
 +              if ($u =~ s#^\Q$url\E(/|$)##) {
 +                      $p = $u;
 +                      $u = $url;
 +              }
 +              $gs = Git::SVN->init($u, $p, $self->{repo_id}, $ref_id, 1);
        }
        my ($r0, $parent) = $gs->find_rev_before($r, 1);
        if (!defined $r0 || !defined $parent) {
@@@ -4000,7 -3990,6 +4001,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.