summaryrefslogtreecommitdiff
path: root/gnu/dist/cvs/src/commit.c
diff options
context:
space:
mode:
authorwiz <wiz@NetBSD.org>2000-10-26 14:59:06 +0000
committerwiz <wiz@NetBSD.org>2000-10-26 14:59:06 +0000
commit2b12e010265cefa3617d277b4e06d05f2f23be5d (patch)
tree81ad07e98967225bfc8510156a86379017a4d518 /gnu/dist/cvs/src/commit.c
parent528e3141438189ff8c6b92c2f415f47edfeaed0e (diff)
resolve conflicts from cvs-1.11 import
Diffstat (limited to 'gnu/dist/cvs/src/commit.c')
-rw-r--r--gnu/dist/cvs/src/commit.c163
1 files changed, 85 insertions, 78 deletions
diff --git a/gnu/dist/cvs/src/commit.c b/gnu/dist/cvs/src/commit.c
index 862171b49d8..7073299e26a 100644
--- a/gnu/dist/cvs/src/commit.c
+++ b/gnu/dist/cvs/src/commit.c
@@ -263,6 +263,7 @@ find_fileproc (callerdat, finfo)
else
error (0, 0, "use `%s add' to create an entry for %s",
program_name, finfo->fullname);
+ freevers_ts (&vers);
return 1;
}
else if (vers->ts_user != NULL
@@ -284,6 +285,7 @@ find_fileproc (callerdat, finfo)
cases. FIXME: we probably should be printing a message and
returning 1 for many of those cases (but I'm not sure
exactly which ones). */
+ freevers_ts (&vers);
return 0;
}
@@ -421,28 +423,12 @@ commit (argc, argv)
/* some checks related to the "-F logfile" option */
if (logfile)
{
- int n, logfd;
- struct stat statbuf;
+ size_t size = 0, len;
if (saved_message)
error (1, 0, "cannot specify both a message and a log file");
- /* FIXME: Why is this binary? Needs more investigation. */
- if ((logfd = CVS_OPEN (logfile, O_RDONLY | OPEN_BINARY)) < 0)
- error (1, errno, "cannot open log file %s", logfile);
-
- if (fstat(logfd, &statbuf) < 0)
- error (1, errno, "cannot find size of log file %s", logfile);
-
- saved_message = xmalloc (statbuf.st_size + 1);
-
- /* FIXME: Should keep reading until EOF, rather than assuming the
- first read gets the whole thing. */
- if ((n = read (logfd, saved_message, statbuf.st_size + 1)) < 0)
- error (1, errno, "cannot read log message from %s", logfile);
-
- (void) close (logfd);
- saved_message[n] = '\0';
+ get_file (logfile, logfile, "r", &saved_message, &size, &len);
}
#ifdef CLIENT_SUPPORT
@@ -473,11 +459,14 @@ commit (argc, argv)
error (1, 0, "correct above errors first!");
if (find_args.argc == 0)
+ {
/* Nothing to commit. Exit now without contacting the
server (note that this means that we won't print "?
foo" for files which merit it, because we don't know
what is in the CVSROOT/cvsignore file). */
+ dellist (&find_args.ulist);
return 0;
+ }
/* Now we keep track of which files we actually are going to
operate on, and only work with those files in the future.
@@ -583,6 +572,8 @@ commit (argc, argv)
previous versions of client/server CVS, but it probably is a Good
Thing, or at least Not Such A Bad Thing. */
send_file_names (find_args.argc, find_args.argv, 0);
+ free (find_args.argv);
+ dellist (&find_args.ulist);
send_to_server ("ci\012", 0);
err = get_responses_and_close ();
@@ -1293,6 +1284,8 @@ commit_fileproc (callerdat, finfo)
{
if (finfo->rcs == NULL)
error (1, 0, "internal error: no parsed RCS file");
+ if (ci->rev)
+ free (ci->rev);
ci->rev = RCS_whatbranch (finfo->rcs, ci->tag);
err = Checkin ('A', finfo, finfo->rcs->path, ci->rev,
ci->tag, ci->options, saved_message);
@@ -1403,6 +1396,8 @@ out:
}
}
}
+ if (SIG_inCrSect ())
+ SIG_endCrSect ();
return (err);
}
@@ -1503,6 +1498,7 @@ commit_filesdoneproc (callerdat, err, repository, update_dir, entries)
cvs_output (": Executing '", 0);
run_print (stdout);
cvs_output ("'\n", 0);
+ cvs_flushout ();
(void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
free (repos);
}
@@ -1585,8 +1581,10 @@ commit_dirleaveproc (callerdat, dir, err, update_dir, entries)
this being a confusing feature! */
if (err == 0 && write_dirtag != NULL)
{
+ char *repos = Name_Repository (dir, update_dir);
WriteTag (NULL, write_dirtag, NULL, write_dirnonbranch,
- update_dir, Name_Repository (dir, update_dir));
+ update_dir, repos);
+ free (repos);
}
return (err);
@@ -1754,8 +1752,8 @@ remove_file (finfo, tag, message)
"failed to commit dead revision for `%s'", finfo->fullname);
return (1);
}
-/* At this point, the file has been committed as removed. We should
- probably tell the history file about it */
+ /* At this point, the file has been committed as removed. We should
+ probably tell the history file about it */
history_write ('R', NULL, finfo->rcs->head, finfo->file, finfo->repository);
if (rev != NULL)
@@ -1968,6 +1966,11 @@ checkaddfile (file, repository, tag, options, rcsnode)
sprintf (rcs, "%s/%s%s", repository, file, RCSEXT);
+ /* Begin a critical section around the code that spans the
+ first commit on the trunk of a file that's already been
+ committed on a branch. */
+ SIG_beginCrSect ();
+
if (RCS_setattic (rcsfile, 0))
{
retval = 1;
@@ -2050,74 +2053,76 @@ checkaddfile (file, repository, tag, options, rcsnode)
newfile = 1;
if (desc != NULL)
free (desc);
+ if (rcsnode != NULL)
+ {
+ assert (*rcsnode == NULL);
+ *rcsnode = rcsfile;
+ }
}
/* when adding a file for the first time, and using a tag, we need
to create a dead revision on the trunk. */
- if (adding_on_branch && newfile)
+ if (adding_on_branch)
{
- char *tmp;
- FILE *fp;
-
- /* move the new file out of the way. */
- fname = xmalloc (strlen (file) + sizeof (CVSADM)
- + sizeof (CVSPREFIX) + 10);
- (void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, file);
- rename_file (file, fname);
-
- /* Create empty FILE. Can't use copy_file with a DEVNULL
- argument -- copy_file now ignores device files. */
- fp = fopen (file, "w");
- if (fp == NULL)
- error (1, errno, "cannot open %s for writing", file);
- if (fclose (fp) < 0)
- error (0, errno, "cannot close %s", file);
-
- tmp = xmalloc (strlen (file) + strlen (tag) + 80);
- /* commit a dead revision. */
- (void) sprintf (tmp, "file %s was initially added on branch %s.",
- file, tag);
- retcode = RCS_checkin (rcsfile, NULL, tmp, NULL,
- RCS_FLAGS_DEAD | RCS_FLAGS_QUIET);
- free (tmp);
- if (retcode != 0)
+ if (newfile)
{
- error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
- "could not create initial dead revision %s", rcs);
- retval = 1;
- goto out;
- }
+ char *tmp;
+ FILE *fp;
- /* put the new file back where it was */
- rename_file (fname, file);
- free (fname);
+ /* move the new file out of the way. */
+ fname = xmalloc (strlen (file) + sizeof (CVSADM)
+ + sizeof (CVSPREFIX) + 10);
+ (void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, file);
+ rename_file (file, fname);
- /* double-check that the file was written correctly */
- freercsnode (&rcsfile);
- rcsfile = RCS_parse (file, repository);
- if (rcsfile == NULL)
- {
- error (0, 0, "could not read %s", rcs);
- retval = 1;
- goto out;
- }
- if (rcsnode != NULL)
- {
- assert (*rcsnode == NULL);
- *rcsnode = rcsfile;
- }
+ /* Create empty FILE. Can't use copy_file with a DEVNULL
+ argument -- copy_file now ignores device files. */
+ fp = fopen (file, "w");
+ if (fp == NULL)
+ error (1, errno, "cannot open %s for writing", file);
+ if (fclose (fp) < 0)
+ error (0, errno, "cannot close %s", file);
+
+ tmp = xmalloc (strlen (file) + strlen (tag) + 80);
+ /* commit a dead revision. */
+ (void) sprintf (tmp, "file %s was initially added on branch %s.",
+ file, tag);
+ retcode = RCS_checkin (rcsfile, NULL, tmp, NULL,
+ RCS_FLAGS_DEAD | RCS_FLAGS_QUIET);
+ free (tmp);
+ if (retcode != 0)
+ {
+ error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
+ "could not create initial dead revision %s", rcs);
+ retval = 1;
+ goto out;
+ }
- /* and lock it once again. */
- if (lock_RCS (file, rcsfile, NULL, repository))
- {
- error (0, 0, "cannot lock `%s'.", rcs);
- retval = 1;
- goto out;
+ /* put the new file back where it was */
+ rename_file (fname, file);
+ free (fname);
+
+ /* double-check that the file was written correctly */
+ freercsnode (&rcsfile);
+ rcsfile = RCS_parse (file, repository);
+ if (rcsfile == NULL)
+ {
+ error (0, 0, "could not read %s", rcs);
+ retval = 1;
+ goto out;
+ }
+ if (rcsnode != NULL)
+ *rcsnode = rcsfile;
+
+ /* and lock it once again. */
+ if (lock_RCS (file, rcsfile, NULL, repository))
+ {
+ error (0, 0, "cannot lock `%s'.", rcs);
+ retval = 1;
+ goto out;
+ }
}
- }
- if (adding_on_branch)
- {
/* when adding with a tag, we need to stub a branch, if it
doesn't already exist. */
@@ -2200,6 +2205,8 @@ checkaddfile (file, repository, tag, options, rcsnode)
retval = 0;
out:
+ if (retval != 0 && SIG_inCrSect ())
+ SIG_endCrSect ();
free (rcs);
return retval;
}