+sub rcs_find_changes ($) {
+ my $oldrev=shift;
+
+ # Note that git log will sometimes show files being added that
+ # don't exist. Particularly, git merge -s ours can result in a
+ # merge commit where some files were not really added.
+ # This is why the code below verifies that the files really
+ # exist.
+ my @raw_lines = run_or_die('git', 'log',
+ '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
+ '--no-renames', , '--reverse',
+ '-r', "$oldrev..HEAD", '--', '.');
+
+ # Due to --reverse, we see changes in chronological order.
+ my %changed;
+ my %deleted;
+ my $nullsha = 0 x 40;
+ my $newrev=$oldrev;
+ while (my $ci = parse_diff_tree(\@raw_lines)) {
+ $newrev=$ci->{sha1};
+ foreach my $i (@{$ci->{details}}) {
+ my $file=$i->{file};
+ if ($i->{sha1_to} eq $nullsha) {
+ if (! -e "$config{srcdir}/$file") {
+ delete $changed{$file};
+ $deleted{$file}=1;
+ }
+ }
+ else {
+ if (-e "$config{srcdir}/$file") {
+ delete $deleted{$file};
+ $changed{$file}=1;
+ }
+ }
+ }
+ }
+
+ return (\%changed, \%deleted, $newrev);
+}