]> thyrsus.com Git - src.git/commitdiff
Ading tests, finding bugs.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 7 Nov 2014 16:25:36 +0000 (11:25 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 7 Nov 2014 16:25:36 +0000 (11:25 -0500)
src
srctest

diff --git a/src b/src
index 2bd61c83562b81a0cef6a760eaa82d2a1bdc693b..380cfcb2a9aee1dce7b1ab3992ff405166b50729 100755 (executable)
--- a/src
+++ b/src
@@ -363,6 +363,7 @@ class lifted:
 
 def commit_method(*args):
     "Commit changes to files."
+    args = list(args)
     comment = None
     if args[0] == '--':
         args.pop(0)
@@ -370,18 +371,21 @@ def commit_method(*args):
         commentfp = sys.stdin.read()
         args.pop(0)
     elif args[0] == "-m":
+        args.pop(0)
         try:
-            comment = args[1]
+            comment = args[0]
+            args.pop(0)
         except IndexError:
             croak("commit -m requires a following string.")
     elif args[0] == "-f":
+        args.pop(0)
         try:
-            comment = open(args[1]).read()
+            comment = open(args[0]).read()
+            args.pop(0)
         except IndexError:
             croak("commit -f requires a following filename argument.")
         except OSError:
             croak("couldn't open %s." % args[1])
-        args.pop(0)
     (revspec, args) = preamble("commit", args)
     if revspec is not None:
         croak("commit doesn't take a revision spec")
diff --git a/srctest b/srctest
index dbc6211d57a46e68d30a8e40c54dfffd7fb574eb..2dd968e703478ad6c2f11842c5917fa15e25656e 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -22,7 +22,10 @@ EOF
 src add testfile$$ >/dev/null
 check "add"
 
-src commit -m "First comment" >/dev/null
+src commit -m "First comment" >/dev/null testfile$$
 check "commit"
 
+src cat testfile$$ | diff testfile$$ - >/dev/null 
+check "diff"
+
 # end