|
15 | 15 | die "GIT_DIR is not defined or is unreadable"; |
16 | 16 | } |
17 | 17 |
|
18 | | -our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m ); |
| 18 | +our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d); |
19 | 19 |
|
20 | | -getopts('hPpvcfam:'); |
| 20 | +getopts('hPpvcfam:d:'); |
21 | 21 |
|
22 | 22 | $opt_h && usage(); |
23 | 23 |
|
24 | 24 | die "Need at least one commit identifier!" unless @ARGV; |
25 | 25 |
|
| 26 | +my @cvs; |
| 27 | +if ($opt_d) { |
| 28 | + @cvs = ('cvs', '-d', $opt_d); |
| 29 | +} else { |
| 30 | + @cvs = ('cvs'); |
| 31 | +} |
| 32 | + |
26 | 33 | # setup a tempdir |
27 | 34 | our ($tmpdir, $tmpdirname) = tempdir('git-cvsapplycommit-XXXXXX', |
28 | 35 | TMPDIR => 1, |
|
160 | 167 | my $p = $1; |
161 | 168 | next if (grep { $_ eq $p } @dirs); |
162 | 169 | } |
163 | | - my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f)); |
| 170 | + my @status = grep(m/^File/, safe_pipe_capture(@cvs, '-q', 'status' ,$f)); |
164 | 171 | if (@status > 1) { warn 'Strange! cvs status returned more than one line?'}; |
165 | 172 | if (-d dirname $f and $status[0] !~ m/Status: Unknown$/ |
166 | 173 | and $status[0] !~ m/^File: no file /) { |
|
173 | 180 | foreach my $f (@files) { |
174 | 181 | next if grep { $_ eq $f } @afiles; |
175 | 182 | # TODO:we need to handle removed in cvs |
176 | | - my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f)); |
| 183 | + my @status = grep(m/^File/, safe_pipe_capture(@cvs, '-q', 'status' ,$f)); |
177 | 184 | if (@status > 1) { warn 'Strange! cvs status returned more than one line?'}; |
178 | 185 | unless ($status[0] =~ m/Status: Up-to-date$/) { |
179 | 186 | $dirty = 1; |
|
194 | 201 | print "Patch applied successfully. Adding new files and directories to CVS\n"; |
195 | 202 | my $dirtypatch = 0; |
196 | 203 | foreach my $d (@dirs) { |
197 | | - if (system('cvs','add',$d)) { |
| 204 | + if (system(@cvs,'add',$d)) { |
198 | 205 | $dirtypatch = 1; |
199 | 206 | warn "Failed to cvs add directory $d -- you may need to do it manually"; |
200 | 207 | } |
201 | 208 | } |
202 | 209 |
|
203 | 210 | foreach my $f (@afiles) { |
204 | 211 | if (grep { $_ eq $f } @bfiles) { |
205 | | - system('cvs', 'add','-kb',$f); |
| 212 | + system(@cvs, 'add','-kb',$f); |
206 | 213 | } else { |
207 | | - system('cvs', 'add', $f); |
| 214 | + system(@cvs, 'add', $f); |
208 | 215 | } |
209 | 216 | if ($?) { |
210 | 217 | $dirtypatch = 1; |
|
213 | 220 | } |
214 | 221 |
|
215 | 222 | foreach my $f (@dfiles) { |
216 | | - system('cvs', 'rm', '-f', $f); |
| 223 | + system(@cvs, 'rm', '-f', $f); |
217 | 224 | if ($?) { |
218 | 225 | $dirtypatch = 1; |
219 | 226 | warn "Failed to cvs rm -f $f -- you may need to do it manually"; |
|
223 | 230 | print "Commit to CVS\n"; |
224 | 231 | print "Patch title (first comment line): $title\n"; |
225 | 232 | my @commitfiles = map { unless (m/\s/) { '\''.$_.'\''; } else { $_; }; } (@files); |
226 | | -my $cmd = "cvs commit -F .msg @commitfiles"; |
| 233 | +my $cmd = join(' ', @cvs)." commit -F .msg @commitfiles"; |
227 | 234 |
|
228 | 235 | if ($dirtypatch) { |
229 | 236 | print "NOTE: One or more hunks failed to apply cleanly.\n"; |
|
236 | 243 |
|
237 | 244 | if ($opt_c) { |
238 | 245 | print "Autocommit\n $cmd\n"; |
239 | | - print safe_pipe_capture('cvs', 'commit', '-F', '.msg', @files); |
| 246 | + print safe_pipe_capture(@cvs, 'commit', '-F', '.msg', @files); |
240 | 247 | if ($?) { |
241 | 248 | die "Exiting: The commit did not succeed"; |
242 | 249 | } |
|
0 commit comments