# [PATCH 4/7] Bisect: factorise "bisect_write_*" functions.

5 messages from 2007-10-14 to 2007-10-24. Participants: Christian Couder, Junio C Hamano, J. Bruce Fields, Andreas Ericsson.
Thread: https://gitlist.dev/t/10278

## Christian Couder, 2007-10-14 12:29

Subject: [PATCH 4/7] Bisect: factorise "bisect_write_*" functions.
Message-ID: <20071014142938.d722299c.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/20071014142938.d722299c.chriscool%40tuxfamily.org

```
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 git-bisect.sh |   46 ++++++++++++++++++++--------------------------
 1 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/git-bisect.sh b/git-bisect.sh
index 94534e6..847250c 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -108,9 +108,9 @@ bisect_start() {
 		}
 		if [ $bad_seen -eq 0 ]; then
 		    bad_seen=1
-		    bisect_write_bad "$rev"
+		    bisect_write 'bad' "$rev"
 		else
-		    bisect_write_good "$rev"
+		    bisect_write 'good' "$rev"
 		fi
 		shift
 		;;
@@ -122,6 +122,18 @@ bisect_start() {
 	bisect_auto_next
 }
 
+bisect_write() {
+	state="$1"
+	rev="$2"
+	case "$state" in
+		bad)		tag="$state" ;;
+		good|dunno)	tag="$state"-"$rev" ;;
+		*)		die "Bad bisect_write argument: $state" ;;
+	esac
+	echo "$rev" >"$GIT_DIR/refs/bisect/$tag"
+	echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
+}
+
 bisect_bad() {
 	bisect_autostart
 	case "$#" in
@@ -132,17 +144,11 @@ bisect_bad() {
 	*)
 		usage ;;
 	esac || exit
-	bisect_write_bad "$rev"
+	bisect_write 'bad' "$rev"
 	echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
 	bisect_auto_next
 }
 
-bisect_write_bad() {
-	rev="$1"
-	echo "$rev" >"$GIT_DIR/refs/bisect/bad"
-	echo "# bad: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
-}
-
 bisect_good() {
 	bisect_autostart
 	case "$#" in
@@ -153,18 +159,12 @@ bisect_good() {
 	for rev in $revs
 	do
 		rev=$(git rev-parse --verify "$rev^{commit}") || exit
-		bisect_write_good "$rev"
+		bisect_write 'good' "$rev"
 		echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
 	done
 	bisect_auto_next
 }
 
-bisect_write_good() {
-	rev="$1"
-	echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"
-	echo "# good: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
-}
-
 bisect_dunno() {
 	bisect_autostart
 	case "$#" in
@@ -175,18 +175,12 @@ bisect_dunno() {
 	for rev in $revs
 	do
 		rev=$(git rev-parse --verify "$rev^{commit}") || exit
-		bisect_write_dunno "$rev"
+		bisect_write 'dunno' "$rev"
 		echo "git-bisect dunno $rev" >>"$GIT_DIR/BISECT_LOG"
 	done
 	bisect_auto_next
 }
 
-bisect_write_dunno() {
-	rev="$1"
-	echo "$rev" >"$GIT_DIR/refs/bisect/dunno-$rev"
-	echo "# dunno: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG"
-}
-
 bisect_next_check() {
 	missing_good= missing_bad=
 	git show-ref -q --verify refs/bisect/bad || missing_bad=t
@@ -395,15 +389,15 @@ bisect_replay () {
 			eval "$cmd"
 			;;
 		good)
-			bisect_write_good "$rev"
+			bisect_write 'good' "$rev"
 			echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG"
 			;;
 		bad)
-			bisect_write_bad "$rev"
+			bisect_write 'bad' "$rev"
 			echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG"
 			;;
 		dunno)
-			bisect_write_dunno "$rev"
+			bisect_write 'dunno' "$rev"
 			echo "git-bisect dunno $rev" >>"$GIT_DIR/BISECT_LOG"
 			;;
 		*)
-- 
1.5.3.4.213.g68ad5

```

## Junio C Hamano, 2007-10-23 22:13

Subject: Re: [PATCH 4/7] Bisect: factorise "bisect_write_*" functions.
Message-ID: <7v640x7a4n.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v640x7a4n.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <20071014142938.d722299c.chriscool@tuxfamily.org>

```
Sort of offtopic, but is "factorise" a correct verb here?  I
thought "factorise" is to express a non prime number as the
product of prime numbers.

"refactor" is the act of splitting and merging pieces of
functions for better reuse, isn't it?

```

## J. Bruce Fields, 2007-10-23 22:29

Subject: Re: [PATCH 4/7] Bisect: factorise "bisect_write_*" functions.
Message-ID: <20071023222938.GE1115@fieldses.org>
URL: https://gitlist.dev/e/20071023222938.GE1115%40fieldses.org
In-Reply-To: <7v640x7a4n.fsf@gitster.siamese.dyndns.org>

```
On Tue, Oct 23, 2007 at 03:13:12PM -0700, Junio C Hamano wrote:
> Sort of offtopic, but is "factorise" a correct verb here?  I
> thought "factorise" is to express a non prime number as the
> product of prime numbers.

"Factor" is a perfectly good verb on its own, no need for the "ise"
normally.

--b.

```

## Andreas Ericsson, 2007-10-23 22:36

Subject: Re: [PATCH 4/7] Bisect: factorise "bisect_write_*" functions.
Message-ID: <471E7766.6000303@op5.se>
URL: https://gitlist.dev/e/471E7766.6000303%40op5.se
In-Reply-To: <7v640x7a4n.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano wrote:
> Sort of offtopic, but is "factorise" a correct verb here?  I
> thought "factorise" is to express a non prime number as the
> product of prime numbers.
> 

It's the reverse of expanding brackets, like so:
2x² + x - 3 = (2x + 3)(x - 1)

> "refactor" is the act of splitting and merging pieces of
> functions for better reuse, isn't it?
> 

Yes.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

```

## Christian Couder, 2007-10-24 04:09

Subject: Re: [PATCH 4/7] Bisect: factorise "bisect_write_*" functions.
Message-ID: <200710240609.54597.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/200710240609.54597.chriscool%40tuxfamily.org
In-Reply-To: <7v640x7a4n.fsf@gitster.siamese.dyndns.org>

```
Le mercredi 24 octobre 2007, Junio C Hamano a écrit :
> Sort of offtopic, but is "factorise" a correct verb here?  I
> thought "factorise" is to express a non prime number as the
> product of prime numbers.

English is not my mother tongue so I very often make mistakes.
Sorry about that.

Anyway my prefered online dictionary finds it:

http://www.wordreference.com/definition/factorise

> "refactor" is the act of splitting and merging pieces of
> functions for better reuse, isn't it?

Yes, it would be better.

I used "factorise" because as a french native speaker, I am always tempted 
to use word that sound the same as their french translation.

By the way I realised that the "bisect_write" function is still 
missing 'nolog="$3"', so I will send an updated patch.

Thanks,
Christian.

```
