Check whether the file exists in the fold command
[stgit] / stgit / commands / fold.py
index 963c196..8b796ca 100644 (file)
@@ -60,7 +60,10 @@ def func(parser, options, args):
         raise CmdException, 'No patches applied'
 
     if filename:
-        print 'Folding patch "%s"...' % filename,
+        if os.path.exists(filename):
+            print 'Folding patch "%s"...' % filename,
+        else:
+            raise CmdException, 'No such file: %s' % filename
     else:
         print 'Folding patch from stdin...',
     sys.stdout.flush()
@@ -70,7 +73,7 @@ def func(parser, options, args):
         bottom = crt_patch.get_bottom()
         git.apply_patch(filename, bottom)
     elif options.base:
-        git.apply_patch(filename, git.rev_parse(options.base))
+        git.apply_patch(filename, git_id(options.base))
     else:
         git.apply_patch(filename)