here's a useful but possibly controversial patch. it allows one to say

        cvs -m "foo" -u user-to-commit-as srcdir/

and have the ,v files show the "user-to-commit-as" as the author of
the change rather than the getcaller() user.

in a setting where you keep your tree in CVS but accept patches from
a variety of authors, i've found this useful. obviously though, it 
wouldn't be nice in a untrusted environment. maybe someone could add
some security to this somehow.

i'm not on this list so for any suggestions/questions please cc me
directly. thanks.

its really a simple patch...

Only in cvs-1.10.8/src: Makefile
diff -ur cvs-1.10.8/src/commit.c cvs-1.10.8-su-commit/src/commit.c
--- cvs-1.10.8/src/commit.c     Wed Jan  5 11:35:46 2000
+++ cvs-1.10.8-su-commit/src/commit.c   Tue May  2 13:25:36 2000
@@ -74,6 +74,7 @@
 static int run_module_prog = 1;
 static int aflag;
 static char *saved_tag;
+static char *checkin_author;
 static char *write_dirtag;
 static int write_dirnonbranch;
 static char *logfile;
@@ -84,7 +85,7 @@
 
 static const char *const commit_usage[] =
 {
-    "Usage: %s %s [-nRlf] [-m msg | -F logfile] [-r rev] files...\n",
+    "Usage: %s %s [-nRlf] [-m msg | -F logfile] [-r rev] [-u user] files...\n",
     "\t-n\tDo not run the module program (if any).\n",
     "\t-R\tProcess directories recursively.\n",
     "\t-l\tLocal directory only (not recursive).\n",
@@ -92,6 +93,7 @@
     "\t-F file\tRead the log message from file.\n",
     "\t-m msg\tLog message.\n",
     "\t-r rev\tCommit to this branch or trunk revision.\n",
+    "\t-u user\tCommit as this user, rather than who you are logged in as.\n",
     "(Specify the --help global option for a list of other help options)\n",
     NULL
 };
@@ -356,7 +358,7 @@
 #endif /* CVS_BADROOT */
 
     optind = 0;
-    while ((c = getopt (argc, argv, "+nlRm:fF:r:")) != -1)
+    while ((c = getopt (argc, argv, "+nlRm:fF:r:u:")) != -1)
     {
        switch (c)
        {
@@ -382,6 +384,11 @@
                    free (saved_tag);
                saved_tag = xstrdup (optarg);
                break;
+           case 'u':
+               if (checkin_author)
+                   free (checkin_author);
+               checkin_author = xstrdup(optarg);
+               break;
            case 'l':
                local = 1;
                break;
@@ -564,6 +571,8 @@
        if (!run_module_prog)
            send_arg("-n");
        option_with_arg ("-r", saved_tag);
+       if (checkin_author)
+               option_with_arg("-u", checkin_author);
 
        /* FIXME: This whole find_args.force/SEND_FORCE business is a
           kludge.  It would seem to be a server bug that we have to
@@ -2364,3 +2374,12 @@
     }
     return rcs;
 }
+
+/* a hack for RCS_checkin to checkin as someone else */
+char* 
+getauthor()
+{
+       if (checkin_author) return checkin_author;
+       else return getcaller();
+}
+
Only in cvs-1.10.8-su-commit/src: commit.c~
Only in cvs-1.10.8-su-commit/src: cscope.out
diff -ur cvs-1.10.8/src/cvs.h cvs-1.10.8-su-commit/src/cvs.h
--- cvs-1.10.8/src/cvs.h        Mon Jan  3 15:49:12 2000
+++ cvs-1.10.8-su-commit/src/cvs.h      Tue May  2 09:17:05 2000
@@ -459,6 +459,7 @@
 char *gca PROTO((const char *rev1, const char *rev2));
 extern void check_numeric PROTO ((const char *, int, char **));
 char *getcaller PROTO((void));
+char *getauthor PROTO((void));
 char *time_stamp PROTO((char *file));
 
 void *xmalloc PROTO((size_t bytes));
diff -ur cvs-1.10.8/src/rcs.c cvs-1.10.8-su-commit/src/rcs.c
--- cvs-1.10.8/src/rcs.c        Wed Jan  5 11:35:46 2000
+++ cvs-1.10.8-su-commit/src/rcs.c      Tue May  2 09:33:18 2000
@@ -5199,7 +5199,7 @@
     /* Create new delta node. */
     delta = (RCSVers *) xmalloc (sizeof (RCSVers));
     memset (delta, 0, sizeof (RCSVers));
-    delta->author = xstrdup (getcaller ());
+    delta->author = xstrdup (getauthor ());
     if (flags & RCS_FLAGS_MODTIME)
     {
        struct stat ws;
@@ -5517,7 +5517,7 @@
     nodep = findnode (RCS_getlocks (rcs), commitpt->version);
     if (nodep != NULL)
     {
-       if (! STREQ (nodep->data, delta->author))
+       if (! STREQ (nodep->data, getcaller()))
        {
            /* If we are adding a branch, then leave the old lock around.
               That is sensible in the sense that when adding a branch,
Only in cvs-1.10.8: stamp-h
Only in cvs-1.10.8/tools: Makefile
Only in cvs-1.10.8/vms: Makefile
Only in cvs-1.10.8/windows-NT: Makefile
Only in cvs-1.10.8/zlib: Makefile

-- 
------------------------------------------------------------------------
Joel W. Reed                              http://ruby.ddiworld.com/jreed
-------------------------Oxymoron: Slow speed.-------------------------


Reply via email to