Gmane
From: Johannes Sixt <j6t <at> kdbg.org>
Subject: [PATCH 1/7] Truncate result of run_command that is used in exit() to lowest 8 bits
Newsgroups: gmane.comp.version-control.git
Date: 2009-07-04 19:26:37 GMT (35 weeks, 4 days, 4 hours and 59 minutes ago)
On Windows, negative return values are not detected reliably by the parent
process as failure. This fixes it.

Signed-off-by: Johannes Sixt <j6t <at> kdbg.org>
---
 bisect.c      |    4 ++--
 builtin-add.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bisect.c b/bisect.c
index 52220df..b395c47 100644
--- a/bisect.c
+++ b/bisect.c
@@ -760,7 +760,7 @@ static int bisect_checkout(char *bisect_rev_hex)
 	argv_checkout[2] = bisect_rev_hex;
 	res = run_command_v_opt(argv_checkout, RUN_GIT_CMD);
 	if (res)
-		exit(res);
+		exit(res & 0xff);

 	argv_show_branch[1] = bisect_rev_hex;
 	return run_command_v_opt(argv_show_branch, RUN_GIT_CMD);
@@ -850,7 +850,7 @@ static void check_merge_bases(void)
 			handle_skipped_merge_base(mb);
 		} else {
 			printf("Bisecting: a merge base must be tested\n");
-			exit(bisect_checkout(sha1_to_hex(mb)));
+			exit(bisect_checkout(sha1_to_hex(mb)) & 0xff);
 		}
 	}

diff --git a/builtin-add.c b/builtin-add.c
index 4e44148..d83e67e 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -305,7 +305,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
 	if (patch_interactive)
 		add_interactive = 1;
 	if (add_interactive)
-		exit(interactive_add(argc - 1, argv + 1, prefix));
+		exit(interactive_add(argc - 1, argv + 1, prefix) & 0xff);

 	if (edit_interactive)
 		return(edit_patch(argc, argv, prefix));
-- 
1.6.3.17.g1665f