X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-rev-parse.c;h=8d78b69c902a99738cfc337222ba71493ff45370;hb=620e729dd3625f3329e9cb50a1175648b5672653;hp=d53deaa3691c7b57e215f3f33c44881c4f397527;hpb=302da67472e322109e6299d38dd1a2c30bde9f4c;p=git.git diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c index d53deaa36..8d78b69c9 100644 --- a/builtin-rev-parse.c +++ b/builtin-rev-parse.c @@ -233,7 +233,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) } continue; } - if (!strncmp(arg,"-n",2)) { + if (!prefixcmp(arg, "-n")) { if ((filter & DO_FLAGS) && (filter & DO_REVS)) show(arg); continue; @@ -274,7 +274,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(arg, "--short") || - !strncmp(arg, "--short=", 8)) { + !prefixcmp(arg, "--short=")) { filter &= ~(DO_FLAGS|DO_NOREV); verify = 1; abbrev = DEFAULT_ABBREV; @@ -321,6 +321,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) } if (!strcmp(arg, "--show-cdup")) { const char *pfx = prefix; + if (!is_inside_work_tree()) { + const char *work_tree = + get_git_work_tree(); + if (work_tree) + printf("%s\n", work_tree); + continue; + } while (pfx) { pfx = strchr(pfx, '/'); if (pfx) { @@ -352,19 +359,29 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) : "false"); continue; } - if (!strncmp(arg, "--since=", 8)) { + if (!strcmp(arg, "--is-inside-work-tree")) { + printf("%s\n", is_inside_work_tree() ? "true" + : "false"); + continue; + } + if (!strcmp(arg, "--is-bare-repository")) { + printf("%s\n", is_bare_repository() ? "true" + : "false"); + continue; + } + if (!prefixcmp(arg, "--since=")) { show_datestring("--max-age=", arg+8); continue; } - if (!strncmp(arg, "--after=", 8)) { + if (!prefixcmp(arg, "--after=")) { show_datestring("--max-age=", arg+8); continue; } - if (!strncmp(arg, "--before=", 9)) { + if (!prefixcmp(arg, "--before=")) { show_datestring("--min-age=", arg+9); continue; } - if (!strncmp(arg, "--until=", 8)) { + if (!prefixcmp(arg, "--until=")) { show_datestring("--min-age=", arg+8); continue; }