Merge branch 'ow/rev-parse-is-shallow-repo'
authorJunio C Hamano <gitster@pobox.com>
Mon, 25 Sep 2017 06:24:10 +0000 (15:24 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Sep 2017 06:24:10 +0000 (15:24 +0900)
"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

1  2 
builtin/rev-parse.c
diff --combined builtin/rev-parse.c
index 9f24004c0a310d22808c86ab6ee65e6b296fe70c,44e9a48e02363db902ac7358251c0098f396ce6e..b9c13d3d9df6cf5f90e990d181e268f698ac93e4
@@@ -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;
        }
@@@ -702,7 -702,7 +702,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)) {
                                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)) {
                                                : "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"));
                        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