Skip to content

Commit 992793c

Browse files
author
Martin Langhoff
committed
git-cvsexportcommit: Add -f(orce) and -m(essage prefix) flags, small cleanups.
1 parent 36932ea commit 992793c

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

Documentation/git-cvsexportcommit.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-cvsexportcommit - Export a commit to a CVS checkout
88

99
SYNOPSIS
1010
--------
11-
'git-cvsexportcommmit' [-h] [-v] [-c] [-p] [PARENTCOMMIT] COMMITID
11+
'git-cvsexportcommmit' [-h] [-v] [-c] [-p] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
1212

1313

1414
DESCRIPTION
@@ -39,6 +39,13 @@ OPTIONS
3939
Be pedantic (paranoid) when applying patches. Invokes patch with
4040
--fuzz=0
4141

42+
-f::
43+
Force the merge even if the files are not up to date.
44+
45+
-m::
46+
Prepend the commit message with the provided prefix.
47+
Useful for patch series and the like.
48+
4249
-v::
4350
Verbose.
4451

git-cvsexportcommit.perl

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
die "GIT_DIR is not defined or is unreadable";
1111
}
1212

13-
our ($opt_h, $opt_p, $opt_v, $opt_c );
13+
our ($opt_h, $opt_p, $opt_v, $opt_c, $opt_f, $opt_m );
1414

15-
getopts('hpvc');
15+
getopts('hpvcfm:');
1616

1717
$opt_h && usage();
1818

@@ -77,12 +77,16 @@
7777
$opt_v && print "Applying to CVS commit $commit from parent $parent\n";
7878

7979
# grab the commit message
80-
`git-cat-file commit $commit | sed -e '1,/^\$/d' > .msg`;
80+
open(MSG, ">.msg") or die "Cannot open .msg for writing";
81+
print MSG $opt_m;
82+
close MSG;
83+
84+
`git-cat-file commit $commit | sed -e '1,/^\$/d' >> .msg`;
8185
$? && die "Error extracting the commit message";
8286

8387
my (@afiles, @dfiles, @mfiles);
8488
my @files = safe_pipe_capture('git-diff-tree', '-r', $parent, $commit);
85-
print @files;
89+
#print @files;
8690
$? && die "Error in git-diff-tree";
8791
foreach my $f (@files) {
8892
chomp $f;
@@ -109,7 +113,7 @@
109113
if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
110114
unless ($status[0] =~ m/Status: Unknown$/) {
111115
$dirty = 1;
112-
warn "File $f is already known in your CVS checkout!\n";
116+
warn "File $f is already known in your CVS checkout -- perhaps it has been added by another user. Or this may indicate that it exists on a different branch. If this is the case, use -f to force the merge.\n";
113117
}
114118
}
115119
foreach my $f (@mfiles, @dfiles) {
@@ -122,7 +126,11 @@
122126
}
123127
}
124128
if ($dirty) {
125-
die "Exiting: your CVS tree is not clean for this merge.";
129+
if ($opt_f) { warn "The tree is not clean -- forced merge\n";
130+
$dirty = 0;
131+
} else {
132+
die "Exiting: your CVS tree is not clean for this merge.";
133+
}
126134
}
127135

128136
###
@@ -215,7 +223,7 @@
215223
}
216224
sub usage {
217225
print STDERR <<END;
218-
Usage: GIT_DIR=/path/to/.git ${\basename $0} [-h] [-p] [-v] [-c] [ parent ] commit
226+
Usage: GIT_DIR=/path/to/.git ${\basename $0} [-h] [-p] [-v] [-c] [-f] [-m msgprefix] [ parent ] commit
219227
END
220228
exit(1);
221229
}

0 commit comments

Comments
 (0)