send-pack/receive-pack: allow errors to be reported back to pusher.
[gitweb.git] / rev-parse.c
index 507b531dce781133946da04cb27fa2ff6d3832a9..0c951af0d49da459fc6c85c32707b016bf581a57 100644 (file)
@@ -32,7 +32,9 @@ static int revs_count = 0;
 static int is_rev_argument(const char *arg)
 {
        static const char *rev_args[] = {
+               "--all",
                "--bisect",
+               "--dense",
                "--header",
                "--max-age=",
                "--max-count=",
@@ -43,6 +45,7 @@ static int is_rev_argument(const char *arg)
                "--parents",
                "--pretty",
                "--show-breaks",
+               "--sparse",
                "--topo-order",
                "--unpacked",
                NULL
@@ -128,28 +131,22 @@ static int show_reference(const char *refname, const unsigned char *sha1)
 
 static void show_datestring(const char *flag, const char *datestr)
 {
-       FILE *date;
        static char buffer[100];
-       static char cmd[1000];
-       int len;
 
        /* date handling requires both flags and revs */
        if ((filter & (DO_FLAGS | DO_REVS)) != (DO_FLAGS | DO_REVS))
                return;
-       len = strlen(flag);
-       memcpy(buffer, flag, len);
-
-       snprintf(cmd, sizeof(cmd), "date --date=%s +%%s", sq_quote(datestr));
-       date = popen(cmd, "r");
-       if (!date || !fgets(buffer + len, sizeof(buffer) - len, date))
-               die("git-rev-list: bad date string");
-       pclose(date);
-       len = strlen(buffer);
-       if (buffer[len-1] == '\n')
-               buffer[--len] = 0;
+       snprintf(buffer, sizeof(buffer), "%s%lu", flag, approxidate(datestr));
        show(buffer);
 }
 
+static void show_file(const char *arg)
+{
+       show_default();
+       if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
+               show(arg);
+}
+
 int main(int argc, char **argv)
 {
        int i, as_is = 0, verify = 0;
@@ -161,12 +158,15 @@ int main(int argc, char **argv)
                char *dotdot;
        
                if (as_is) {
-                       show(arg);
+                       show_file(arg);
                        continue;
                }
                if (*arg == '-') {
                        if (!strcmp(arg, "--")) {
                                as_is = 1;
+                               /* Pass on the "--" if we show anything but files.. */
+                               if (filter & (DO_FLAGS | DO_REVS))
+                                       show_file(arg);
                                continue;
                        }
                        if (!strcmp(arg, "--default")) {
@@ -216,6 +216,18 @@ int main(int argc, char **argv)
                                        puts(prefix);
                                continue;
                        }
+                       if (!strcmp(arg, "--show-cdup")) {
+                               const char *pfx = prefix;
+                               while (pfx) {
+                                       pfx = strchr(pfx, '/');
+                                       if (pfx) {
+                                               pfx++;
+                                               printf("../");
+                                       }
+                               }
+                               putchar('\n');
+                               continue;
+                       }
                        if (!strcmp(arg, "--git-dir")) {
                                const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
                                static char cwd[PATH_MAX];
@@ -281,9 +293,8 @@ int main(int argc, char **argv)
                }
                if (verify)
                        die("Needed a single revision");
-               if ((filter & (DO_NONFLAGS|DO_NOREV)) ==
-                   (DO_NONFLAGS|DO_NOREV))
-                       show(arg);
+               as_is = 1;
+               show_file(arg);
        }
        show_default();
        if (verify && revs_count != 1)