You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2010/09/01 09:44:13 UTC

svn commit: r991459 - in /subversion/trunk/subversion: libsvn_diff/parse-diff.c tests/libsvn_diff/parse-diff-test.c

Author: dannas
Date: Wed Sep  1 07:44:13 2010
New Revision: 991459

URL: http://svn.apache.org/viewvc?rev=991459&view=rev
Log:
Fix the diff parser to look for the correct first line of a git diff.

The change that is beeing applied is s/git --diff/diff --git/.

* subversion/libsvn_diff/parse-diff.c
  (parse_next_hunk,
   git_start,
   svn_diff_parse_next_patch): Check for 'diff --git' as first line of a 
    git diff header.

* subversion/libsvn_diff/parse-diff-test.c
  (git_unidiff,
   git_tree_and_text_unidiff,
   bad_git_diff_header,
   path_with_spaces_unidiff): Use 'diff --git as first line of git
    diff headers.

Found by: stsp

Modified:
    subversion/trunk/subversion/libsvn_diff/parse-diff.c
    subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c

Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=991459&r1=991458&r2=991459&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Wed Sep  1 07:44:13 2010
@@ -709,7 +709,7 @@ parse_next_hunk(svn_diff_hunk_t **hunk,
               *prop_operation = svn_diff_op_modified;
             }
           else if (starts_with(line->data, minus)
-                   || starts_with(line->data, "git --diff "))
+                   || starts_with(line->data, "diff --git "))
             /* This could be a header of another patch. Bail out. */
             break;
         }
