bisect--helper: string output variables together with "&&"

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 gets rid of the need to string together the line from
the output of "git bisect--helper" with "&&" in the calling script
by making "git bisect--helper --next-vars" return output variables
already in that format.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Christian Couder 2009-03-30 06:59:59 +02:00 committed by Junio C Hamano
parent 37c4c38d73
commit e89aa6d2f5
4 changed files with 23 additions and 25 deletions

View File

@ -547,5 +547,6 @@ int bisect_next_vars(const char *prefix)
revs.commits = find_bisection(revs.commits, &reaches, &all, revs.commits = find_bisection(revs.commits, &reaches, &all,
!!skipped_sha1_nr); !!skipped_sha1_nr);
return show_bisect_vars(&revs, reaches, all, BISECT_SHOW_TRIED); return show_bisect_vars(&revs, reaches, all,
BISECT_SHOW_TRIED | BISECT_SHOW_STRINGED);
} }

View File

@ -12,6 +12,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,
/* show_bisect_vars flags */ /* show_bisect_vars flags */
#define BISECT_SHOW_ALL (1<<0) #define BISECT_SHOW_ALL (1<<0)
#define BISECT_SHOW_TRIED (1<<1) #define BISECT_SHOW_TRIED (1<<1)
#define BISECT_SHOW_STRINGED (1<<2)
/* /*
* The flag BISECT_SHOW_ALL should not be set if this function is called * The flag BISECT_SHOW_ALL should not be set if this function is called

View File

@ -226,20 +226,20 @@ static int estimate_bisect_steps(int all)
return (e < 3 * x) ? n : n - 1; 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='"); printf("bisect_tried='");
for (;tried; tried = tried->next) { for (;tried; tried = tried->next) {
char *format = tried->next ? "%s|" : "%s"; char *format = tried->next ? "%s|" : "%s";
printf(format, sha1_to_hex(tried->item->object.sha1)); 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 show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
{ {
int cnt; int cnt;
char hex[41] = ""; char hex[41] = "", *format;
struct commit_list *tried; struct commit_list *tried;
if (!revs->commits && !(flags & BISECT_SHOW_TRIED)) if (!revs->commits && !(flags & BISECT_SHOW_TRIED))
@ -269,13 +269,22 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
} }
if (flags & BISECT_SHOW_TRIED) if (flags & BISECT_SHOW_TRIED)
show_tried_revs(tried); show_tried_revs(tried, flags & BISECT_SHOW_STRINGED);
printf("bisect_rev=%s\n" format = (flags & BISECT_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_nr=%d\n"
"bisect_good=%d\n" "bisect_good=%d\n"
"bisect_bad=%d\n" "bisect_bad=%d\n"
"bisect_all=%d\n" "bisect_all=%d\n"
"bisect_steps=%d\n", "bisect_steps=%d\n";
printf(format,
hex, hex,
cnt - 1, cnt - 1,
all - reaches - 1, all - reaches - 1,

View File

@ -279,18 +279,6 @@ bisect_auto_next() {
bisect_next_check && bisect_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 () { exit_if_skipped_commits () {
_tried=$1 _tried=$1
_bad=$2 _bad=$2
@ -429,8 +417,7 @@ bisect_next() {
test "$?" -eq "1" && return test "$?" -eq "1" && return
# Get bisection information # Get bisection information
eval="git bisect--helper --next-vars" && eval=$(eval "git bisect--helper --next-vars") &&
eval=$(eval_and_string_together "$eval") &&
eval "$eval" || exit eval "$eval" || exit
if [ -z "$bisect_rev" ]; then if [ -z "$bisect_rev" ]; then