chiark / gitweb /
Fix indexing error during "diff -r/"
[stgit] / stgit / utils.py
index ed6e43c2c9282ee87333317d02f73c14eb616c1d..67431ec995be7aa31f0f86d58c35a237107fb3eb 100644 (file)
@@ -109,6 +109,12 @@ def strip_prefix(prefix, string):
     assert string.startswith(prefix)
     return string[len(prefix):]
 
+def strip_suffix(suffix, string):
+    """Return string, without the suffix. Blow up if string doesn't
+    end with suffix."""
+    assert string.endswith(suffix)
+    return string[:-len(suffix)]
+
 def remove_dirs(basedir, dirs):
     """Starting at join(basedir, dirs), remove the directory if empty,
     and try the same with its parent, until we find a nonempty