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

[PATCH 3/5] Introduce a 'die' function.

From
Fredrik Kuivinen <freku045@student.liu.se>
Date
Sep 12, 2005, 21:30 UTC
Message-ID
<20050912213047.GE6644@c165.ib.student.liu.se>
In-Reply-To
<20050912212601.GB6644@c165.ib.student.liu.se>
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
---
 git-merge-fredrik.py |   15 +++++----------
 gitMergeCommon.py    |   12 ++++++++----
 2 files changed, 13 insertions(+), 14 deletions(-)
8ca382168d366c68c567c1f85fb6d2cb02b40f37
diff --git a/git-merge-fredrik.py b/git-merge-fredrik.py
--- a/git-merge-fredrik.py
+++ b/git-merge-fredrik.py
@@ -120,9 +120,8 @@ def unmergedCacheEntries():
             e.stages[stage].mode = mode
             e.stages[stage].sha1 = sha1
         else:
-            print 'Error: Merge program failed: Unexpected output from', \
-                  'git-ls-files:', l
-            sys.exit(2)
+            die('Error: Merge program failed: Unexpected output from', \
+                'git-ls-files:', l)
     return res
 
 def mergeTrees(head, merge, common, branch1Name, branch2Name,
@@ -381,15 +380,12 @@ def processEntry(entry, branch1Name, bra
         os.unlink(src1)
         os.unlink(src2)
     else:
-        print 'ERROR: Fatal merge failure.'
-        print "ERROR: Shouldn't happen"
-        sys.exit(2)
+        die("ERROR: Fatal merge failure, shouldn't happen.")
 
     return cleanMerge
 
 def usage():
-    print 'Usage:', sys.argv[0], ' <base>... -- <head> <remote>..'
-    sys.exit(2)
+    die('Usage:', sys.argv[0], ' <base>... -- <head> <remote>..')
 
 # main entry point as merge strategy module
 # The first parameters up to -- are merge bases, and the rest are heads.
@@ -399,8 +395,7 @@ def usage():
 for nextArg in xrange(1, len(sys.argv)):
     if sys.argv[nextArg] == '--':
         if len(sys.argv) != nextArg + 3:
-            print 'Not handling anything other than two heads merge.'
-            sys.exit(2)
+            die('Not handling anything other than two heads merge.')
         try:
             h1 = firstBranch = sys.argv[nextArg + 1]
             h2 = secondBranch = sys.argv[nextArg + 2]
diff --git a/gitMergeCommon.py b/gitMergeCommon.py
--- a/gitMergeCommon.py
+++ b/gitMergeCommon.py
@@ -10,6 +10,10 @@ if sys.version_info[0] < 2 or \
 
 import subprocess
 
+def die(*args):
+    printList(args, sys.stderr)
+    sys.exit(2)
+
 # Debugging machinery
 # -------------------
 
@@ -28,11 +32,11 @@ def debug(*args):
         if funcName in functionsToDebug:
             printList(args)
 
-def printList(list):
+def printList(list, file=sys.stdout):
     for x in list:
-        sys.stdout.write(str(x))
-        sys.stdout.write(' ')
-    sys.stdout.write('\n')
+        file.write(str(x))
+        file.write(' ')
+    file.write('\n')
 
 # Program execution
 # -----------------
Previous: Fredrik KuivinenNext: Fredrik Kuivinen
Message 4 of 8 in “git-merge-fredrik updates”
  1. 0/5 git-merge-fredrik updatesFredrik Kuivinen, Sep 12, 2005
  2. 1/5 Fix assertion failure when merging common ancestors.Fredrik Kuivinen, Sep 12, 2005
  3. 2/5 Exit with status code 2 if we get an exception.Fredrik Kuivinen, Sep 12, 2005
  4. 3/5 Introduce a 'die' function.Fredrik Kuivinen, Sep 12, 2005
  5. 4/5 Make sure we die if we don't get enough arguments.Fredrik Kuivinen, Sep 12, 2005
  6. 5/5 Make the ProgramError class printable.Fredrik Kuivinen, Sep 12, 2005
  7. Junio C HamanoSep 12, 2005
  8. Rename the 'fredrik' merge strategy to 'recursive'.Fredrik Kuivinen, Sep 13, 2005

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.