git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGit PATCH 3/5] Set exit code to 3 on merge conflict

From
Karl Hasselström <kha@treskal.com>
Date
Dec 14, 2007, 06:32 UTC
Message-ID
<20071214063224.29290.45251.stgit@yoghurt>
In-Reply-To
<20071214062618.29290.70792.stgit@yoghurt>
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/commands/coalesce.py |    6 +++---
 stgit/commands/goto.py     |    2 +-
 stgit/lib/transaction.py   |    7 ++++++-
 stgit/main.py              |    4 ++--
 stgit/utils.py             |    1 +
 5 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/stgit/commands/coalesce.py b/stgit/commands/coalesce.py
index 2330231..d2cba3e 100644
--- a/stgit/commands/coalesce.py
+++ b/stgit/commands/coalesce.py
@@ -110,7 +110,7 @@ def _coalesce(stack, iw, name, msg, save_template, patches):
         return
     except transaction.TransactionHalted:
         pass
-    trans.run(iw)
+    return trans.run(iw)
 
 def func(parser, options, args):
     stack = directory.repository.current_stack
@@ -118,5 +118,5 @@ def func(parser, options, args):
                                           + list(stack.patchorder.unapplied)))
     if len(patches) < 2:
         raise common.CmdException('Need at least two patches')
-    _coalesce(stack, stack.repository.default_iw(),
-              options.name, options.message, options.save_template, patches)
+    return _coalesce(stack, stack.repository.default_iw(), options.name,
+                     options.message, options.save_template, patches)
diff --git a/stgit/commands/goto.py b/stgit/commands/goto.py
index d78929d..763a8af 100644
--- a/stgit/commands/goto.py
+++ b/stgit/commands/goto.py
@@ -48,4 +48,4 @@ def func(parser, options, args):
             pass
     else:
         raise common.CmdException('Patch "%s" does not exist' % patch)
-    trans.run(iw)
+    return trans.run(iw)
diff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py
index 663d393..0ca647e 100644
--- a/stgit/lib/transaction.py
+++ b/stgit/lib/transaction.py
@@ -1,4 +1,4 @@
-from stgit import exception
+from stgit import exception, utils
 from stgit.out import *
 from stgit.lib import git
 
@@ -111,6 +111,11 @@ class StackTransaction(object):
         self.__stack.patchorder.applied = self.__applied
         self.__stack.patchorder.unapplied = self.__unapplied
 
+        if self.__error:
+            return utils.STGIT_CONFLICT
+        else:
+            return utils.STGIT_SUCCESS
+
     def __halt(self, msg):
         self.__error = msg
         raise TransactionHalted(msg)
diff --git a/stgit/main.py b/stgit/main.py
index a95eeb9..2577693 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -273,7 +273,7 @@ def main():
             else:
                 command.crt_series = Series()
 
-        command.func(parser, options, args)
+        ret = command.func(parser, options, args)
     except (StgException, IOError, ParsingError, NoSectionError), err:
         out.error(str(err), title = '%s %s' % (prog, cmd))
         if debug_level > 0:
@@ -283,4 +283,4 @@ def main():
     except KeyboardInterrupt:
         sys.exit(utils.STGIT_GENERAL_ERROR)
 
-    sys.exit(utils.STGIT_SUCCESS)
+    sys.exit(ret or utils.STGIT_SUCCESS)
diff --git a/stgit/utils.py b/stgit/utils.py
index 6568da5..2ff1d74 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -317,6 +317,7 @@ def make_message_options():
 STGIT_SUCCESS = 0        # everything's OK
 STGIT_GENERAL_ERROR = 1  # seems to be non-command-specific error
 STGIT_COMMAND_ERROR = 2  # seems to be a command that failed
+STGIT_CONFLICT = 3       # merge conflict, otherwise OK
 
 def strip_leading(prefix, s):
     """Strip leading prefix from a string. Blow up if the prefix isn't
Previous: Karl HasselströmNext: Karl Hasselström
Message 4 of 6 in “More experimental patches”
  1. 0/5 More experimental patchesKarl Hasselström, Dec 14, 2007
  2. 1/5 Expose transaction abort functionKarl Hasselström, Dec 14, 2007
  3. 2/5 stg coalesce: Support --file and --save-templateKarl Hasselström, Dec 14, 2007
  4. 3/5 Set exit code to 3 on merge conflictKarl Hasselström, Dec 14, 2007
  5. 4/5 Convert "stg commit" to new infrastructureKarl Hasselström, Dec 14, 2007
  6. 5/5 Make "stg commit" fancierKarl Hasselström, Dec 14, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.