* [PATCH 2/2] bisect--helper: string output variables together with "&&"
@ 2009-03-30 4:59 Christian Couder
0 siblings, 0 replies; 3+ messages in thread
From: Christian Couder @ 2009-03-30 4:59 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell, Johannes Schindelin
When doing:
eval "git bisect--helper --next-vars" | {
while read line
do
echo "$line &&"
done
echo ':'
}
the result code comes from the last "echo ':'", not from running
"git bisect--helper --next-vars".
This patch get rid of the need to string the line from the output
of "git bisect--helper" by making "git bisect--helper --next-vars"
return output variables stringed together with "&&".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 3 ++-
bisect.h | 1 +
builtin-rev-list.c | 29 +++++++++++++++++++----------
git-bisect.sh | 15 +--------------
4 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/bisect.c b/bisect.c
index 64a5ad5..df0ab4d 100644
--- a/bisect.c
+++ b/bisect.c
@@ -554,5 +554,6 @@ int bisect_next_vars(const char *prefix)
revs.commits = find_bisection(revs.commits, &reaches, &all,
!!skipped_sha1_nr);
- return show_bisect_vars(&revs, reaches, all, SHOW_TRIED);
+ return show_bisect_vars(&revs, reaches, all,
+ SHOW_TRIED | SHOW_STRINGED);
}
diff --git a/bisect.h b/bisect.h
index 4cff2ba..2e4b2af 100644
--- a/bisect.h
+++ b/bisect.h
@@ -12,6 +12,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,
/* show_bisect_vars flags */
#define SHOW_ALL 1
#define SHOW_TRIED 2
+#define SHOW_STRINGED 4
/*
* The flag SHOW_ALL should not be set if this function is called
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index c1c4a18..330f7f0 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -226,20 +226,20 @@ static int estimate_bisect_steps(int all)
return (e < 3 * x) ? n : n - 1;
}
-static void show_tried_revs(struct commit_list *tried)
+static void show_tried_revs(struct commit_list *tried, int stringed)
{
printf("bisect_tried='");
for (;tried; tried = tried->next) {
char *format = tried->next ? "%s|" : "%s";
printf(format, sha1_to_hex(tried->item->object.sha1));
}
- printf("'\n");
+ printf(stringed ? "' &&\n" : "'\n");
}
int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
{
int cnt;
- char hex[41] = "";
+ char hex[41] = "", *format;
struct commit_list *tried;
if (!revs->commits && !(flags & SHOW_TRIED))
@@ -269,13 +269,22 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
}
if (flags & SHOW_TRIED)
- show_tried_revs(tried);
- printf("bisect_rev=%s\n"
- "bisect_nr=%d\n"
- "bisect_good=%d\n"
- "bisect_bad=%d\n"
- "bisect_all=%d\n"
- "bisect_steps=%d\n",
+ show_tried_revs(tried, flags & SHOW_STRINGED);
+ format = (flags & SHOW_STRINGED) ?
+ "bisect_rev=%s &&\n"
+ "bisect_nr=%d &&\n"
+ "bisect_good=%d &&\n"
+ "bisect_bad=%d &&\n"
+ "bisect_all=%d &&\n"
+ "bisect_steps=%d\n"
+ :
+ "bisect_rev=%s\n"
+ "bisect_nr=%d\n"
+ "bisect_good=%d\n"
+ "bisect_bad=%d\n"
+ "bisect_all=%d\n"
+ "bisect_steps=%d\n";
+ printf(format,
hex,
cnt - 1,
all - reaches - 1,
diff --git a/git-bisect.sh b/git-bisect.sh
index 0f7590d..5074dda 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -279,18 +279,6 @@ bisect_auto_next() {
bisect_next_check && bisect_next || :
}
-eval_and_string_together() {
- _eval="$1"
-
- eval "$_eval" | {
- while read line
- do
- echo "$line &&"
- done
- echo ':'
- }
-}
-
exit_if_skipped_commits () {
_tried=$1
_bad=$2
@@ -429,8 +417,7 @@ bisect_next() {
test "$?" -eq "1" && return
# Get bisection information
- eval="git bisect--helper --next-vars" &&
- eval=$(eval_and_string_together "$eval") &&
+ eval=$(eval "git bisect--helper --next-vars") &&
eval "$eval" || exit
if [ -z "$bisect_rev" ]; then
--
1.6.2.1.404.gb0085.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] bisect--helper: string output variables together with "&&"
2009-03-29 9:55 Christian Couder
@ 2009-03-30 4:18 ` Christian Couder
0 siblings, 0 replies; 3+ messages in thread
From: Christian Couder @ 2009-03-30 4:18 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell, Johannes Schindelin
Le dimanche 29 mars 2009, Christian Couder a écrit :
> -static void show_tried_revs(struct commit_list *tried)
> +static void show_tried_revs(struct commit_list *tried, int stringed)
> {
> + char *last_format = stringed ? "%s &&" : "%s";
> +
> printf("bisect_tried='");
> for (;tried; tried = tried->next) {
> - char *format = tried->next ? "%s|" : "%s";
> + char *format = tried->next ? "%s|" : last_format;
> printf(format, sha1_to_hex(tried->item->object.sha1));
> }
> printf("'\n");
Ooops, sorry, this is wrong I will send an updaed series.
Best regards,
Christian.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] bisect--helper: string output variables together with "&&"
@ 2009-03-29 9:55 Christian Couder
2009-03-30 4:18 ` Christian Couder
0 siblings, 1 reply; 3+ messages in thread
From: Christian Couder @ 2009-03-29 9:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell, Johannes Schindelin
When doing:
eval "git bisect--helper --next-vars" | {
while read line
do
echo "$line &&"
done
echo ':'
}
the result code comes from the last "echo ':'", not from running
"git bisect--helper --next-vars".
This patch get rid of the need to string the line from the output
of "git bisect--helper" by making "git bisect--helper --next-vars"
return output variables stringed together with "&&".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
bisect.c | 3 ++-
bisect.h | 1 +
builtin-rev-list.c | 31 +++++++++++++++++++++----------
git-bisect.sh | 15 +--------------
4 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/bisect.c b/bisect.c
index 64a5ad5..df0ab4d 100644
--- a/bisect.c
+++ b/bisect.c
@@ -554,5 +554,6 @@ int bisect_next_vars(const char *prefix)
revs.commits = find_bisection(revs.commits, &reaches, &all,
!!skipped_sha1_nr);
- return show_bisect_vars(&revs, reaches, all, SHOW_TRIED);
+ return show_bisect_vars(&revs, reaches, all,
+ SHOW_TRIED | SHOW_STRINGED);
}
diff --git a/bisect.h b/bisect.h
index 4cff2ba..2e4b2af 100644
--- a/bisect.h
+++ b/bisect.h
@@ -12,6 +12,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,
/* show_bisect_vars flags */
#define SHOW_ALL 1
#define SHOW_TRIED 2
+#define SHOW_STRINGED 4
/*
* The flag SHOW_ALL should not be set if this function is called
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index c1c4a18..83b2214 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -226,11 +226,13 @@ static int estimate_bisect_steps(int all)
return (e < 3 * x) ? n : n - 1;
}
-static void show_tried_revs(struct commit_list *tried)
+static void show_tried_revs(struct commit_list *tried, int stringed)
{
+ char *last_format = stringed ? "%s &&" : "%s";
+
printf("bisect_tried='");
for (;tried; tried = tried->next) {
- char *format = tried->next ? "%s|" : "%s";
+ char *format = tried->next ? "%s|" : last_format;
printf(format, sha1_to_hex(tried->item->object.sha1));
}
printf("'\n");
@@ -239,7 +241,7 @@ static void show_tried_revs(struct commit_list *tried)
int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
{
int cnt;
- char hex[41] = "";
+ char hex[41] = "", *format;
struct commit_list *tried;
if (!revs->commits && !(flags & SHOW_TRIED))
@@ -269,13 +271,22 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
}
if (flags & SHOW_TRIED)
- show_tried_revs(tried);
- printf("bisect_rev=%s\n"
- "bisect_nr=%d\n"
- "bisect_good=%d\n"
- "bisect_bad=%d\n"
- "bisect_all=%d\n"
- "bisect_steps=%d\n",
+ show_tried_revs(tried, flags & SHOW_STRINGED);
+ format = (flags & SHOW_STRINGED) ?
+ "bisect_rev=%s &&\n"
+ "bisect_nr=%d &&\n"
+ "bisect_good=%d &&\n"
+ "bisect_bad=%d &&\n"
+ "bisect_all=%d &&\n"
+ "bisect_steps=%d\n"
+ :
+ "bisect_rev=%s\n"
+ "bisect_nr=%d\n"
+ "bisect_good=%d\n"
+ "bisect_bad=%d\n"
+ "bisect_all=%d\n"
+ "bisect_steps=%d\n";
+ printf(format,
hex,
cnt - 1,
all - reaches - 1,
diff --git a/git-bisect.sh b/git-bisect.sh
index 0f7590d..5074dda 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -279,18 +279,6 @@ bisect_auto_next() {
bisect_next_check && bisect_next || :
}
-eval_and_string_together() {
- _eval="$1"
-
- eval "$_eval" | {
- while read line
- do
- echo "$line &&"
- done
- echo ':'
- }
-}
-
exit_if_skipped_commits () {
_tried=$1
_bad=$2
@@ -429,8 +417,7 @@ bisect_next() {
test "$?" -eq "1" && return
# Get bisection information
- eval="git bisect--helper --next-vars" &&
- eval=$(eval_and_string_together "$eval") &&
+ eval=$(eval "git bisect--helper --next-vars") &&
eval "$eval" || exit
if [ -z "$bisect_rev" ]; then
--
1.6.2.1.404.gb0085.dirty
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-03-30 5:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-30 4:59 [PATCH 2/2] bisect--helper: string output variables together with "&&" Christian Couder
-- strict thread matches above, loose matches on Subject: below --
2009-03-29 9:55 Christian Couder
2009-03-30 4:18 ` Christian Couder
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).