Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Fri, 31 Oct 2008 08:42:58 +0000 (01:42 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 31 Oct 2008 08:42:58 +0000 (01:42 -0700)
* maint:
git-svn: change dashed git-commit-tree to git commit-tree
Documentation: clarify information about 'ident' attribute
bash completion: add doubledash to "git show"
Use test-chmtime -v instead of perl in t5000 to get mtime of a file
Add --verbose|-v to test-chmtime
asciidoc: add minor workaround to add an empty line after code blocks
Plug a memleak in builtin-revert
Add file delete/create info when we overflow rename_limit
Install git-cvsserver in $(bindir)
Install git-shell in bindir, too

1  2 
Documentation/gitattributes.txt
builtin-revert.c
contrib/completion/git-completion.bash
git-svn.perl
index 26945593cb1739bb6a6e1e2acc2cd78caab3a102,42776f089b55989200f58cf1e968a11cbbd93900..24e880c5be1306017ca394af16891cf081fdc30b
@@@ -163,8 -163,8 +163,8 @@@ few exceptions.  Even though..
  `ident`
  ^^^^^^^
  
- When the attribute `ident` is set to a path, git replaces
- `$Id$` in the blob object with `$Id:`, followed by
+ When the attribute `ident` is set for a path, git replaces
+ `$Id$` in the blob object with `$Id:`, followed by the
  40-character hexadecimal blob object name, followed by a dollar
  sign `$` upon checkout.  Any byte sequence that begins with
  `$Id:` and ends with `$` in the worktree file is replaced
@@@ -311,18 -311,10 +311,18 @@@ patterns are available
  
  - `bibtex` suitable for files with BibTeX coded references.
  
 +- `html` suitable for HTML/XHTML documents.
 +
  - `java` suitable for source code in the Java language.
  
 +- `objc` suitable for source code in the Objective-C language.
 +
  - `pascal` suitable for source code in the Pascal/Delphi language.
  
 +- `php` suitable for source code in the PHP language.
 +
 +- `python` suitable for source code in the Python language.
 +
  - `ruby` suitable for source code in the Ruby language.
  
  - `tex` suitable for source code for LaTeX documents.
diff --combined builtin-revert.c
index 472554019afdb5e8e21f2d362f62f40eb569d8aa,c41788685bf0b5bea3a3ae26615795e07a995793..7483a7a63bf09a7a123e442e9b933b9d24f2b1a6
@@@ -11,8 -11,6 +11,8 @@@
  #include "cache-tree.h"
  #include "diff.h"
  #include "revision.h"
 +#include "rerere.h"
 +#include "merge-recursive.h"
  
  /*
   * This implements the builtins revert and cherry-pick.
@@@ -202,6 -200,36 +202,6 @@@ static void set_author_ident_env(const 
                        sha1_to_hex(commit->object.sha1));
  }
  
 -static int merge_recursive(const char *base_sha1,
 -              const char *head_sha1, const char *head_name,
 -              const char *next_sha1, const char *next_name)
 -{
 -      char buffer[256];
 -      const char *argv[6];
 -      int i = 0;
 -
 -      sprintf(buffer, "GITHEAD_%s", head_sha1);
 -      setenv(buffer, head_name, 1);
 -      sprintf(buffer, "GITHEAD_%s", next_sha1);
 -      setenv(buffer, next_name, 1);
 -
 -      /*
 -       * This three way merge is an interesting one.  We are at
 -       * $head, and would want to apply the change between $commit
 -       * and $prev on top of us (when reverting), or the change between
 -       * $prev and $commit on top of us (when cherry-picking or replaying).
 -       */
 -      argv[i++] = "merge-recursive";
 -      if (base_sha1)
 -              argv[i++] = base_sha1;
 -      argv[i++] = "--";
 -      argv[i++] = head_sha1;
 -      argv[i++] = next_sha1;
 -      argv[i++] = NULL;
 -
 -      return run_command_v_opt(argv, RUN_COMMAND_NO_STDIN | RUN_GIT_CMD);
 -}
 -
  static char *help_msg(const unsigned char *sha1)
  {
        static char helpbuf[1024];
@@@ -234,27 -262,14 +234,27 @@@ static int index_is_dirty(void
        return !!DIFF_OPT_TST(&rev.diffopt, HAS_CHANGES);
  }
  
 +static struct tree *empty_tree(void)
 +{
 +      struct tree *tree = xcalloc(1, sizeof(struct tree));
 +
 +      tree->object.parsed = 1;
 +      tree->object.type = OBJ_TREE;
 +      pretend_sha1_file(NULL, 0, OBJ_TREE, tree->object.sha1);
 +      return tree;
 +}
 +
  static int revert_or_cherry_pick(int argc, const char **argv)
  {
        unsigned char head[20];
        struct commit *base, *next, *parent;
 -      int i;
 +      int i, index_fd, clean;
        char *oneline, *reencoded_message = NULL;
        const char *message, *encoding;
-       const char *defmsg = xstrdup(git_path("MERGE_MSG"));
+       char *defmsg = xstrdup(git_path("MERGE_MSG"));
 +      struct merge_options o;
 +      struct tree *result, *next_tree, *base_tree, *head_tree;
 +      static struct lock_file index_lock;
  
        git_config(git_default_config, NULL);
        me = action == REVERT ? "revert" : "cherry-pick";
        if (action == REVERT && !no_replay)
                die("revert is incompatible with replay");
  
 +      if (read_cache() < 0)
 +              die("git %s: failed to read the index", me);
        if (no_commit) {
                /*
                 * We do not intend to commit immediately.  We just want to
        } else {
                if (get_sha1("HEAD", head))
                        die ("You do not have a valid HEAD");
 -              if (read_cache() < 0)
 -                      die("could not read the index");
                if (index_is_dirty())
                        die ("Dirty index: cannot %s", me);
 -              discard_cache();
        }
 +      discard_cache();
 +
 +      index_fd = hold_locked_index(&index_lock, 1);
  
        if (!commit->parents) {
                if (action == REVERT)
                die ("Cannot get commit message for %s",
                                sha1_to_hex(commit->object.sha1));
  
 +      if (parent && parse_commit(parent) < 0)
 +              die("%s: cannot parse parent commit %s",
 +                  me, sha1_to_hex(parent->object.sha1));
 +
        /*
         * "commit" is an existing commit.  We would want to apply
         * the difference it introduces since its first parent "prev"
         * reverse of it if we are revert.
         */
  
 -      msg_fd = hold_lock_file_for_update(&msg_file, defmsg, 1);
 +      msg_fd = hold_lock_file_for_update(&msg_file, defmsg,
 +                                         LOCK_DIE_ON_ERROR);
  
        encoding = get_encoding(message);
        if (!encoding)
                }
        }
  
 -      if (merge_recursive(base == NULL ?
 -                              NULL : sha1_to_hex(base->object.sha1),
 -                              sha1_to_hex(head), "HEAD",
 -                              sha1_to_hex(next->object.sha1), oneline) ||
 -                      write_cache_as_tree(head, 0, NULL)) {
 +      read_cache();
 +      init_merge_options(&o);
 +      o.branch1 = "HEAD";
 +      o.branch2 = oneline;
 +
 +      head_tree = parse_tree_indirect(head);
 +      next_tree = next ? next->tree : empty_tree();
 +      base_tree = base ? base->tree : empty_tree();
 +
 +      clean = merge_trees(&o,
 +                          head_tree,
 +                          next_tree, base_tree, &result);
 +
 +      if (active_cache_changed &&
 +          (write_cache(index_fd, active_cache, active_nr) ||
 +           commit_locked_index(&index_lock)))
 +              die("%s: Unable to write new index file", me);
 +
 +      if (!clean) {
                add_to_msg("\nConflicts:\n\n");
 -              read_cache();
                for (i = 0; i < active_nr;) {
                        struct cache_entry *ce = active_cache[i++];
                        if (ce_stage(ce)) {
                        die ("Error wrapping up %s", defmsg);
                fprintf(stderr, "Automatic %s failed.%s\n",
                        me, help_msg(commit->object.sha1));
 +              rerere();
                exit(1);
        }
        if (commit_lock_file(&msg_file) < 0)
                return execv_git_cmd(args);
        }
        free(reencoded_message);
+       free(defmsg);
  
        return 0;
  }
index eebe73409bebb8e8c2bb448f1612117cabf8d2ad,39a1ce5a3979e6160b8450a0d9dd08ec6b6cd7a2..de193ba7c1caf69367410d763f3541555a64746f
@@@ -154,8 -154,11 +154,8 @@@ __git_heads (
  {
        local cmd i is_hash=y dir="$(__gitdir "$1")"
        if [ -d "$dir" ]; then
 -              for i in $(git --git-dir="$dir" \
 -                      for-each-ref --format='%(refname)' \
 -                      refs/heads ); do
 -                      echo "${i#refs/heads/}"
 -              done
 +              git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
 +                      refs/heads
                return
        fi
        for i in $(git ls-remote "$1" 2>/dev/null); do
@@@ -172,8 -175,11 +172,8 @@@ __git_tags (
  {
        local cmd i is_hash=y dir="$(__gitdir "$1")"
        if [ -d "$dir" ]; then
 -              for i in $(git --git-dir="$dir" \
 -                      for-each-ref --format='%(refname)' \
 -                      refs/tags ); do
 -                      echo "${i#refs/tags/}"
 -              done
 +              git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
 +                      refs/tags
                return
        fi
        for i in $(git ls-remote "$1" 2>/dev/null); do
@@@ -191,8 -197,16 +191,8 @@@ __git_refs (
        local cmd i is_hash=y dir="$(__gitdir "$1")"
        if [ -d "$dir" ]; then
                if [ -e "$dir/HEAD" ]; then echo HEAD; fi
 -              for i in $(git --git-dir="$dir" \
 -                      for-each-ref --format='%(refname)' \
 -                      refs/tags refs/heads refs/remotes); do
 -                      case "$i" in
 -                              refs/tags/*)    echo "${i#refs/tags/}" ;;
 -                              refs/heads/*)   echo "${i#refs/heads/}" ;;
 -                              refs/remotes/*) echo "${i#refs/remotes/}" ;;
 -                              *)              echo "$i" ;;
 -                      esac
 -              done
 +              git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
 +                      refs/tags refs/heads refs/remotes
                return
        fi
        for i in $(git ls-remote "$dir" 2>/dev/null); do
@@@ -881,7 -895,6 +881,7 @@@ _git_help (
                attributes cli core-tutorial cvs-migration
                diffcore gitk glossary hooks ignore modules
                repository-layout tutorial tutorial-2
 +              workflows
                "
  }
  
@@@ -1124,8 -1137,7 +1124,8 @@@ _git_send_email (
                        --no-suppress-from --no-thread --quiet
                        --signed-off-by-cc --smtp-pass --smtp-server
                        --smtp-server-port --smtp-ssl --smtp-user --subject
 -                      --suppress-cc --suppress-from --thread --to"
 +                      --suppress-cc --suppress-from --thread --to
 +                      --validate --no-validate"
                return
                ;;
        esac
@@@ -1398,6 -1410,8 +1398,8 @@@ _git_shortlog (
  
  _git_show ()
  {
+       __git_has_doubledash && return
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --pretty=*)
@@@ -1463,7 -1477,7 +1465,7 @@@ _git_submodule (
  {
        __git_has_doubledash && return
  
 -      local subcommands="add status init update"
 +      local subcommands="add status init update summary foreach sync"
        if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
                local cur="${COMP_WORDS[COMP_CWORD]}"
                case "$cur" in
diff --combined git-svn.perl
index f90ddac908f213fe8d7d58eea1aba45a04ce781e,56238dad088d6da98f7285f74645814e6bb0fe9b..5702b100f17d32c4d370d2b29374390ad0f03520
@@@ -66,7 -66,7 +66,7 @@@ my ($_stdin, $_help, $_edit
        $_version, $_fetch_all, $_no_rebase,
        $_merge, $_strategy, $_dry_run, $_local,
        $_prefix, $_no_checkout, $_url, $_verbose,
 -      $_git_format, $_commit_url);
 +      $_git_format, $_commit_url, $_tag);
  $Git::SVN::_follow_parent = 1;
  my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
                      'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@@ -131,15 -131,6 +131,15 @@@ my %cmd = 
                          'revision|r=i' => \$_revision,
                          'no-rebase' => \$_no_rebase,
                        %cmt_opts, %fc_opts } ],
 +      branch => [ \&cmd_branch,
 +                  'Create a branch in the SVN repository',
 +                  { 'message|m=s' => \$_message,
 +                    'dry-run|n' => \$_dry_run,
 +                    'tag|t' => \$_tag } ],
 +      tag => [ sub { $_tag = 1; cmd_branch(@_) },
 +               'Create a tag in the SVN repository',
 +               { 'message|m=s' => \$_message,
 +                 'dry-run|n' => \$_dry_run } ],
        'set-tree' => [ \&cmd_set_tree,
                        "Set an SVN repository to a git tree-ish",
                        { 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ],
@@@ -430,15 -421,15 +430,15 @@@ sub cmd_dcommit 
        $head ||= 'HEAD';
        my @refs;
        my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
 +      unless ($gs) {
 +              die "Unable to determine upstream SVN information from ",
 +                  "$head history.\nPerhaps the repository is empty.";
 +      }
        $url = defined $_commit_url ? $_commit_url : $gs->full_url;
        my $last_rev = $_revision if defined $_revision;
        if ($url) {
                print "Committing to $url ...\n";
        }
 -      unless ($gs) {
 -              die "Unable to determine upstream SVN information from ",
 -                  "$head history.\nPerhaps the repository is empty.";
 -      }
        my ($linear_refs, $parents) = linearize_history($gs, \@refs);
        if ($_no_rebase && scalar(@$linear_refs) > 1) {
                warn "Attempting to commit more than one change while ",
        unlink $gs->{index};
  }
  
 +sub cmd_branch {
 +      my ($branch_name, $head) = @_;
 +
 +      unless (defined $branch_name && length $branch_name) {
 +              die(($_tag ? "tag" : "branch") . " name required\n");
 +      }
 +      $head ||= 'HEAD';
 +
 +      my ($src, $rev, undef, $gs) = working_head_info($head);
 +
 +      my $remote = Git::SVN::read_all_remotes()->{svn};
 +      my $glob = $remote->{ $_tag ? 'tags' : 'branches' };
 +      my ($lft, $rgt) = @{ $glob->{path} }{qw/left right/};
 +      my $dst = join '/', $remote->{url}, $lft, $branch_name, ($rgt || ());
 +
 +      my $ctx = SVN::Client->new(
 +              auth    => Git::SVN::Ra::_auth_providers(),
 +              log_msg => sub {
 +                      ${ $_[0] } = defined $_message
 +                              ? $_message
 +                              : 'Create ' . ($_tag ? 'tag ' : 'branch ' )
 +                              . $branch_name;
 +              },
 +      );
 +
 +      eval {
 +              $ctx->ls($dst, 'HEAD', 0);
 +      } and die "branch ${branch_name} already exists\n";
 +
 +      print "Copying ${src} at r${rev} to ${dst}...\n";
 +      $ctx->copy($src, $rev, $dst)
 +              unless $_dry_run;
 +
 +      $gs->fetch_all;
 +}
 +
  sub cmd_find_rev {
        my $revision_or_hash = shift or die "SVN or git revision required ",
                                            "as a command-line argument\n";
@@@ -848,28 -803,8 +848,28 @@@ sub cmd_commit_diff 
        }
  }
  
 +sub escape_uri_only {
 +      my ($uri) = @_;
 +      my @tmp;
 +      foreach (split m{/}, $uri) {
 +              s/([^\w.%+-]|%(?![a-fA-F0-9]{2}))/sprintf("%%%02X",ord($1))/eg;
 +              push @tmp, $_;
 +      }
 +      join('/', @tmp);
 +}
 +
 +sub escape_url {
 +      my ($url) = @_;
 +      if ($url =~ m#^([^:]+)://([^/]*)(.*)$#) {
 +              my ($scheme, $domain, $uri) = ($1, $2, escape_uri_only($3));
 +              $url = "$scheme://$domain$uri";
 +      }
 +      $url;
 +}
 +
  sub cmd_info {
        my $path = canonicalize_path(defined($_[0]) ? $_[0] : ".");
 +      my $fullpath = canonicalize_path($cmd_dir_prefix . $path);
        if (exists $_[1]) {
                die "Too many arguments specified\n";
        }
        my ($file_type, $diff_status) = find_file_type_and_diff_status($path);
  
        if (!$file_type && !$diff_status) {
 -              print STDERR "$path:  (Not a versioned resource)\n\n";
 -              return;
 +              print STDERR "svn: '$path' is not under version control\n";
 +              exit 1;
        }
  
        my ($url, $rev, $uuid, $gs) = working_head_info('HEAD');
        # canonicalize_path() will return "" to make libsvn 1.5.x happy,
        $path = "." if $path eq "";
  
 -      my $full_url = $url . ($path eq "." ? "" : "/$path");
 +      my $full_url = $url . ($fullpath eq "" ? "" : "/$fullpath");
  
        if ($_url) {
 -              print $full_url, "\n";
 +              print escape_url($full_url), "\n";
                return;
        }
  
        my $result = "Path: $path\n";
        $result .= "Name: " . basename($path) . "\n" if $file_type ne "dir";
 -      $result .= "URL: " . $full_url . "\n";
 +      $result .= "URL: " . escape_url($full_url) . "\n";
  
        eval {
                my $repos_root = $gs->repos_root;
                Git::SVN::remove_username($repos_root);
 -              $result .= "Repository Root: $repos_root\n";
 +              $result .= "Repository Root: " . escape_url($repos_root) . "\n";
        };
        if ($@) {
                $result .= "Repository Root: (offline)\n";
        }
  
        my ($lc_author, $lc_rev, $lc_date_utc);
 -      my @args = Git::SVN::Log::git_svn_log_cmd($rev, $rev, "--", $path);
 +      my @args = Git::SVN::Log::git_svn_log_cmd($rev, $rev, "--", $fullpath);
        my $log = command_output_pipe(@args);
        my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/;
        while (<$log>) {
@@@ -2267,7 -2202,7 +2267,7 @@@ sub do_git_commit 
        }
        die "Tree is not a valid sha1: $tree\n" if $tree !~ /^$::sha1$/o;
  
-       my @exec = ('git-commit-tree', $tree);
+       my @exec = ('git', 'commit-tree', $tree);
        foreach ($self->get_commit_parents($log_entry)) {
                push @exec, '-p', $_;
        }
@@@ -2671,9 -2606,9 +2671,9 @@@ sub rebuild_from_rev_db 
  sub rebuild {
        my ($self) = @_;
        my $map_path = $self->map_path;
 -      return if (-e $map_path && ! -z $map_path);
 +      my $partial = (-e $map_path && ! -z $map_path);
        return unless ::verify_ref($self->refname.'^0');
 -      if ($self->use_svm_props || $self->no_metadata) {
 +      if (!$partial && ($self->use_svm_props || $self->no_metadata)) {
                my $rev_db = $self->rev_db_path;
                $self->rebuild_from_rev_db($rev_db);
                if ($self->use_svm_props) {
                $self->unlink_rev_db_symlink;
                return;
        }
 -      print "Rebuilding $map_path ...\n";
 +      print "Rebuilding $map_path ...\n" if (!$partial);
 +      my ($base_rev, $head) = ($partial ? $self->rev_map_max_norebuild(1) :
 +              (undef, undef));
        my ($log, $ctx) =
            command_output_pipe(qw/rev-list --pretty=raw --no-color --reverse/,
 -                              $self->refname, '--');
 +                              ($head ? "$head.." : "") . $self->refname,
 +                              '--');
        my $metadata_url = $self->metadata_url;
        remove_username($metadata_url);
        my $svn_uuid = $self->ra_uuid;
                    ($metadata_url && $url && ($url ne $metadata_url))) {
                        next;
                }
 +              if ($partial && $head) {
 +                      print "Partial-rebuilding $map_path ...\n";
 +                      print "Currently at $base_rev = $head\n";
 +                      $head = undef;
 +              }
  
                $self->rev_map_set($rev, $c);
                print "r$rev = $c\n";
        }
        command_close_pipe($log, $ctx);
 -      print "Done rebuilding $map_path\n";
 +      print "Done rebuilding $map_path\n" if (!$partial || !$head);
        my $rev_db_path = $self->rev_db_path;
        if (-f $self->rev_db_path) {
                unlink $self->rev_db_path or croak "unlink: $!";
@@@ -2862,12 -2789,6 +2862,12 @@@ sub rev_map_set 
  sub rev_map_max {
        my ($self, $want_commit) = @_;
        $self->rebuild;
 +      my ($r, $c) = $self->rev_map_max_norebuild($want_commit);
 +      $want_commit ? ($r, $c) : $r;
 +}
 +
 +sub rev_map_max_norebuild {
 +      my ($self, $want_commit) = @_;
        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: $!";
@@@ -3459,12 -3380,11 +3459,12 @@@ sub generate_diff 
        while (<$diff_fh>) {
                chomp $_; # this gets rid of the trailing "\0"
                if ($state eq 'meta' && /^:(\d{6})\s(\d{6})\s
 -                                      $::sha1\s($::sha1)\s
 +                                      ($::sha1)\s($::sha1)\s
                                        ([MTCRAD])\d*$/xo) {
                        push @mods, {   mode_a => $1, mode_b => $2,
 -                                      sha1_b => $3, chg => $4 };
 -                      if ($4 =~ /^(?:C|R)$/) {
 +                                      sha1_a => $3, sha1_b => $4,
 +                                      chg => $5 };
 +                      if ($5 =~ /^(?:C|R)$/) {
                                $state = 'file_a';
                        } else {
                                $state = 'file_b';
@@@ -3716,7 -3636,6 +3716,7 @@@ sub R 
        my $fbat = $self->add_file($self->repo_path($m->{file_b}), $pbat,
                                $self->url_path($m->{file_a}), $self->{r});
        print "\tR\t$m->{file_a} => $m->{file_b}\n" unless $::_q;
 +      $self->apply_autoprops($file, $fbat);
        $self->chg_file($fbat, $m);
        $self->close_file($fbat,undef,$self->{pool});
  
@@@ -3743,52 -3662,33 +3743,52 @@@ sub change_file_prop 
        $self->SUPER::change_file_prop($fbat, $pname, $pval, $self->{pool});
  }
  
 -sub chg_file {
 -      my ($self, $fbat, $m) = @_;
 -      if ($m->{mode_b} =~ /755$/ && $m->{mode_a} !~ /755$/) {
 -              $self->change_file_prop($fbat,'svn:executable','*');
 -      } elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) {
 -              $self->change_file_prop($fbat,'svn:executable',undef);
 -      }
 -      my $fh = Git::temp_acquire('git_blob');
 -      if ($m->{mode_b} =~ /^120/) {
 +sub _chg_file_get_blob ($$$$) {
 +      my ($self, $fbat, $m, $which) = @_;
 +      my $fh = Git::temp_acquire("git_blob_$which");
 +      if ($m->{"mode_$which"} =~ /^120/) {
                print $fh 'link ' or croak $!;
                $self->change_file_prop($fbat,'svn:special','*');
 -      } elsif ($m->{mode_a} =~ /^120/ && $m->{mode_b} !~ /^120/) {
 +      } elsif ($m->{mode_a} =~ /^120/ && $m->{"mode_$which"} !~ /^120/) {
                $self->change_file_prop($fbat,'svn:special',undef);
        }
 -      my $size = $::_repository->cat_blob($m->{sha1_b}, $fh);
 -      croak "Failed to read object $m->{sha1_b}" if ($size < 0);
 +      my $blob = $m->{"sha1_$which"};
 +      return ($fh,) if ($blob =~ /^0{40}$/);
 +      my $size = $::_repository->cat_blob($blob, $fh);
 +      croak "Failed to read object $blob" if ($size < 0);
        $fh->flush == 0 or croak $!;
        seek $fh, 0, 0 or croak $!;
  
        my $exp = ::md5sum($fh);
        seek $fh, 0, 0 or croak $!;
 +      return ($fh, $exp);
 +}
  
 +sub chg_file {
 +      my ($self, $fbat, $m) = @_;
 +      if ($m->{mode_b} =~ /755$/ && $m->{mode_a} !~ /755$/) {
 +              $self->change_file_prop($fbat,'svn:executable','*');
 +      } elsif ($m->{mode_b} !~ /755$/ && $m->{mode_a} =~ /755$/) {
 +              $self->change_file_prop($fbat,'svn:executable',undef);
 +      }
 +      my ($fh_a, $exp_a) = _chg_file_get_blob $self, $fbat, $m, 'a';
 +      my ($fh_b, $exp_b) = _chg_file_get_blob $self, $fbat, $m, 'b';
        my $pool = SVN::Pool->new;
 -      my $atd = $self->apply_textdelta($fbat, undef, $pool);
 -      my $got = SVN::TxDelta::send_stream($fh, @$atd, $pool);
 -      die "Checksum mismatch\nexpected: $exp\ngot: $got\n" if ($got ne $exp);
 -      Git::temp_release($fh, 1);
 +      my $atd = $self->apply_textdelta($fbat, $exp_a, $pool);
 +      if (-s $fh_a) {
 +              my $txstream = SVN::TxDelta::new ($fh_a, $fh_b, $pool);
 +              my $res = SVN::TxDelta::send_txstream($txstream, @$atd, $pool);
 +              if (defined $res) {
 +                      die "Unexpected result from send_txstream: $res\n",
 +                          "(SVN::Core::VERSION: $SVN::Core::VERSION)\n";
 +              }
 +      } else {
 +              my $got = SVN::TxDelta::send_stream($fh_b, @$atd, $pool);
 +              die "Checksum mismatch\nexpected: $exp_b\ngot: $got\n"
 +                  if ($got ne $exp_b);
 +      }
 +      Git::temp_release($fh_b, 1);
 +      Git::temp_release($fh_a, 1);
        $pool->clear;
  }