Commit Diff


commit - a273ac941fef190ba5179b88c6809eebe471b8b3
commit + 09b5bff804353d5930f67d05e453815493aeb225
blob - e27af0c30eb30142cb8e3f9fce4f2f60f16932cc
blob + 60eb4e57f26ec0a536d5512ff7e6ea9b9824606a
--- tog/tog.1
+++ tog/tog.1
@@ -166,7 +166,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
@@ -174,9 +174,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
@@ -209,6 +206,16 @@ Find the next line which matches the current search pa
 .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.
 .Pp
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();