monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-devel] patch for bug 13072


From: Ulrich Drepper
Subject: [Monotone-devel] patch for bug 13072
Date: Thu, 12 May 2005 23:47:29 -0700
User-agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324)

The attached patch should fix bug 13072.  I have no idea why the code in
transform.cc insists on adding an empty line in case the file is empty.
 Removing the code didn't cause any regressions in the test suite and
the diff_patch.cc change corrects the output format.  A new test case is
included as well.  Somebody please apply.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
# 
# patch "diff_patch.cc"
#  from [bc9388bcdf8df0fac37f52aa7a8e0b8b8f94d247]
#    to [209e60efcca30474071383769840ae18d3d1aeef]
# 
# patch "testsuite.at"
#  from [9d5a9fc124934f2f1ab6415377d8ce12ec54fb37]
#    to [dc26ef94905b6520a13871690349ef52b1ba970d]
# 
# patch "transforms.cc"
#  from [6ea138ac776c8d19aaf274a8a93f370a60de3e05]
#    to [a84ed105809f55ba4097a4559ecc53ec21f9ab17]
# 
--- diff_patch.cc
+++ diff_patch.cc
@@ -833,13 +833,23 @@
         }
       
       // write hunk to stream
-      ost << "@@ -" << a_begin+1;
-      if (a_len > 1)
-        ost << "," << a_len;
+      if (a_len == 0)
+        ost << "@@ -0,0";
+      else
+        {
+          ost << "@@ -" << a_begin+1;
+          if (a_len > 1)
+            ost << "," << a_len;
+        }
       
-      ost << " +" << b_begin+1;
-      if (b_len > 1)
-    ost << "," << b_len;
+      if (b_len == 0)
+        ost << " +0,0";
+      else
+       {
+          ost << " +" << b_begin+1;
+          if (b_len > 1)
+            ost << "," << b_len;
+        }
       ost << " @@" << endl;
       
       copy(hunk.begin(), hunk.end(), ostream_iterator<string>(ost, "\n"));
--- testsuite.at
+++ testsuite.at
@@ -637,3 +637,4 @@
 m4_include(tests/t_unreadable_MT.at)
 m4_include(tests/t_cvsimport3.at)
 m4_include(tests/t_commit_message_file.at)
+m4_include(tests/t_unidiff3.at)
--- transforms.cc
+++ transforms.cc
@@ -395,8 +395,6 @@
     {
       out.push_back(in);
     }
-  if (out.size() == 0)
-    out.push_back("");
 }
 
 
--- /dev/null   2005-05-09 21:23:45.097901792 -0700
+++ tests/t_unidiff3.at 2005-05-12 23:40:16.000000000 -0700
@@ -0,0 +1,21 @@
+AT_SETUP([diff against empty file])
+MONOTONE_SETUP
+
+AT_CHECK(printf "1\n2\n", [], [stdout])
+AT_CHECK(mv stdout foo)
+
+AT_CHECK(MONOTONE add foo, [], [ignore], [ignore])
+AT_CHECK(MONOTONE --branch=foo commit -m foo, [], [ignore], [ignore])
+
+AT_CHECK(mv foo foo.away)
+AT_CHECK(touch foo)
+AT_CHECK(MONOTONE diff foo, [], [stdout])
+AT_CHECK(mv stdout monodiff, [], [ignore])
+
+# see whether the patch is well-formed
+AT_CHECK(patch -p0 -R < monodiff, [], [ignore], [ignore])
+
+# see whether the resulting file is the same as the original one
+AT_CHECK(cmp foo foo.away, [], [ignore])
+
+AT_CLEANUP

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]