Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Aug 2001 12:50:49 -0700 (PDT)
From:      Matt Dillon <dillon@earth.backplane.com>
To:        Josef Karthauser <joe@tao.org.uk>
Cc:        Eivind Eklund <eivind@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Second cvs patch: diff -j support
Message-ID:  <200108111950.f7BJonS19565@earth.backplane.com>
References:  <3B4F1FCD.7F2D4842@FreeBSD.org> <20010713120140Q.jkh@osd.bsdi.com> <20010713211017.A57434@heechee.tobez.org> <20010713123241X.jkh@osd.bsdi.com> <200107132214.f6DMET571067@earth.backplane.com> <20010715143503.A10888@FreeBSD.org> <20010810133132.G624@tao.org.uk>

next in thread | previous in thread | raw e-mail | index | archive | help

    Oh, needless to say, I'm looking for feedback on that last patch.  If
    people think it is reasonable, I'll commit it to -current and -stable.

    --

    I also have another patch set for cvs that gives cvs diff the '-j' option.
    The big thing here is that -j can be told to use a tag AND a date spec,
    allowing you to diff between dates for a particular tag.  And the server
    side can be made to support it.  The existing diff -r option cannot do
    that and so you can only do date diffs against the head branch (and if
    I were to extend the existing -r option then it would not be backwards
    compatible with older cvs servers).

    I've included that patch set below.  Feedback is welcome.  It's the same
    one I posted a few months ago.  I'd like to commit it.

						-Matt

Index: diff.c
===================================================================
RCS file: /home/ncvs/src/contrib/cvs/src/diff.c,v
retrieving revision 1.14
diff -u -r1.14 diff.c
--- diff.c	1999/12/11 12:50:08	1.14
+++ diff.c	2001/03/24 21:51:13
@@ -50,6 +50,7 @@
 static char *diff_rev1, *diff_rev2;
 /* Command line dates, from -D option.  Malloc'd.  */
 static char *diff_date1, *diff_date2;
+static char *diff_join1, *diff_join2;
 static char *use_rev1, *use_rev2;
 static int have_rev1_label, have_rev2_label;
 
@@ -245,10 +246,12 @@
     diff_rev2 = NULL;
     diff_date1 = NULL;
     diff_date2 = NULL;
+    diff_join1 = NULL;	/* used for client/server only */
+    diff_join2 = NULL;	/* used for client/server only */
 
     optind = 0;
     while ((c = getopt_long (argc, argv,
-	       "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:",
+	       "+abcdefhilnpstuw0123456789BHNRC:D:F:I:L:U:V:W:k:r:j:",
 			     longopts, &option_index)) != -1)
     {
 	switch (c)
@@ -308,6 +311,27 @@
 		    free (options);
 		options = RCS_check_kflag (optarg);
 		break;
+	    case 'j':
+		{
+		    char *ptr;
+		    char *cpy = strdup(optarg);
+
+		    if ((ptr = strchr(optarg, ':')) != NULL)
+			*ptr++ = 0;
+		    if (diff_rev2 != NULL || diff_date2 != NULL)
+			error (1, 0,
+			   "no more than two revisions/dates can be specified");
+		    if (diff_rev1 != NULL || diff_date1 != NULL) {
+			diff_join2 = cpy;
+			diff_rev2 = optarg;
+			diff_date2 = ptr ? Make_Date(ptr) : NULL;
+		    } else {
+			diff_join1 = cpy;
+			diff_rev1 = optarg;
+			diff_date1 = ptr ? Make_Date(ptr) : NULL;
+		    }
+		}
+		break;
 	    case 'r':
 		if (diff_rev2 != NULL || diff_date2 != NULL)
 		    error (1, 0,
@@ -356,13 +380,18 @@
 	send_option_string (opts);
 	if (options[0] != '\0')
 	    send_arg (options);
-	if (diff_rev1)
+	if (diff_join1)
+	    option_with_arg ("-j", diff_join1);
+	else if (diff_rev1)
 	    option_with_arg ("-r", diff_rev1);
-	if (diff_date1)
+	else if (diff_date1)
 	    client_senddate (diff_date1);
-	if (diff_rev2)
+
+	if (diff_join2)
+	    option_with_arg ("-j", diff_join2);
+	else if (diff_rev2)
 	    option_with_arg ("-r", diff_rev2);
-	if (diff_date2)
+	else if (diff_date2)
 	    client_senddate (diff_date2);
 
 	/* Send the current files unless diffing two revs from the archive */
@@ -375,28 +404,26 @@
 
 	send_to_server ("diff\012", 0);
         err = get_responses_and_close ();
-	free (options);
-	options = NULL;
-	return (err);
-    }
+    } else
 #endif
-
-    if (diff_rev1 != NULL)
-	tag_check_valid (diff_rev1, argc, argv, local, 0, "");
-    if (diff_rev2 != NULL)
-	tag_check_valid (diff_rev2, argc, argv, local, 0, "");
-
-    which = W_LOCAL;
-    if (diff_rev1 != NULL || diff_date1 != NULL)
-	which |= W_REPOS | W_ATTIC;
-
-    wrap_setup ();
-
-    /* start the recursion processor */
-    err = start_recursion (diff_fileproc, diff_filesdoneproc, diff_dirproc,
-			   diff_dirleaveproc, NULL, argc, argv, local,
-			   which, 0, 1, (char *) NULL, 1);
+    {
+	if (diff_rev1 != NULL)
+	    tag_check_valid (diff_rev1, argc, argv, local, 0, "");
+	if (diff_rev2 != NULL)
+	    tag_check_valid (diff_rev2, argc, argv, local, 0, "");
+
+	which = W_LOCAL;
+	if (diff_rev1 != NULL || diff_date1 != NULL)
+	    which |= W_REPOS | W_ATTIC;
+
+	wrap_setup ();
+
+	/* start the recursion processor */
+	err = start_recursion (diff_fileproc, diff_filesdoneproc, diff_dirproc,
+			       diff_dirleaveproc, NULL, argc, argv, local,
+			       which, 0, 1, (char *) NULL, 1);
 
+    }
     /* clean up */
     free (options);
     options = NULL;
@@ -405,6 +432,10 @@
 	free (diff_date1);
     if (diff_date2 != NULL)
 	free (diff_date2);
+    if (diff_join1 != NULL)
+	free (diff_join1);
+    if (diff_join2 != NULL)
+	free (diff_join2);
 
     return (err);
 }
@@ -452,7 +483,7 @@
 		int exists;
 
 		exists = 0;
-		/* special handling for TAG_HEAD */
+		/* special handling for TAG_HEAD XXX */
 		if (diff_rev1 && strcmp (diff_rev1, TAG_HEAD) == 0)
 		{
 		    char *head =
@@ -842,7 +873,7 @@
 
     if (diff_rev1 || diff_date1)
     {
-	/* special handling for TAG_HEAD */
+	/* special handling for TAG_HEAD XXX */
 	if (diff_rev1 && strcmp (diff_rev1, TAG_HEAD) == 0)
 	    use_rev1 = ((vers->vn_rcs == NULL || vers->srcfile == NULL)
 			? NULL
@@ -857,7 +888,7 @@
     }
     if (diff_rev2 || diff_date2)
     {
-	/* special handling for TAG_HEAD */
+	/* special handling for TAG_HEAD XXX */
 	if (diff_rev2 && strcmp (diff_rev2, TAG_HEAD) == 0)
 	    use_rev2 = ((vers->vn_rcs == NULL || vers->srcfile == NULL)
 			? NULL

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108111950.f7BJonS19565>