git-cvsexportcommit: Add -f(orce) and -m(essage prefix) flags, small cleanups.
Martin Langhoff committed
Apr 26, 2006 at 12:26 UTC
992793c832acfd98107068d90b886643f0344d04
2 files changed
+23
-8
Documentation/git-cvsexportcommit.txt
+8
-1
@@ -8,7 +8,7 @@ git-cvsexportcommit - Export a commit to a CVS checkout
8
9
SYNOPSIS
10
--------
11
-'git-cvsexportcommmit' [-h] [-v] [-c] [-p] [PARENTCOMMIT] COMMITID
11
+'git-cvsexportcommmit' [-h] [-v] [-c] [-p] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
12
13
14
DESCRIPTION
@@ -39,6 +39,13 @@ OPTIONS
39
Be pedantic (paranoid) when applying patches. Invokes patch with
40
--fuzz=0
41
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
+
49
-v::
50
Verbose.
51
git-cvsexportcommit.perl
+15
-7
@@ -10,9 +10,9 @@ unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){
10
die "GIT_DIR is not defined or is unreadable";
11
}
12
13
-our ($opt_h, $opt_p, $opt_v, $opt_c );
13
+our ($opt_h, $opt_p, $opt_v, $opt_c, $opt_f, $opt_m );
14
15
-getopts('hpvc');
15
+getopts('hpvcfm:');
16
17
$opt_h && usage();
18
@@ -77,12 +77,16 @@ if ($parent) {
77
$opt_v && print "Applying to CVS commit $commit from parent $parent\n";
78
79
# 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`;
85
$? && die "Error extracting the commit message";
86
87
my (@afiles, @dfiles, @mfiles);
88
my @files = safe_pipe_capture('git-diff-tree', '-r', $parent, $commit);
85
-print @files;
89
+#print @files;
90
$? && die "Error in git-diff-tree";
91
foreach my $f (@files) {
92
chomp $f;
@@ -109,7 +113,7 @@ foreach my $f (@afiles) {
113
if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
114
unless ($status[0] =~ m/Status: Unknown$/) {
115
$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";
117
}
118
}
119
foreach my $f (@mfiles, @dfiles) {
@@ -122,7 +126,11 @@ foreach my $f (@mfiles, @dfiles) {
126
}
127
}
128
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
+ }
134
}
135
136
###
@@ -215,7 +223,7 @@ if ($opt_c) {
223
}
224
sub usage {
225
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
227
END
228
exit(1);
229
}