threads / patch / 10278

patch, 7 partsBisect: factorise "bisect_write_*" functions.

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

## tl;dr

5 messages between Oct 14, 2007 and Oct 24, 2007. Diffs are folded; open one to read it.

replies: 4people: 4as markdown or json

Christian Couder· Oct 14, 2007, 12:29 UTC · lore
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 git-bisect.sh |   46 ++++++++++++++++++++--------------------------
 1 files changed, 20 insertions(+), 26 deletions(-)
Show changes to git-bisect.sh +20 −26
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· Oct 23, 2007, 22:13 UTC · re: Christian Couder · lore

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

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· Oct 23, 2007, 22:29 UTC · re: Junio C Hamano · lore

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

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· Oct 23, 2007, 22:36 UTC · re: Junio C Hamano · lore

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

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· Oct 24, 2007, 04:09 UTC · re: Junio C Hamano · lore

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

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.

← back to recent threads