From: Junio C Hamano Date: Sun, 24 Sep 2017 10:39:41 +0000 (+0900) Subject: Merge branch 'ow/rev-parse-is-shallow-repo' into next X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/8f1b915908484d7ab7218da327e3db11d0eb4c3a?hp=-c Merge branch 'ow/rev-parse-is-shallow-repo' into next "git rev-parse" learned "--is-shallow-repository", that is to be used in a way similar to existing "--is-bare-repository" and friends. * ow/rev-parse-is-shallow-repo: rev-parse: rev-parse: add --is-shallow-repository --- 8f1b915908484d7ab7218da327e3db11d0eb4c3a diff --combined builtin/rev-parse.c index 37f4209c24,44e9a48e02..a8d7e6f7ae --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@@ -274,7 -274,7 +274,7 @@@ static int try_difference(const char *a return 0; } - if (!get_sha1_committish(this, oid.hash) && !get_sha1_committish(next, end.hash)) { + if (!get_oid_committish(this, &oid) && !get_oid_committish(next, &end)) { show_rev(NORMAL, &end, next); show_rev(symmetric ? NORMAL : REVERSED, &oid, this); if (symmetric) { @@@ -328,7 -328,7 +328,7 @@@ static int try_parent_shorthands(const return 0; *dotdot = 0; - if (get_sha1_committish(arg, oid.hash)) { + if (get_oid_committish(arg, &oid)) { *dotdot = '^'; return 0; } @@@ -387,14 -387,6 +387,14 @@@ static const char *skipspaces(const cha return s; } +static char *findspace(const char *s) +{ + for (; *s; s++) + if (isspace(*s)) + return (char*)s; + return NULL; +} + static int cmd_parseopt(int argc, const char **argv, const char *prefix) { static int keep_dashdash = 0, stop_at_non_option = 0; @@@ -442,7 -434,7 +442,7 @@@ /* parse: (|,|)[*=?!]*? SP+ */ while (strbuf_getline(&sb, stdin) != EOF) { const char *s; - const char *help; + char *help; struct option *o; if (!sb.len) @@@ -452,17 -444,15 +452,17 @@@ memset(opts + onb, 0, sizeof(opts[onb])); o = &opts[onb++]; - help = strchr(sb.buf, ' '); - if (!help || *sb.buf == ' ') { + help = findspace(sb.buf); + if (!help || sb.buf == help) { o->type = OPTION_GROUP; o->help = xstrdup(skipspaces(sb.buf)); continue; } + *help = '\0'; + o->type = OPTION_CALLBACK; - o->help = xstrdup(skipspaces(help)); + o->help = xstrdup(skipspaces(help+1)); o->value = &parsed; o->flags = PARSE_OPT_NOARG; o->callback = &parseopt_dump; @@@ -712,7 -702,7 +712,7 @@@ int cmd_rev_parse(int argc, const char } if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) { quiet = 1; - flags |= GET_SHA1_QUIETLY; + flags |= GET_OID_QUIETLY; continue; } if (opt_with_value(arg, "--short", &arg)) { @@@ -767,8 -757,8 +767,8 @@@ continue; } if (!strcmp(arg, "--bisect")) { - for_each_ref_in("refs/bisect/bad", show_reference, NULL); - for_each_ref_in("refs/bisect/good", anti_reference, NULL); + for_each_fullref_in("refs/bisect/bad", show_reference, NULL, 0); + for_each_fullref_in("refs/bisect/good", anti_reference, NULL, 0); continue; } if (opt_with_value(arg, "--branches", &arg)) { @@@ -878,6 -868,11 +878,11 @@@ : "false"); continue; } + if (!strcmp(arg, "--is-shallow-repository")) { + printf("%s\n", is_repository_shallow() ? "true" + : "false"); + continue; + } if (!strcmp(arg, "--shared-index-path")) { if (read_cache() < 0) die(_("Could not read the index")); @@@ -921,7 -916,7 +926,7 @@@ name++; type = REVERSED; } - if (!get_sha1_with_context(name, flags, oid.hash, &unused)) { + if (!get_oid_with_context(name, flags, &oid, &unused)) { if (verify) revs_count++; else