@@ -905,8 +905,7 @@ git_start(enum parse_state *new_state, c
    * such substitution then the whole pathname is put in double quotes.
    */
 
-  /* Our line should look like this: 'git --diff a/path b/path'. 
-   * ### Not diff --git a/path b/path ?
+  /* Our line should look like this: 'diff --git a/path b/path'. 
    *
    * If we find any deviations from that format, we return with state reset
    * to start.
@@ -942,9 +941,9 @@ git_start(enum parse_state *new_state, c
   /* By now, we know that we have a line on the form '--git diff a/.+ b/.+'
    * We only need the filenames when we have deleted or added empty
    * files. In those cases the old_path and new_path is identical on the
-   * '--git diff' line.  For all other cases we fetch the filenames from
+   * 'diff --git' line.  For all other cases we fetch the filenames from
    * other header lines. */ 
-  old_path_start = line + strlen("--git diff a/");
+  old_path_start = line + strlen("diff --git a/");
   new_path_end = line + strlen(line);
   new_path_start = old_path_start;
 
@@ -1165,8 +1164,7 @@ svn_diff_parse_next_patch(svn_patch_t **
     {
       {"--- ",          state_start,            diff_minus},
       {"+++ ",          state_minus_seen,       diff_plus},
-      /* ### Not "diff --git"? */
-      {"git --diff",    state_start,            git_start},
+      {"diff --git",    state_start,            git_start},
       {"--- a/",        state_git_diff_seen,    git_minus},
       {"--- a/",        state_git_tree_seen,    git_minus},
       {"--- /dev/null", state_git_tree_seen,    git_minus},

Modified: subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c?rev=991459&r1=991458&r2=991459&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c (original)
+++ subversion/trunk/subversion/tests/libsvn_diff/parse-diff-test.c Wed Sep  1 07:44:13 2010
@@ -59,11 +59,11 @@ static const char *unidiff =
 static const char *git_unidiff =
   "Index: A/mu (deleted)"                                               NL
   "===================================================================" NL
-  "git --diff a/A/mu b/A/mu"                                            NL
+  "diff --git a/A/mu b/A/mu"                                            NL
   "deleted file mode 100644"                                            NL
   "Index: A/C/gamma"                                                    NL
   "===================================================================" NL
-  "git --diff a/A/C/gamma b/A/C/gamma"                                  NL
+  "diff --git a/A/C/gamma b/A/C/gamma"                                  NL
   "--- a/A/C/gamma\t(revision 2)"                                       NL
   "+++ b/A/C/gamma\t(working copy)"                                     NL
   "@@ -1 +1,2 @@"                                                       NL
@@ -71,19 +71,19 @@ static const char *git_unidiff =
   "+some more bytes to 'gamma'"                                         NL
   "Index: iota"                                                         NL
   "===================================================================" NL
-  "git --diff a/iota b/iota.copied"                                     NL
+  "diff --git a/iota b/iota.copied"                                     NL
   "copy from iota"                                                      NL
   "copy to iota.copied"                                                 NL
   "Index: new"                                                          NL
   "===================================================================" NL
-  "git --diff a/new b/new"                                              NL
+  "diff --git a/new b/new"                                              NL
   "new file mode 100644"                                                NL
   ""                                                                    NL;
 
 static const char *git_tree_and_text_unidiff =
   "Index: iota.copied"                                                  NL
   "===================================================================" NL
-  "git --diff a/iota b/iota.copied"                                     NL
+  "diff --git a/iota b/iota.copied"                                     NL
   "copy from iota"                                                      NL
   "copy to iota.copied"                                                 NL
   "--- a/iota\t(revision 2)"                                            NL
@@ -93,7 +93,7 @@ static const char *git_tree_and_text_uni
   "+some more bytes to 'iota'"                                          NL
   "Index: A/mu.moved"                                                   NL
   "===================================================================" NL
-  "git --diff a/A/mu b/A/mu.moved"                                      NL
+  "diff --git a/A/mu b/A/mu.moved"                                      NL
   "rename from A/mu"                                                    NL
   "rename to A/mu.moved"                                                NL
   "--- a/A/mu\t(revision 2)"                                            NL
@@ -103,7 +103,7 @@ static const char *git_tree_and_text_uni
   "+some more bytes to 'mu'"                                            NL
   "Index: new"                                                          NL
   "===================================================================" NL
-  "git --diff a/new b/new"                                              NL
+  "diff --git a/new b/new"                                              NL
   "new file mode 100644"                                                NL
   "--- /dev/null\t(revision 0)"                                         NL
   "+++ b/new\t(working copy)"                                           NL
@@ -111,7 +111,7 @@ static const char *git_tree_and_text_uni
   "+This is the file 'new'."                                            NL
   "Index: A/B/lambda"                                                   NL
   "===================================================================" NL
-  "git --diff a/A/B/lambda b/A/B/lambda"                                NL
+  "diff --git a/A/B/lambda b/A/B/lambda"                                NL
   "deleted file mode 100644"                                            NL
   "--- a/A/B/lambda\t(revision 2)"                                      NL
   "+++ /dev/null\t(working copy)"                                       NL
@@ -124,22 +124,22 @@ static const char *git_tree_and_text_uni
 static const char *bad_git_diff_header =
   "Index: iota.copied"                                                  NL
   "===================================================================" NL
-  "git --diff a/foo1 b/"                                                NL
-  "git --diff a/foo2 b"                                                 NL
-  "git --diff a/foo3 "                                                  NL
-  "git --diff a/foo3 "                                                  NL
-  "git --diff foo4 b/foo4"                                              NL
-  "git --diff a/foo5 b/foo5"                                            NL
+  "diff --git a/foo1 b/"                                                NL
+  "diff --git a/foo2 b"                                                 NL
+  "diff --git a/foo3 "                                                  NL
+  "diff --git a/foo3 "                                                  NL
+  "diff --git foo4 b/foo4"                                              NL
+  "diff --git a/foo5 b/foo5"                                            NL
   "random noise"                                                        NL
   "copy from foo5"                                                      NL
   "copy to foo5"                                                        NL
-  "git --diff a/foo6 b/foo6"                                            NL
+  "diff --git a/foo6 b/foo6"                                            NL
   "copy from foo6"                                                      NL
   "random noise"                                                        NL
   "copy to foo6"                                                        NL
-  "git --diff a/foo6 b/foo6"                                            NL
+  "diff --git a/foo6 b/foo6"                                            NL
   "copy from foo6"                                                      NL
-  "git --diff a/iota b/iota.copied"                                     NL
+  "diff --git a/iota b/iota.copied"                                     NL
   "copy from iota"                                                      NL
   "copy to iota.copied"                                                 NL
   "@@ -1 +1,2 @@"                                                       NL
@@ -236,13 +236,13 @@ static const char *bad_git_diff_header =
 
   /* A unidiff containing paths with spaces. */
   static const char *path_with_spaces_unidiff =
-  "git --diff a/path 1 b/path 1"                                        NL
+  "diff --git a/path 1 b/path 1"                                        NL
   "new file mode 100644"                                                NL
-  "git --diff a/path one 1 b/path one 1"                                NL
+  "diff --git a/path one 1 b/path one 1"                                NL
   "new file mode 100644"                                                NL
-  "git --diff a/dir/ b/path b/dir/ b/path"                              NL
+  "diff --git a/dir/ b/path b/dir/ b/path"                              NL
   "new file mode 100644"                                                NL
-  "git --diff a/ b/path 1 b/ b/path 1"                                  NL
+  "diff --git a/ b/path 1 b/ b/path 1"                                  NL
   "new file mode 100644"                                                NL;