include version number
diff --git a/src/ninja.cc b/src/ninja.cc
index 667aaae..6090bdb 100644
--- a/src/ninja.cc
+++ b/src/ninja.cc
@@ -49,6 +49,10 @@
 
 namespace {
 
+/// The version number of the current Ninja release.  This will always
+/// be "git" on trunk.
+const char* kVersion = "git";
+
 /// Global information passed into subtools.
 struct Globals {
   Globals() : state(new State()) {}
@@ -83,6 +87,7 @@
 "options:\n"
 "  -C DIR   change to DIR before doing anything else\n"
 "  -f FILE  specify input build file [default=build.ninja]\n"
+"  -V       print ninja version (\"%s\")\n"
 "\n"
 "  -j N     run N jobs in parallel [default=%d]\n"
 "  -l N     do not start new jobs if the load average is greater than N\n"
@@ -94,7 +99,7 @@
 "  -t TOOL  run a subtool\n"
 "    use '-t list' to list subtools.\n"
 "    terminates toplevel options; further flags are passed to the tool.\n",
-          config.parallelism);
+          kVersion, config.parallelism);
 }
 
 /// Choose a default value for the -j (parallelism) flag.
@@ -641,7 +646,7 @@
 
   int opt;
   while (tool.empty() &&
-         (opt = getopt_long(argc, argv, "d:f:hj:k:l:nt:vC:", kLongOptions,
+         (opt = getopt_long(argc, argv, "d:f:hj:k:l:nt:vC:V", kLongOptions,
                             NULL)) != -1) {
     switch (opt) {
       case 'd':
@@ -686,6 +691,9 @@
       case 'C':
         working_dir = optarg;
         break;
+      case 'V':
+        printf("%s\n", kVersion);
+        return 0;
       case 'h':
       default:
         Usage(globals.config);