summaryrefslogtreecommitdiff
path: root/git-bisect.sh
diff options
context:
space:
mode:
authorPranit Bauva <pranit.bauva@gmail.com>2019-01-02 15:38:32 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-01-02 18:23:02 (GMT)
commit0f30233a11f6d89fb387ddf96db64877adb90713 (patch)
treec7076e59bdbe3b223f3a6bd8af9ea8140b94d13b /git-bisect.sh
parent5e82c3dd22aa804ba0ae571bf903b387b0f766a6 (diff)
downloadgit-0f30233a11f6d89fb387ddf96db64877adb90713.zip
git-0f30233a11f6d89fb387ddf96db64877adb90713.tar.gz
git-0f30233a11f6d89fb387ddf96db64877adb90713.tar.bz2
bisect--helper: `bisect_write` shell function in C
Reimplement the `bisect_write` shell function in C and add a `bisect-write` subcommand to `git bisect--helper` to call it from git-bisect.sh Using `--bisect-write` subcommand is a temporary measure to port shell function in C so as to use the existing test suite. As more functions are ported, this subcommand will be retired but its implementation will be called by some other methods. Note: bisect_write() uses two variables namely TERM_GOOD and TERM_BAD from the global shell script thus we need to pass it to the subcommand using the arguments. We then store them in a struct bisect_terms and pass the memory address around functions. Add a log_commit() helper function to write the contents of the commit message header to a file which will be re-used in future parts of the code as well. Also introduce a function free_terms() to free the memory of `struct bisect_terms` and set_terms() to set the values of members in `struct bisect_terms`. Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Mentored-by: Lars Schneider <larsxschneider@gmail.com> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-bisect.sh')
-rwxr-xr-xgit-bisect.sh25
1 files changed, 4 insertions, 21 deletions
diff --git a/git-bisect.sh b/git-bisect.sh
index afbfbc1..ebf4452 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -144,7 +144,7 @@ bisect_start() {
0) state=$TERM_BAD ; bad_seen=1 ;;
*) state=$TERM_GOOD ;;
esac
- eval="$eval bisect_write '$state' '$rev' 'nolog' &&"
+ eval="$eval git bisect--helper --bisect-write '$state' '$rev' '$TERM_GOOD' '$TERM_BAD' 'nolog' &&"
done
#
# Verify HEAD.
@@ -220,23 +220,6 @@ bisect_start() {
trap '-' 0
}
-bisect_write() {
- state="$1"
- rev="$2"
- nolog="$3"
- case "$state" in
- "$TERM_BAD")
- tag="$state" ;;
- "$TERM_GOOD"|skip)
- tag="$state"-"$rev" ;;
- *)
- die "$(eval_gettext "Bad bisect_write argument: \$state")" ;;
- esac
- git update-ref "refs/bisect/$tag" "$rev" || exit
- echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG"
- test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
-}
-
bisect_skip() {
all=''
for arg in "$@"
@@ -263,7 +246,7 @@ bisect_state() {
bisected_head=$(bisect_head)
rev=$(git rev-parse --verify "$bisected_head") ||
die "$(eval_gettext "Bad rev input: \$bisected_head")"
- bisect_write "$state" "$rev"
+ git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit
git bisect--helper --check-expected-revs "$rev" ;;
2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip)
shift
@@ -276,7 +259,7 @@ bisect_state() {
done
for rev in $hash_list
do
- bisect_write "$state" "$rev"
+ git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit
done
git bisect--helper --check-expected-revs $hash_list ;;
*,"$TERM_BAD")
@@ -413,7 +396,7 @@ bisect_replay () {
cmd="bisect_start $rev"
eval "$cmd" ;;
"$TERM_GOOD"|"$TERM_BAD"|skip)
- bisect_write "$command" "$rev" ;;
+ git bisect--helper --bisect-write "$command" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit;;
terms)
bisect_terms $rev ;;
*)