Commit Diff


commit - e3e3c46ba063d58085bb603ab3e755ce1ff44d9b8789afe72e0ac5aa48f5c8f5
commit + 68a5ea4cac937b4c448ab37e3e71e76702c981649c94a93d4f6b678ada5f4561
blob - ee08842339a89f2ef6a574d5d2b96642688c9289116ebcfceb4bc85cdd684440
blob + 318935acf5f96c282ce713eeb25e7cc82983b5908f1bcecc779ef5244838531e
--- gotsysd/gotsysd.8	
+++ gotsysd/gotsysd.8	
@@ -94,6 +94,8 @@ Only check the configuration file for validity.
 .It Fl v
 Verbose mode.
 Verbosity increases if this option is used multiple times.
+.It Fl V , -version
+Display program version and exit immediately.
 .El
 .Sh FILES
 .Bl -tag -width Ds -compact
blob - 75895889d9e3f12401de9750331408545dbb6c68e3fda65adcbcacbf6c3bf7a5
blob + 5aa632332ed2e08bce5885b653fa3d6304bec82ce02fda963a2b34926ec4ffb5
--- gotsysd/gotsysd.c	
+++ gotsysd/gotsysd.c	
@@ -36,6 +36,7 @@
 #include <syslog.h>
 #include <unistd.h>
 
+#include "got_version.h"
 #include "got_error.h"
 #include "got_path.h"
 #include "got_object.h"
@@ -1683,11 +1684,15 @@ main(int argc, char **argv)
 	uid_t uid;
 	const char *errstr;
 	char *commit_id_str = NULL;
-	int ch, fd = -1, daemonize = 1, verbosity = 0, noaction = 0;
+	int ch, fd = -1, daemonize = 1, verbosity = 0, noaction = 0, version_flag = 0;
+	static const struct option longopts[] = {
+		{ "version", no_argument, NULL, 'V' },
+		{ NULL, 0, NULL, 0 }
+	};
 
 	log_init(1, LOG_DAEMON); /* Log to stderr until daemonized. */
 
-	while ((ch = getopt(argc, argv, "df:nT:v")) != -1) {
+	while ((ch = getopt_long(argc, argv, "df:nT:vV", longopts, NULL)) != -1) {
 		switch (ch) {
 		case 'd':
 			daemonize = 0;
@@ -1723,6 +1728,9 @@ main(int argc, char **argv)
 			if (verbosity < 3)
 				verbosity++;
 			break;
+		case 'V':
+			version_flag = 1;
+			break;
 		default:
 			usage();
 		}
@@ -1737,6 +1745,11 @@ main(int argc, char **argv)
 		commit_id_str = argv[0];
 	} else if (argc != 0)
 		usage();
+	
+	if (version_flag) {
+		got_version_print_str();
+		return 0;
+	}
 
 	if (geteuid() && (proc_id == GOTSYSD_PROC_GOTSYSD ||
 	    proc_id == GOTSYSD_PROC_LISTEN || proc_id == GOTSYSD_PROC_PRIV))