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>
Christian Couder committed
Mar 30, 2009 at 06:59 UTC
e89aa6d2f546b2d4f2d88c15ce7e343751d6922f
4 files changed
+23
-25
bisect.c
+2
-1
@@ -547,5 +547,6 @@ int bisect_next_vars(const char *prefix)
547
revs.commits = find_bisection(revs.commits, &reaches, &all,
548
!!skipped_sha1_nr);
549
550
- return show_bisect_vars(&revs, reaches, all, BISECT_SHOW_TRIED);
550
+ return show_bisect_vars(&revs, reaches, all,
551
+ BISECT_SHOW_TRIED | BISECT_SHOW_STRINGED);
552
}
bisect.h
+1
@@ -12,6 +12,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,
12
/* show_bisect_vars flags */
13
#define BISECT_SHOW_ALL (1<<0)
14
#define BISECT_SHOW_TRIED (1<<1)
15
+#define BISECT_SHOW_STRINGED (1<<2)
16
17
/*
18
* The flag BISECT_SHOW_ALL should not be set if this function is called
builtin-rev-list.c
+19
-10
@@ -226,20 +226,20 @@ static int estimate_bisect_steps(int all)
226
return (e < 3 * x) ? n : n - 1;
227
}
228
229
-static void show_tried_revs(struct commit_list *tried)
229
+static void show_tried_revs(struct commit_list *tried, int stringed)
230
{
231
printf("bisect_tried='");
232
for (;tried; tried = tried->next) {
233
char *format = tried->next ? "%s|" : "%s";
234
printf(format, sha1_to_hex(tried->item->object.sha1));
235
}
236
- printf("'\n");
236
+ printf(stringed ? "' &&\n" : "'\n");
237
}
238
239
int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)
240
{
241
int cnt;
242
- char hex[41] = "";
242
+ char hex[41] = "", *format;
243
struct commit_list *tried;
244
245
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)
269
}
270
271
if (flags & BISECT_SHOW_TRIED)
272
- show_tried_revs(tried);
273
- printf("bisect_rev=%s\n"
274
- "bisect_nr=%d\n"
275
- "bisect_good=%d\n"
276
- "bisect_bad=%d\n"
277
- "bisect_all=%d\n"
278
- "bisect_steps=%d\n",
272
+ show_tried_revs(tried, flags & BISECT_SHOW_STRINGED);
273
+ format = (flags & BISECT_SHOW_STRINGED) ?
274
+ "bisect_rev=%s &&\n"
275
+ "bisect_nr=%d &&\n"
276
+ "bisect_good=%d &&\n"
277
+ "bisect_bad=%d &&\n"
278
+ "bisect_all=%d &&\n"
279
+ "bisect_steps=%d\n"
280
+ :
281
+ "bisect_rev=%s\n"
282
+ "bisect_nr=%d\n"
283
+ "bisect_good=%d\n"
284
+ "bisect_bad=%d\n"
285
+ "bisect_all=%d\n"
286
+ "bisect_steps=%d\n";
287
+ printf(format,
288
hex,
289
cnt - 1,
290
all - reaches - 1,
git-bisect.sh
+1
-14
@@ -279,18 +279,6 @@ bisect_auto_next() {
279
bisect_next_check && bisect_next || :
280
}
281
282
-eval_and_string_together() {
283
- _eval="$1"
284
-
285
- eval "$_eval" | {
286
- while read line
287
- do
288
- echo "$line &&"
289
- done
290
- echo ':'
291
- }
292
-}
293
-
282
exit_if_skipped_commits () {
283
_tried=$1
284
_bad=$2
@@ -429,8 +417,7 @@ bisect_next() {
417
test "$?" -eq "1" && return
418
419
# Get bisection information
432
- eval="git bisect--helper --next-vars" &&
433
- eval=$(eval_and_string_together "$eval") &&
420
+ eval=$(eval "git bisect--helper --next-vars") &&
421
eval "$eval" || exit
422
423
if [ -z "$bisect_rev" ]; then