Merge branch 'js/use-bug-macro'
authorJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 05:04:07 +0000 (14:04 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 05:04:07 +0000 (14:04 +0900)
Developer support update, by using BUG() macro instead of die() to
mark codepaths that should not happen more clearly.

* js/use-bug-macro:
BUG_exit_code: fix sparse "symbol not declared" warning
Convert remaining die*(BUG) messages
Replace all die("BUG: ...") calls by BUG() ones
run-command: use BUG() to report bugs, not die()
test-tool: help verifying BUG() code paths

39 files changed:
1  2 
apply.c
archive-tar.c
blame.c
builtin/branch.c
builtin/cat-file.c
builtin/clone.c
builtin/commit.c
builtin/config.c
builtin/fast-export.c
builtin/index-pack.c
builtin/pack-objects.c
builtin/pull.c
builtin/receive-pack.c
builtin/update-index.c
bulk-checkin.c
color.c
config.c
diff.c
git-compat-util.h
http.c
merge-recursive.c
notes-merge.c
pack-bitmap-write.c
pack-bitmap.c
pack-objects.c
packfile.c
pkt-line.c
ref-filter.c
refs.c
refs/files-backend.c
remote.c
revision.c
sha1-name.c
shallow.c
strbuf.c
submodule.c
transport.c
unpack-trees.c
wt-status.c
diff --cc apply.c
Simple merge
diff --cc archive-tar.c
Simple merge
diff --cc blame.c
Simple merge
Simple merge
Simple merge
diff --cc builtin/clone.c
Simple merge
Simple merge
index 69e7270356c5a4da8372201ac80ec0d33e8909c2,c4f20332d7428fbe3358e927b67e8aa4283d1bf2..1e31aa9f8d98ffa6790ba2c6023634841b1abf74
@@@ -383,22 -308,8 +383,22 @@@ static char *normalize_value(const cha
                else
                        return xstrdup(v ? "true" : "false");
        }
 +      if (type == TYPE_COLOR) {
 +              char v[COLOR_MAXLEN];
 +              if (git_config_color(v, key, value))
 +                      die("cannot parse color '%s'", value);
 +
 +              /*
 +               * The contents of `v` now contain an ANSI escape
 +               * sequence, not suitable for including within a
 +               * configuration file. Treat the above as a
 +               * "sanity-check", and return the given value, which we
 +               * know is representable as valid color code.
 +               */
 +              return xstrdup(value);
 +      }
  
-       die("BUG: cannot normalize type %d", type);
 -      BUG("cannot normalize type %d", types);
++      BUG("cannot normalize type %d", type);
  }
  
  static int get_color_found;
Simple merge
Simple merge
Simple merge
diff --cc builtin/pull.c
Simple merge
Simple merge
Simple merge
diff --cc bulk-checkin.c
Simple merge
diff --cc color.c
Simple merge
diff --cc config.c
Simple merge
diff --cc diff.c
Simple merge
Simple merge
diff --cc http.c
Simple merge
index 8d96e94bd5911376bec5df3fecb1ab502691060a,6409d0770f2fc1dd34dcb5117ae8575d858d8f23..e64b4b9d031afff282bf37c7c373d29e11157835
@@@ -1166,12 -1060,9 +1166,12 @@@ static int merge_file_1(struct merge_op
                                break;
                        }
                } else
-                       die("BUG: unsupported object type in the tree");
+                       BUG("unsupported object type in the tree");
        }
  
 +      if (result->merge)
 +              output(o, 2, _("Auto-merging %s"), filename);
 +
        return 0;
  }
  
diff --cc notes-merge.c
Simple merge
Simple merge
diff --cc pack-bitmap.c
Simple merge
diff --cc pack-objects.c
Simple merge
diff --cc packfile.c
Simple merge
diff --cc pkt-line.c
Simple merge
diff --cc ref-filter.c
Simple merge
diff --cc refs.c
Simple merge
Simple merge
diff --cc remote.c
Simple merge
diff --cc revision.c
index 4e0e193e57e0d1360c52ae566770df61677e554e,67f8e74cbb362c18badf67e42685830ba9dceed7..dc756918e89ba5f6114f716881dbe46166e407bc
@@@ -2174,10 -2173,10 +2174,10 @@@ static int handle_revision_pseudo_opt(c
                 * supported right now, so stick to single worktree.
                 */
                if (!revs->single_worktree)
-                       die("BUG: --single-worktree cannot be used together with submodule");
+                       BUG("--single-worktree cannot be used together with submodule");
                refs = get_submodule_ref_store(submodule);
        } else
 -              refs = get_main_ref_store();
 +              refs = get_main_ref_store(the_repository);
  
        /*
         * NOTE!
diff --cc sha1-name.c
Simple merge
diff --cc shallow.c
Simple merge
diff --cc strbuf.c
Simple merge
diff --cc submodule.c
index 8fd8e5d178d4d6a8d7cf4fb465d96bb323fd02ee,c282fa8fe51601c2a877d121a5b2491bbb3f1620..eb08cf0782ad13d2629c54b8154f4afe78bd0650
@@@ -1606,10 -1604,10 +1606,10 @@@ int submodule_move_head(const char *pat
        if (old_head && !is_submodule_populated_gently(path, error_code_ptr))
                return 0;
  
 -      sub = submodule_from_path(&null_oid, path);
 +      sub = submodule_from_path(the_repository, &null_oid, path);
  
        if (!sub)
-               die("BUG: could not get submodule information for '%s'", path);
+               BUG("could not get submodule information for '%s'", path);
  
        if (old_head && !(flags & SUBMODULE_MOVE_HEAD_FORCE)) {
                /* Check if the submodule has a dirty index. */
diff --cc transport.c
Simple merge
diff --cc unpack-trees.c
Simple merge
diff --cc wt-status.c
Simple merge