switch "tog diff" repository path argument to a new -r option
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
diff --git a/tog/tog.1 b/tog/tog.1
index e27af0c..60eb4e5 100644
--- a/tog/tog.1
+++ b/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 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.
.Pp
diff --git a/tog/tog.c b/tog/tog.c
index 1a25cb8..db491e8 100644
--- a/tog/tog.c
+++ b/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();