Annotation of src/usr.bin/cvs/commit.c, Revision 1.120
1.120 ! tobias 1: /* $OpenBSD: commit.c,v 1.119 2008/01/13 11:15:19 tobias Exp $ */
1.1 jfb 2: /*
1.55 joris 3: * Copyright (c) 2006 Joris Vink <joris@openbsd.org>
1.71 xsa 4: * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
1.1 jfb 5: *
1.55 joris 6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
1.1 jfb 9: *
1.55 joris 10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 jfb 17: */
18:
1.105 otto 19: #include <sys/stat.h>
20:
21: #include <errno.h>
22: #include <fcntl.h>
23: #include <string.h>
24: #include <unistd.h>
1.1 jfb 25:
26: #include "cvs.h"
1.55 joris 27: #include "diff.h"
1.80 joris 28: #include "remote.h"
1.1 jfb 29:
1.55 joris 30: void cvs_commit_local(struct cvs_file *);
1.86 joris 31: void cvs_commit_check_files(struct cvs_file *);
1.55 joris 32:
1.112 joris 33: static BUF *commit_diff(struct cvs_file *, RCSNUM *, int);
1.71 xsa 34: static void commit_desc_set(struct cvs_file *);
1.55 joris 35:
36: struct cvs_flisthead files_affected;
1.86 joris 37: struct cvs_flisthead files_added;
38: struct cvs_flisthead files_removed;
39: struct cvs_flisthead files_modified;
40:
1.55 joris 41: int conflicts_found;
1.86 joris 42: char *logmsg = NULL;
1.34 jfb 43:
44: struct cvs_cmd cvs_cmd_commit = {
1.74 joris 45: CVS_OP_COMMIT, 0, "commit",
1.55 joris 46: { "ci", "com" },
1.34 jfb 47: "Check files into the repository",
48: "[-flR] [-F logfile | -m msg] [-r rev] ...",
49: "F:flm:Rr:",
1.18 joris 50: NULL,
1.55 joris 51: cvs_commit
1.18 joris 52: };
1.1 jfb 53:
1.55 joris 54: int
55: cvs_commit(int argc, char **argv)
1.1 jfb 56: {
1.18 joris 57: int ch;
1.55 joris 58: char *arg = ".";
1.58 joris 59: int flags;
1.55 joris 60: struct cvs_recursion cr;
1.3 krapht 61:
1.58 joris 62: flags = CR_RECURSE_DIRS;
63:
1.55 joris 64: while ((ch = getopt(argc, argv, cvs_cmd_commit.cmd_opts)) != -1) {
1.1 jfb 65: switch (ch) {
66: case 'F':
1.88 joris 67: logmsg = cvs_logmsg_read(optarg);
1.1 jfb 68: break;
1.82 xsa 69: case 'f':
70: break;
1.1 jfb 71: case 'l':
1.58 joris 72: flags &= ~CR_RECURSE_DIRS;
1.1 jfb 73: break;
74: case 'm':
1.55 joris 75: logmsg = xstrdup(optarg);
76: break;
1.82 xsa 77: case 'R':
1.120 ! tobias 78: flags |= CR_RECURSE_DIRS;
1.82 xsa 79: break;
1.55 joris 80: case 'r':
1.1 jfb 81: break;
82: default:
1.55 joris 83: fatal("%s", cvs_cmd_commit.cmd_synopsis);
1.1 jfb 84: }
85: }
86:
1.55 joris 87: argc -= optind;
88: argv += optind;
1.1 jfb 89:
1.86 joris 90: TAILQ_INIT(&files_affected);
91: TAILQ_INIT(&files_added);
92: TAILQ_INIT(&files_removed);
93: TAILQ_INIT(&files_modified);
94: conflicts_found = 0;
95:
96: cr.enterdir = NULL;
97: cr.leavedir = NULL;
98: cr.fileproc = cvs_commit_check_files;
99: cr.flags = flags;
100:
101: if (argc > 0)
102: cvs_file_run(argc, argv, &cr);
103: else
104: cvs_file_run(1, &arg, &cr);
105:
106: if (conflicts_found != 0)
107: fatal("%d conflicts found, please correct these first",
108: conflicts_found);
1.92 joris 109:
110: if (TAILQ_EMPTY(&files_affected))
111: return (0);
1.86 joris 112:
113: if (logmsg == NULL && cvs_server_active == 0) {
114: logmsg = cvs_logmsg_create(&files_added, &files_removed,
115: &files_modified);
116: }
117:
1.55 joris 118: if (logmsg == NULL)
1.86 joris 119: fatal("This shouldnt happen, honestly!");
1.87 joris 120:
121: cvs_file_freelist(&files_modified);
122: cvs_file_freelist(&files_removed);
123: cvs_file_freelist(&files_added);
1.80 joris 124:
125: if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) {
1.89 joris 126: cvs_client_connect_to_server();
1.80 joris 127: cr.fileproc = cvs_client_sendfile;
128:
129: if (argc > 0)
130: cvs_file_run(argc, argv, &cr);
131: else
132: cvs_file_run(1, &arg, &cr);
1.99 xsa 133:
134: if (!(flags & CR_RECURSE_DIRS))
135: cvs_client_send_request("Argument -l");
1.80 joris 136:
1.109 joris 137: if (logmsg != NULL)
138: cvs_client_send_logmsg(logmsg);
1.80 joris 139:
140: cvs_client_send_files(argv, argc);
141: cvs_client_senddir(".");
142: cvs_client_send_request("ci");
143: cvs_client_get_responses();
1.86 joris 144: } else {
145: cr.fileproc = cvs_commit_local;
146: cvs_file_walklist(&files_affected, &cr);
147: cvs_file_freelist(&files_affected);
1.80 joris 148: }
1.1 jfb 149:
1.18 joris 150: return (0);
151: }
1.1 jfb 152:
1.55 joris 153: void
1.86 joris 154: cvs_commit_check_files(struct cvs_file *cf)
1.18 joris 155: {
1.112 joris 156: char *tag;
157: RCSNUM *branch, *brev;
158: char rev[CVS_REV_BUFSZ];
159:
1.86 joris 160: cvs_log(LP_TRACE, "cvs_commit_check_files(%s)", cf->file_path);
1.44 joris 161:
1.108 joris 162: if (current_cvsroot->cr_method != CVS_METHOD_LOCAL)
163: cvs_remote_classify_file(cf);
164: else
1.110 joris 165: cvs_file_classify(cf, cvs_directory_tag);
1.59 joris 166:
167: if (cf->file_type == CVS_DIR) {
168: if (verbosity > 1)
169: cvs_log(LP_NOTICE, "Examining %s", cf->file_path);
170: return;
171: }
1.32 joris 172:
1.55 joris 173: if (cf->file_status == FILE_CONFLICT ||
1.79 joris 174: cf->file_status == FILE_UNLINK) {
1.55 joris 175: conflicts_found++;
1.79 joris 176: return;
177: }
1.57 joris 178:
1.63 joris 179: if (cf->file_status != FILE_REMOVED &&
180: update_has_conflict_markers(cf)) {
1.60 joris 181: cvs_log(LP_ERR, "conflict: unresolved conflicts in %s from "
182: "merging, please fix these first", cf->file_path);
183: conflicts_found++;
1.79 joris 184: return;
1.60 joris 185: }
186:
1.57 joris 187: if (cf->file_status == FILE_MERGE ||
1.72 joris 188: cf->file_status == FILE_PATCH ||
1.79 joris 189: cf->file_status == FILE_CHECKOUT ||
190: cf->file_status == FILE_LOST) {
1.57 joris 191: cvs_log(LP_ERR, "conflict: %s is not up-to-date",
192: cf->file_path);
193: conflicts_found++;
1.79 joris 194: return;
1.57 joris 195: }
1.55 joris 196:
1.112 joris 197: if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
198: tag = cvs_directory_tag;
199: if (cf->file_ent != NULL)
200: tag = cf->file_ent->ce_tag;
201:
202: if (tag != NULL && cf->file_rcs != NULL) {
203: brev = rcs_sym_getrev(cf->file_rcs, tag);
204: if (brev != NULL) {
205: if (RCSNUM_ISBRANCH(brev))
206: goto next;
207: }
208:
209: brev = rcs_translate_tag(tag, cf->file_rcs);
210:
211: if (brev == NULL) {
212: fatal("failed to resolve tag: %s",
213: cf->file_ent->ce_tag);
214: }
215:
216: rcsnum_tostr(brev, rev, sizeof(rev));
217: if ((branch = rcsnum_revtobr(brev)) == NULL) {
218: cvs_log(LP_ERR, "%s is not a branch revision",
219: rev);
220: conflicts_found++;
221: return;
222: }
223:
224: if (!RCSNUM_ISBRANCHREV(brev)) {
225: cvs_log(LP_ERR, "%s is not a branch revision",
226: rev);
227: conflicts_found++;
228: return;
229: }
230:
231: rcsnum_tostr(branch, rev, sizeof(rev));
232: if (!RCSNUM_ISBRANCH(branch)) {
233: cvs_log(LP_ERR, "%s (%s) is not a branch",
234: cf->file_ent->ce_tag, rev);
235: conflicts_found++;
236: return;
237: }
238: }
239: }
240:
241: next:
1.55 joris 242: if (cf->file_status == FILE_ADDED ||
243: cf->file_status == FILE_REMOVED ||
244: cf->file_status == FILE_MODIFIED)
1.110 joris 245: cvs_file_get(cf->file_path, 0, &files_affected);
1.86 joris 246:
247: switch (cf->file_status) {
248: case FILE_ADDED:
1.110 joris 249: cvs_file_get(cf->file_path, 0, &files_added);
1.86 joris 250: break;
251: case FILE_REMOVED:
1.110 joris 252: cvs_file_get(cf->file_path, 0, &files_removed);
1.86 joris 253: break;
254: case FILE_MODIFIED:
1.110 joris 255: cvs_file_get(cf->file_path, 0, &files_modified);
1.86 joris 256: break;
257: }
1.55 joris 258: }
1.1 jfb 259:
1.55 joris 260: void
261: cvs_commit_local(struct cvs_file *cf)
262: {
1.112 joris 263: char *tag;
1.91 joris 264: BUF *b, *d;
1.112 joris 265: int onbranch, isnew, histtype;
266: RCSNUM *nrev, *crev, *rrev, *brev;
1.102 xsa 267: int openflags, rcsflags;
1.119 tobias 268: char rbuf[CVS_REV_BUFSZ], nbuf[CVS_REV_BUFSZ];
1.56 joris 269: CVSENTRIES *entlist;
1.100 otto 270: char attic[MAXPATHLEN], repo[MAXPATHLEN], rcsfile[MAXPATHLEN];
1.17 joris 271:
1.55 joris 272: cvs_log(LP_TRACE, "cvs_commit_local(%s)", cf->file_path);
1.110 joris 273: cvs_file_classify(cf, cvs_directory_tag);
1.69 joris 274:
275: if (cvs_noexec == 1)
276: return;
1.35 xsa 277:
1.64 joris 278: if (cf->file_type != CVS_FILE)
279: fatal("cvs_commit_local: '%s' is not a file", cf->file_path);
280:
1.107 joris 281: if (cf->file_status != FILE_MODIFIED &&
282: cf->file_status != FILE_ADDED &&
283: cf->file_status != FILE_REMOVED) {
284: cvs_log(LP_ERR, "skipping bogus file `%s'", cf->file_path);
285: return;
286: }
287:
1.112 joris 288: onbranch = 0;
289: nrev = RCS_HEAD_REV;
290: crev = NULL;
291: rrev = NULL;
292:
1.115 joris 293: if (cf->file_rcs != NULL && cf->file_rcs->rf_branch != NULL) {
1.114 joris 294: rcsnum_free(cf->file_rcs->rf_branch);
295: cf->file_rcs->rf_branch = NULL;
296: }
297:
1.56 joris 298: if (cf->file_status == FILE_MODIFIED ||
1.66 joris 299: cf->file_status == FILE_REMOVED || (cf->file_status == FILE_ADDED
1.93 joris 300: && cf->file_rcs != NULL && cf->file_rcs->rf_dead == 1)) {
1.112 joris 301: rrev = rcs_head_get(cf->file_rcs);
302: crev = rcs_head_get(cf->file_rcs);
1.116 tobias 303: if (crev == NULL || rrev == NULL)
304: fatal("RCS head empty or missing in %s\n",
305: cf->file_rcs->rf_path);
1.112 joris 306:
307: tag = cvs_directory_tag;
308: if (cf->file_ent != NULL && cf->file_ent->ce_tag != NULL)
309: tag = cf->file_ent->ce_tag;
310:
311: if (tag != NULL) {
312: rcsnum_free(crev);
313: crev = rcs_translate_tag(tag, cf->file_rcs);
314: if (crev == NULL) {
315: fatal("failed to resolve existing tag: %s",
316: tag);
317: }
318:
319: if (RCSNUM_ISBRANCHREV(crev)) {
320: nrev = rcsnum_alloc();
321: rcsnum_cpy(crev, nrev, 0);
322: rcsnum_inc(nrev);
323: } else if (!RCSNUM_ISBRANCH(crev)) {
324: brev = rcs_sym_getrev(cf->file_rcs, tag);
325: if (brev == NULL)
326: fatal("no more tag?");
327: nrev = rcsnum_brtorev(brev);
328: if (nrev == NULL)
329: fatal("failed to create branch rev");
330: } else {
331: fatal("this isnt suppose to happen, honestly");
332: }
333:
334: rcsnum_free(rrev);
335: rrev = rcsnum_branch_root(nrev);
336:
337: /* branch stuff was checked in cvs_commit_check_files */
338: onbranch = 1;
339: }
340:
341: rcsnum_tostr(crev, rbuf, sizeof(rbuf));
1.93 joris 342: } else {
1.61 joris 343: strlcpy(rbuf, "Non-existent", sizeof(rbuf));
1.93 joris 344: }
1.61 joris 345:
1.67 joris 346: isnew = 0;
1.66 joris 347: if (cf->file_status == FILE_ADDED) {
1.67 joris 348: isnew = 1;
1.66 joris 349: rcsflags = RCS_CREATE;
350: openflags = O_CREAT | O_TRUNC | O_WRONLY;
351: if (cf->file_rcs != NULL) {
1.106 niallo 352: if (cf->in_attic == 0)
1.66 joris 353: cvs_log(LP_ERR, "warning: expected %s "
354: "to be in the Attic", cf->file_path);
355:
356: if (cf->file_rcs->rf_dead == 0)
357: cvs_log(LP_ERR, "warning: expected %s "
358: "to be dead", cf->file_path);
359:
360: cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
1.102 xsa 361: (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s%s",
1.66 joris 362: repo, cf->file_name, RCS_FILE_EXT);
363:
364: if (rename(cf->file_rpath, rcsfile) == -1)
365: fatal("cvs_commit_local: failed to move %s "
366: "outside the Attic: %s", cf->file_path,
367: strerror(errno));
368:
369: xfree(cf->file_rpath);
370: cf->file_rpath = xstrdup(rcsfile);
371:
372: rcsflags = RCS_READ | RCS_PARSE_FULLY;
373: openflags = O_RDONLY;
374: rcs_close(cf->file_rcs);
1.67 joris 375: isnew = 0;
1.66 joris 376: }
377:
378: cf->repo_fd = open(cf->file_rpath, openflags);
1.61 joris 379: if (cf->repo_fd < 0)
380: fatal("cvs_commit_local: %s", strerror(errno));
381:
382: cf->file_rcs = rcs_open(cf->file_rpath, cf->repo_fd,
1.103 otto 383: rcsflags, 0444);
1.61 joris 384: if (cf->file_rcs == NULL)
385: fatal("cvs_commit_local: failed to create RCS file "
386: "for %s", cf->file_path);
1.71 xsa 387:
388: commit_desc_set(cf);
1.61 joris 389: }
1.36 joris 390:
1.77 reyk 391: if (verbosity > 1) {
392: cvs_printf("Checking in %s:\n", cf->file_path);
393: cvs_printf("%s <- %s\n", cf->file_rpath, cf->file_path);
394: cvs_printf("old revision: %s; ", rbuf);
395: }
1.7 jfb 396:
1.112 joris 397: if (isnew == 0 && onbranch == 0)
398: d = commit_diff(cf, cf->file_rcs->rf_head, 0);
1.7 jfb 399:
1.56 joris 400: if (cf->file_status == FILE_REMOVED) {
1.112 joris 401: b = rcs_rev_getbuf(cf->file_rcs, crev, 0);
1.56 joris 402: if (b == NULL)
1.112 joris 403: fatal("cvs_commit_local: failed to get crev");
404: } else if (onbranch == 1) {
405: b = commit_diff(cf, crev, 1);
1.61 joris 406: } else {
1.73 joris 407: if ((b = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL)
1.56 joris 408: fatal("cvs_commit_local: failed to load file");
409: }
1.7 jfb 410:
1.112 joris 411: if (isnew == 0 && onbranch == 0) {
412: if (rcs_deltatext_set(cf->file_rcs, crev, d) == -1)
1.61 joris 413: fatal("cvs_commit_local: failed to set delta");
414: }
1.3 krapht 415:
1.112 joris 416: if (rcs_rev_add(cf->file_rcs, nrev, logmsg, -1, NULL) == -1)
1.55 joris 417: fatal("cvs_commit_local: failed to add new revision");
1.3 krapht 418:
1.112 joris 419: if (nrev == RCS_HEAD_REV)
420: nrev = cf->file_rcs->rf_head;
421:
422: if (rcs_deltatext_set(cf->file_rcs, nrev, b) == -1)
1.55 joris 423: fatal("cvs_commit_local: failed to set new HEAD delta");
1.3 krapht 424:
1.56 joris 425: if (cf->file_status == FILE_REMOVED) {
1.112 joris 426: if (rcs_state_set(cf->file_rcs, nrev, RCS_STATE_DEAD) == -1)
1.56 joris 427: fatal("cvs_commit_local: failed to set state");
1.101 xsa 428: }
429:
430: if (cf->file_status == FILE_ADDED && cf->file_ent->ce_opts != NULL) {
431: int kflag;
432:
433: kflag = rcs_kflag_get(cf->file_ent->ce_opts + 2);
434: rcs_kwexp_set(cf->file_rcs, kflag);
1.56 joris 435: }
436:
1.55 joris 437: rcs_write(cf->file_rcs);
1.6 jfb 438:
1.56 joris 439: if (cf->file_status == FILE_REMOVED) {
1.77 reyk 440: strlcpy(nbuf, "Removed", sizeof(nbuf));
1.61 joris 441: } else if (cf->file_status == FILE_ADDED) {
1.66 joris 442: if (cf->file_rcs->rf_dead == 1)
1.77 reyk 443: strlcpy(nbuf, "Initial Revision", sizeof(nbuf));
1.63 joris 444: else
1.112 joris 445: rcsnum_tostr(nrev, nbuf, sizeof(nbuf));
1.56 joris 446: } else if (cf->file_status == FILE_MODIFIED) {
1.112 joris 447: rcsnum_tostr(nrev, nbuf, sizeof(nbuf));
1.56 joris 448: }
449:
1.77 reyk 450: if (verbosity > 1)
451: cvs_printf("new revision: %s\n", nbuf);
1.3 krapht 452:
1.55 joris 453: (void)unlink(cf->file_path);
454: (void)close(cf->fd);
455: cf->fd = -1;
1.56 joris 456:
457: if (cf->file_status != FILE_REMOVED) {
1.112 joris 458: cvs_checkout_file(cf, nrev, NULL, CO_COMMIT);
1.56 joris 459: } else {
460: entlist = cvs_ent_open(cf->file_wd);
461: cvs_ent_remove(entlist, cf->file_name);
462: cvs_ent_close(entlist, ENT_SYNC);
1.64 joris 463:
464: cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
465:
1.102 xsa 466: (void)xsnprintf(attic, MAXPATHLEN, "%s/%s",
467: repo, CVS_PATH_ATTIC);
1.64 joris 468:
469: if (mkdir(attic, 0755) == -1 && errno != EEXIST)
470: fatal("cvs_commit_local: failed to create Attic");
471:
1.102 xsa 472: (void)xsnprintf(attic, MAXPATHLEN, "%s/%s/%s%s", repo,
1.64 joris 473: CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT);
474:
475: if (rename(cf->file_rpath, attic) == -1)
476: fatal("cvs_commit_local: failed to move %s to Attic",
477: cf->file_path);
478:
1.85 joris 479: if (cvs_server_active == 1)
480: cvs_server_update_entry("Remove-entry", cf);
1.56 joris 481: }
1.3 krapht 482:
1.77 reyk 483: if (verbosity > 1)
484: cvs_printf("done\n");
485: else {
486: cvs_log(LP_NOTICE, "checking in '%s'; revision %s -> %s",
487: cf->file_path, rbuf, nbuf);
488: }
1.107 joris 489:
490: switch (cf->file_status) {
491: case FILE_MODIFIED:
492: histtype = CVS_HISTORY_COMMIT_MODIFIED;
493: break;
494: case FILE_ADDED:
495: histtype = CVS_HISTORY_COMMIT_ADDED;
496: break;
497: case FILE_REMOVED:
498: histtype = CVS_HISTORY_COMMIT_REMOVED;
499: break;
500: }
501:
502: cvs_history_add(histtype, cf, NULL);
1.39 xsa 503: }
504:
1.91 joris 505: static BUF *
1.112 joris 506: commit_diff(struct cvs_file *cf, RCSNUM *rev, int reverse)
1.39 xsa 507: {
1.112 joris 508: char *p1, *p2, *p;
1.97 joris 509: BUF *b1, *b2;
510:
511: (void)xasprintf(&p1, "%s/diff1.XXXXXXXXXX", cvs_tmpdir);
1.39 xsa 512:
1.63 joris 513: if (cf->file_status == FILE_MODIFIED ||
514: cf->file_status == FILE_ADDED) {
1.73 joris 515: if ((b1 = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL)
1.118 tobias 516: fatal("commit_diff: failed to load '%s'",
1.56 joris 517: cf->file_path);
1.97 joris 518: cvs_buf_write_stmp(b1, p1, NULL);
519: cvs_buf_free(b1);
1.63 joris 520: } else {
1.112 joris 521: rcs_rev_write_stmp(cf->file_rcs, rev, p1, 0);
1.56 joris 522: }
1.3 krapht 523:
1.97 joris 524: (void)xasprintf(&p2, "%s/diff2.XXXXXXXXXX", cvs_tmpdir);
1.117 tobias 525: rcs_rev_write_stmp(cf->file_rcs, rev, p2, RCS_KWEXP_NONE);
1.55 joris 526:
1.97 joris 527: if ((b2 = cvs_buf_alloc(128, BUF_AUTOEXT)) == NULL)
1.112 joris 528: fatal("commit_diff: failed to create diff buf");
1.55 joris 529:
530: diff_format = D_RCSDIFF;
1.112 joris 531:
532: if (reverse == 1) {
533: p = p1;
534: p1 = p2;
535: p2 = p;
536: }
537:
1.97 joris 538: if (cvs_diffreg(p1, p2, b2) == D_ERROR)
1.112 joris 539: fatal("commit_diff: failed to get RCS patch");
1.96 joris 540:
541: xfree(p1);
542: xfree(p2);
1.55 joris 543:
1.97 joris 544: return (b2);
1.71 xsa 545: }
546:
547: static void
548: commit_desc_set(struct cvs_file *cf)
549: {
550: BUF *bp;
1.102 xsa 551: int fd;
1.100 otto 552: char desc_path[MAXPATHLEN], *desc;
1.71 xsa 553:
1.102 xsa 554: (void)xsnprintf(desc_path, MAXPATHLEN, "%s/%s%s",
1.71 xsa 555: CVS_PATH_CVSDIR, cf->file_name, CVS_DESCR_FILE_EXT);
556:
1.100 otto 557: if ((fd = open(desc_path, O_RDONLY)) == -1)
1.71 xsa 558: return;
559:
1.78 joris 560: bp = cvs_buf_load_fd(fd, BUF_AUTOEXT);
1.71 xsa 561: cvs_buf_putc(bp, '\0');
562: desc = cvs_buf_release(bp);
563:
564: rcs_desc_set(cf->file_rcs, desc);
565:
1.76 joris 566: (void)close(fd);
1.71 xsa 567: (void)cvs_unlink(desc_path);
568:
569: xfree(desc);
1.1 jfb 570: }