"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Switch tog diff to -r
To:
gameoftrees@openbsd.org
Date:
Sun, 23 Feb 2020 00:14:12 +0100

Download raw body.

Thread
  • Christian Weisgerber:

    Switch tog diff to -r

 switch "tog diff" repository path argument to a new -r option
 
diff 28e8fe3acba2cedafee5e122442ff2a68f84bc45 00d0285b8963519aa587493b9aecf828c44f563c
blob - 0dd65401b0dc391a3212722256b92a0e5afc702a
blob + f1e524913f216c6568a861e086ca56c709b0ee90
--- tog/tog.1
+++ tog/tog.1
@@ -161,7 +161,7 @@ Use the repository at the specified path.
 If not specified, assume the repository is located at or above the current
 working directory.
 .El
-.It Cm diff Oo Ar repository-path Oc Ar object1 object2
+.It Cm diff Oo Fl r Ar repository-path Oc Ar object1 object2
 Display the differences between two objects in the repository.
 Each
 .Ar object
@@ -169,9 +169,6 @@ argument is an object ID SHA1 hash.
 An abbreviated hash argument will be expanded to a full SHA1 hash
 automatically, provided the abbreviation is unique.
 Both objects must be of the same type (blobs, trees, or commits).
-If the
-.Ar repository path
-is omitted, use the current working directory.
 .Pp
 The key bindings for
 .Cm tog diff
@@ -203,6 +200,16 @@ Regular expression syntax is documented in
 Find the next line which matches the current search pattern.
 .It Cm N
 Find the previous line which matches the current search pattern.
+.El
+.Pp
+The options for
+.Cm tog diff
+are as follows:
+.Bl -tag -width Ds
+.It Fl r Ar repository-path
+Use the repository at the specified path.
+If not specified, assume the repository is located at or above the current
+working directory.
 .El
 .It Cm blame Oo Fl c Ar commit Oc Oo Fl r Ar repository-path Oc Ar path
 Display line-by-line history of a file at the specified path.
blob - 1a25cb86d8ee8854fc60c819572513bd7d475850
blob + db491e889c779a9a919851be200f178541a1974e
--- tog/tog.c
+++ tog/tog.c
@@ -2682,7 +2682,7 @@ __dead static void
 usage_diff(void)
 {
 	endwin();
-	fprintf(stderr, "usage: %s diff [repository-path] object1 object2\n",
+	fprintf(stderr, "usage: %s diff [-r repository-path] object1 object2\n",
 	    getprogname());
 	exit(1);
 }
@@ -3491,8 +3491,14 @@ cmd_diff(int argc, char *argv[])
 		err(1, "pledge");
 #endif
 
-	while ((ch = getopt(argc, argv, "")) != -1) {
+	while ((ch = getopt(argc, argv, "r:")) != -1) {
 		switch (ch) {
+		case 'r':
+			repo_path = realpath(optarg, NULL);
+			if (repo_path == NULL)
+				return got_error_from_errno2("realpath",
+				    optarg);
+			break;
 		default:
 			usage_diff();
 			/* NOTREACHED */
@@ -3507,12 +3513,6 @@ cmd_diff(int argc, char *argv[])
 	} else if (argc == 2) {
 		id_str1 = argv[0];
 		id_str2 = argv[1];
-	} else if (argc == 3) {
-		repo_path = realpath(argv[0], NULL);
-		if (repo_path == NULL)
-			return got_error_from_errno2("realpath", argv[0]);
-		id_str1 = argv[1];
-		id_str2 = argv[2];
 	} else
 		usage_diff();
 

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de