24 |
#include "edit.h" |
#include "edit.h" |
25 |
#include "fileattr.h" |
#include "fileattr.h" |
26 |
#include "hardlink.h" |
#include "hardlink.h" |
27 |
|
#include "sign.h" |
28 |
|
#include "stack.h" |
29 |
|
|
30 |
static Dtype check_direntproc (void *callerdat, const char *dir, |
static Dtype check_direntproc (void *callerdat, const char *dir, |
31 |
const char *repos, const char *update_dir, |
const char *repos, const char *update_dir, |
334 |
|
|
335 |
|
|
336 |
|
|
337 |
#ifdef SERVER_SUPPORT |
/* Commit options both the client and server accept. */ |
338 |
# define COMMIT_OPTIONS "+cnlRm:fF:r:" |
#define COMMIT_OPTIONS "+cgG:lRm:fF:r:" |
339 |
#else /* !SERVER_SUPPORT */ |
|
340 |
# define COMMIT_OPTIONS "+clRm:fF:r:" |
|
341 |
#endif /* SERVER_SUPPORT */ |
|
342 |
int |
int |
343 |
commit (int argc, char **argv) |
commit (int argc, char **argv) |
344 |
{ |
{ |
345 |
int c; |
int c; |
346 |
int err = 0; |
int err = 0; |
347 |
int local = 0; |
int local = 0; |
348 |
|
int option_index = 0; /* `getopt_long' stores the option index here, |
349 |
|
* but right now we don't use it. |
350 |
|
*/ |
351 |
|
/* If a GPG-like program couldn't be found at compile time, default the sign |
352 |
|
* state to off, otherwise, depend on the server support. |
353 |
|
*/ |
354 |
|
#ifdef GPG_PROGRAM |
355 |
|
sign_state sign = SIGN_DEFAULT; |
356 |
|
#else |
357 |
|
sign_state sign = SIGN_NEVER; |
358 |
|
#endif |
359 |
|
char *sign_template = NULL; |
360 |
|
List *sign_args; |
361 |
|
|
362 |
|
#ifdef SERVER_SUPPORT |
363 |
|
/* See below for documentation of the `-n' option. */ |
364 |
|
const char short_options[] = COMMIT_OPTIONS"n"; |
365 |
|
#else /* !SERVER_SUPPORT */ |
366 |
|
const char short_options[] = COMMIT_OPTIONS; |
367 |
|
#endif /* SERVER_SUPPORT */ |
368 |
|
struct option long_options[] = |
369 |
|
{ |
370 |
|
{"sign", 0, NULL, 'g'}, |
371 |
|
{"nosign", 0, NULL, 1}, |
372 |
|
{"sign-template", required_argument, NULL, 'G'}, |
373 |
|
{"sign-arg", required_argument, NULL, '2'}, |
374 |
|
{0, 0, 0, 0} |
375 |
|
}; |
376 |
|
|
377 |
if (argc == -1) |
if (argc == -1) |
378 |
usage (commit_usage); |
usage (commit_usage); |
399 |
} |
} |
400 |
#endif /* CVS_BADROOT */ |
#endif /* CVS_BADROOT */ |
401 |
|
|
402 |
|
sign_args = getlist (); |
403 |
optind = 0; |
optind = 0; |
404 |
while ((c = getopt (argc, argv, COMMIT_OPTIONS)) != -1) |
while ((c = getopt_long |
405 |
|
(argc, argv, short_options, long_options, &option_index)) |
406 |
|
!= EOF) |
407 |
{ |
{ |
408 |
switch (c) |
switch (c) |
409 |
{ |
{ |
410 |
case 'c': |
case 'c': |
411 |
check_valid_edit = 1; |
check_valid_edit = 1; |
412 |
break; |
break; |
413 |
|
|
414 |
|
case 'g': |
415 |
|
sign = SIGN_ALWAYS; |
416 |
|
break; |
417 |
|
|
418 |
|
case 1: |
419 |
|
sign = SIGN_NEVER; |
420 |
|
break; |
421 |
|
|
422 |
|
case 'G': |
423 |
|
if (sign_template) free (sign_template); |
424 |
|
sign_template = xstrdup (optarg); |
425 |
|
break; |
426 |
|
|
427 |
|
case 2: |
428 |
|
push_string (sign_args, optarg); |
429 |
|
break; |
430 |
|
|
431 |
#ifdef SERVER_SUPPORT |
#ifdef SERVER_SUPPORT |
432 |
case 'n': |
case 'n': |
433 |
/* Silently ignore -n for compatibility with old |
/* Silently ignore -n for compatibility with old |
651 |
program, which we used to call, wanted the file to exist, |
program, which we used to call, wanted the file to exist, |
652 |
then it would be relatively simple to fix in the server. */ |
then it would be relatively simple to fix in the server. */ |
653 |
send_files (find_args.argc, find_args.argv, local, 0, |
send_files (find_args.argc, find_args.argv, local, 0, |
654 |
find_args.force ? SEND_FORCE : 0); |
find_args.force ? SEND_FORCE : 0, |
655 |
|
sign == SIGN_DEFAULT ? current_parsed_root->sign : sign, |
656 |
|
sign_template ? sign_template |
657 |
|
: current_parsed_root->sign_template, |
658 |
|
sign_args); |
659 |
|
|
660 |
/* Sending only the names of the files which were modified, added, |
/* Sending only the names of the files which were modified, added, |
661 |
or removed means that the server will only do an up-to-date |
or removed means that the server will only do an up-to-date |