X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=rev-parse.c;h=169d0cc9b5a5769ad90e1f76039f14bf051a39dc;hb=1bd8c8f00b1c7facb67c99047fe777b53f2c49ff;hp=0f5630f95c4dc9ac257ea6c3b2f0e178af667ae5;hpb=727132834e6be48a93c1bd6458a29d474ce7d5d5;p=git.git diff --git a/rev-parse.c b/rev-parse.c index 0f5630f9..169d0cc9 100644 --- a/rev-parse.c +++ b/rev-parse.c @@ -6,6 +6,7 @@ #include "cache.h" #include "commit.h" #include "refs.h" +#include "quote.h" #define DO_REVS 1 #define DO_NOREV 2 @@ -31,6 +32,7 @@ static int revs_count = 0; static int is_rev_argument(const char *arg) { static const char *rev_args[] = { + "--all", "--bisect", "--header", "--max-age=", @@ -125,6 +127,37 @@ static int show_reference(const char *refname, const unsigned char *sha1) return 0; } +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; + 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; @@ -136,12 +169,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")) { @@ -207,6 +243,22 @@ int main(int argc, char **argv) printf("%s/.git\n", cwd); continue; } + if (!strncmp(arg, "--since=", 8)) { + show_datestring("--max-age=", arg+8); + continue; + } + if (!strncmp(arg, "--after=", 8)) { + show_datestring("--max-age=", arg+8); + continue; + } + if (!strncmp(arg, "--before=", 9)) { + show_datestring("--min-age=", arg+9); + continue; + } + if (!strncmp(arg, "--until=", 8)) { + show_datestring("--min-age=", arg+8); + continue; + } if (verify) die("Needed a single revision"); show_flag(arg); @@ -240,9 +292,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)