Merge branch 'ad/bisect-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2015 21:09:53 +0000 (14:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 12 Aug 2015 21:09:53 +0000 (14:09 -0700)
Code and documentation clean-up to "git bisect".

* ad/bisect-cleanup:
bisect: don't mix option parsing and non-trivial code
bisect: simplify the addition of new bisect terms
bisect: replace hardcoded "bad|good" by variables
Documentation/bisect: revise overall content
Documentation/bisect: move getting help section to the end
bisect: correction of typo

1  2 
revision.c
diff --combined revision.c
index cf60c5d8178200aaaf72d37a174d837afd9ff228,60a6f7c884eced51251a41e865a89886810bffa5..5350139599d7d9fe542423ab9042962b75821dae
  #include "commit-slab.h"
  #include "dir.h"
  #include "cache-tree.h"
+ #include "bisect.h"
  
  volatile show_early_output_fn_t show_early_output;
  
+ static const char *term_bad;
+ static const char *term_good;
  char *path_name(const struct name_path *path, const char *name)
  {
        const struct name_path *p;
@@@ -361,8 -365,8 +365,8 @@@ static int everybody_uninteresting(stru
                list = list->next;
                if (commit->object.flags & UNINTERESTING)
                        continue;
 -              if (interesting_cache)
 -                      *interesting_cache = commit;
 +
 +              *interesting_cache = commit;
                return 0;
        }
        return 1;
@@@ -1996,10 -2000,10 +2000,10 @@@ static int handle_revision_opt(struct r
        } else if (!strcmp(arg, "--full-history")) {
                revs->simplify_history = 0;
        } else if (!strcmp(arg, "--relative-date")) {
 -              revs->date_mode = DATE_RELATIVE;
 +              revs->date_mode.type = DATE_RELATIVE;
                revs->date_mode_explicit = 1;
        } else if ((argcount = parse_long_opt("date", argv, &optarg))) {
 -              revs->date_mode = parse_date_format(optarg);
 +              parse_date_format(optarg, &revs->date_mode);
                revs->date_mode_explicit = 1;
                return argcount;
        } else if (!strcmp(arg, "--log-size")) {
@@@ -2076,14 -2080,23 +2080,23 @@@ void parse_revision_opt(struct rev_inf
        ctx->argc -= n;
  }
  
+ static int for_each_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data, const char *term) {
+       struct strbuf bisect_refs = STRBUF_INIT;
+       int status;
+       strbuf_addf(&bisect_refs, "refs/bisect/%s", term);
+       status = for_each_ref_in_submodule(submodule, bisect_refs.buf, fn, cb_data);
+       strbuf_release(&bisect_refs);
+       return status;
+ }
  static int for_each_bad_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data)
  {
-       return for_each_ref_in_submodule(submodule, "refs/bisect/bad", fn, cb_data);
+       return for_each_bisect_ref(submodule, fn, cb_data, term_bad);
  }
  
  static int for_each_good_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data)
  {
-       return for_each_ref_in_submodule(submodule, "refs/bisect/good", fn, cb_data);
+       return for_each_bisect_ref(submodule, fn, cb_data, term_good);
  }
  
  static int handle_revision_pseudo_opt(const char *submodule,
                handle_refs(submodule, revs, *flags, for_each_branch_ref_submodule);
                clear_ref_exclusion(&revs->ref_excludes);
        } else if (!strcmp(arg, "--bisect")) {
+               read_bisect_terms(&term_bad, &term_good);
                handle_refs(submodule, revs, *flags, for_each_bad_bisect_ref);
                handle_refs(submodule, revs, *flags ^ (UNINTERESTING | BOTTOM), for_each_good_bisect_ref);
                revs->bisect = 1;