Merge branch 'cc/maint-bisect-paths'
authorJunio C Hamano <gitster@pobox.com>
Mon, 1 Mar 2010 09:09:21 +0000 (01:09 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Mar 2010 09:09:21 +0000 (01:09 -0800)
* cc/maint-bisect-paths:
bisect: error out when passing bad path parameters

1  2 
bisect.c
t/t6030-bisect-porcelain.sh
diff --combined bisect.c
index 6dc27ee7a6090e56d5b0f2072a72553d3b3e3b87,88881f7b6ed7a69498561912dbf4934697c17e4b..b556b11610480afd80cddd86a81af9737254ee36
+++ b/bisect.c
@@@ -593,7 -593,7 +593,7 @@@ struct commit_list *filter_skipped(stru
   * is increased by one between each call, but that should not matter
   * for this application.
   */
 -int get_prn(int count) {
 +static int get_prn(int count) {
        count = count * 1103515245 + 12345;
        return ((unsigned)(count/65536) % PRN_MODULO);
  }
@@@ -813,11 -813,11 +813,11 @@@ static void handle_skipped_merge_base(c
        char *bad_hex = sha1_to_hex(current_bad_sha1);
        char *good_hex = join_sha1_array_hex(&good_revs, ' ');
  
 -      fprintf(stderr, "Warning: the merge base between %s and [%s] "
 +      warning("the merge base between %s and [%s] "
                "must be skipped.\n"
                "So we cannot be sure the first bad commit is "
                "between %s and %s.\n"
 -              "We continue anyway.\n",
 +              "We continue anyway.",
                bad_hex, good_hex, mb_hex, bad_hex);
        free(good_hex);
  }
@@@ -956,7 -956,7 +956,7 @@@ int bisect_next_all(const char *prefix
  {
        struct rev_info revs;
        struct commit_list *tried;
 -      int reaches = 0, all = 0, nr;
 +      int reaches = 0, all = 0, nr, steps;
        const unsigned char *bisect_rev;
        char bisect_rev_hex[41];
  
                exit(1);
        }
  
+       if (!all) {
+               fprintf(stderr, "No testable commit found.\n"
+                       "Maybe you started with bad path parameters?\n");
+               exit(4);
+       }
        bisect_rev = revs.commits->item->object.sha1;
        memcpy(bisect_rev_hex, sha1_to_hex(bisect_rev), 41);
  
        }
  
        nr = all - reaches - 1;
 -      printf("Bisecting: %d revisions left to test after this "
 -             "(roughly %d steps)\n", nr, estimate_bisect_steps(all));
 +      steps = estimate_bisect_steps(all);
 +      printf("Bisecting: %d revision%s left to test after this "
 +             "(roughly %d step%s)\n", nr, (nr == 1 ? "" : "s"),
 +             steps, (steps == 1 ? "" : "s"));
  
        return bisect_checkout(bisect_rev_hex);
  }
index c51865fdbc0a6fd98cca4a4accd35b302e5fd739,dc9e8d030a6e803ac5a022e4f0685016879edaf0..3b042aacd63f77651fdaf3d10b65f4fc85669a75
@@@ -423,7 -423,7 +423,7 @@@ test_expect_success 'skipped merge bas
        grep "merge base must be tested" my_bisect_log.txt &&
        grep $HASH4 my_bisect_log.txt &&
        git bisect skip > my_bisect_log.txt 2>&1 &&
 -      grep "Warning" my_bisect_log.txt &&
 +      grep "warning" my_bisect_log.txt &&
        grep $SIDE_HASH6 my_bisect_log.txt &&
        git bisect reset
  '
@@@ -567,6 -567,11 +567,11 @@@ test_expect_success 'skipping away fro
        test "$para3" = "$PARA_HASH3"
  '
  
+ test_expect_success 'erroring out when using bad path parameters' '
+       test_must_fail git bisect start $PARA_HASH7 $HASH1 -- foobar 2> error.txt &&
+       grep "bad path parameters" error.txt
+ '
  #
  #
  test_done