From e49795ec4c345cb26183c6c4507b0650aa1ef9c6 Mon Sep 17 00:00:00 2001 From: David Caldwell Date: Sun, 17 Apr 2011 23:41:01 -0700 Subject: [PATCH] [commit-patch] Don't try to reverse the working patch when there are no diffs. Patch fails when the input has just a single \n in it which is what happens when we do "darcs diff a" and "a" doesn't exist yet. --- commit-patch | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/commit-patch b/commit-patch index 31e9f76..8b3f222 100755 --- a/commit-patch +++ b/commit-patch @@ -223,9 +223,11 @@ my ($out, $working_patch, $non_committed_patch); run([split(/ /,$vc{add}), @files], '>', \$out, '2>', \$err);# Expect these 2 to fail when run([split(/ /,$vc{remove}), @files], '>', \$out, '2>', \$err);# there are no new files. run([split(/ /,$vc{diff}), @files], '>', \$working_patch, '2>', \$err);# CVS diff dies. Sigh. or die "$err\n"; -run(["interdiff", $vc{patcharg}, $patch, '-'], '<', \$working_patch, - '>', \$non_committed_patch, '2>', \$err) or die "$err\n"; -run(["patch", $vc{patcharg}, "-R"], '<', \$working_patch, '>', \$out, '2>', \$err) or die "$out\n$err\n"; +unless ($working_patch =~ /^\s*$/s) { + run(["interdiff", $vc{patcharg}, $patch, '-'], '<', \$working_patch, + '>', \$non_committed_patch, '2>', \$err) or die "$err\n"; + run(["patch", $vc{patcharg}, "-R"], '<', \$working_patch, '>', \$out, '2>', \$err) or die "$out\n$err\n"; +} run(["patch", $vc{patcharg}], '<', $patch, '>', \$out, '2>', \$err) or die "$out\n$err\n"; # Don't capture stdout or stderr because it can be interactive (cough cough darcs) run([split(/ /,$vc_commit), @message_opt, @files],debug => 0) or die "commit failed.\n"; -- 2.51.2