From b2017c38acfed9c26ec5bbcb2b23784ca0a15cc8 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Tue, 13 Feb 2007 22:26:36 +0000 Subject: [PATCH] Make StGIT aware of the STGIT_DEBUG_LEVEL environment variable For now, setting this environment variable will make StGIT dump the backtrace in case of a failure. Signed-off-by: Catalin Marinas --- stgit/main.py | 13 ++++++++++++- t/test-lib.sh | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/stgit/main.py b/stgit/main.py index 49089e6e..933f1271 100644 --- a/stgit/main.py +++ b/stgit/main.py @@ -258,6 +258,14 @@ def main(): from stgit.gitmergeonefile import GitMergeException try: + debug_level = int(os.environ['STGIT_DEBUG_LEVEL']) + except KeyError: + debug_level = 0 + except ValueError: + print >> sys.stderr, 'Invalid STGIT_DEBUG_LEVEL environment variable' + sys.exit(1) + + try: config_setup() # 'clone' doesn't expect an already initialised GIT tree. A Series @@ -273,7 +281,10 @@ def main(): except (IOError, ParsingError, NoSectionError, CmdException, StackException, GitException, GitMergeException), err: print >> sys.stderr, '%s %s: %s' % (prog, cmd, err) - sys.exit(2) + if debug_level: + raise + else: + sys.exit(2) except KeyboardInterrupt: sys.exit(1) diff --git a/t/test-lib.sh b/t/test-lib.sh index 3274b84f..0ac7e7c4 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -63,6 +63,7 @@ do echo "$test_description" exit 0 ;; -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) + export STGIT_DEBUG_LEVEL="-1" verbose=t; shift ;; *) break ;; -- 2.11.4.GIT