User: sits
Date: 08/07/11 02:50:22
Modified: . CHANGELOG
template/en/default viewdeltas.html.tmpl
viewdeltaheader.html.tmpl
lib/Codestriker/FileParser PatchUnidiff.pm
Added: test/testtopictexts git-diff1.txt
Log:
Ability to parse git patches correctly.
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -r1.243 -r1.244
--- CHANGELOG 11 Jul 2008 04:49:28 -0000 1.243
+++ CHANGELOG 11 Jul 2008 09:50:21 -0000 1.244
@@ -12,6 +12,8 @@
* Deleting a topic connected with a TestDirector bug has been fixed
from [EMAIL PROTECTED]
+
+* Ability to parse git patches correctly.
Version 1.9.5
Index: viewdeltas.html.tmpl
===================================================================
RCS file:
/cvsroot/codestriker/codestriker/template/en/default/viewdeltas.html.tmpl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- viewdeltas.html.tmpl 1 Jul 2008 11:08:47 -0000 1.9
+++ viewdeltas.html.tmpl 11 Jul 2008 09:50:22 -0000 1.10
@@ -18,8 +18,8 @@
[%# Output the diff description if it is present. #%]
[% IF delta.description != "" %]
<tr>
- <td class="line" colspan="2">[% delta.description | html_entity
%]</td>
- <td class="line" colspan="2">[% delta.description | html_entity
%]</td>
+ <td class="line" align="left">[% delta.description | html_entity
%]</td>
+ <td class="line" align="right">[% delta.description | html_entity
%]</td>
</tr>
[% END %]
</table>
Index: viewdeltaheader.html.tmpl
===================================================================
RCS file:
/cvsroot/codestriker/codestriker/template/en/default/viewdeltaheader.html.tmpl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- viewdeltaheader.html.tmpl 13 Mar 2008 22:39:07 -0000 1.2
+++ viewdeltaheader.html.tmpl 11 Jul 2008 09:50:22 -0000 1.3
@@ -10,7 +10,7 @@
[% ELSE %]
[% delta.filename | html_entity %]
[% END %]
- (Revision [% delta.revision %])
+ [% IF delta.revision != "0.1" %](Revision [% delta.revision %])[%
END %]
</td>
<td class="file" align="right">
Index: PatchUnidiff.pm
===================================================================
RCS file:
/cvsroot/codestriker/codestriker/lib/Codestriker/FileParser/PatchUnidiff.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PatchUnidiff.pm 29 Jun 2007 05:38:31 -0000 1.5
+++ PatchUnidiff.pm 11 Jul 2008 09:50:22 -0000 1.6
@@ -46,6 +46,14 @@
$line = <$fh>;
}
return () unless defined $line;
+
+ # Git patches might have an index: line, such as:
+ # index b3fc290..d13313f 100644
+ if ($line =~ /^index /o) {
+ $line = <$fh>;
+ }
+ return () unless defined $line;
+
# Need to check for binary file differences.
# Unfortunately, when you provide the "-N" argument to diff,
@@ -61,7 +69,8 @@
} elsif ($line =~ /^\-\-\- \/dev\/null/o) {
# File has been added.
$revision = $Codestriker::ADDED_REVISION;
- } elsif ($line =~ /^\-\-\- (.*)\t/o) {
+ } elsif ($line =~ /^\-\-\- ([^\t]+)/o) {
+ # Note git and quilt diffs don't have a tab character unlike
normal diffs.
$filename = $1;
} else {
return ();
@@ -76,7 +85,7 @@
if ($line =~ /^\+\+\+ \/dev\/null/o) {
# File has been removed.
$revision = $Codestriker::REMOVED_REVISION;
- } elsif ($line =~ /^\+\+\+ (.*)\t/o) {
+ } elsif ($line =~ /^\+\+\+ ([^\t]+)/o) {
$filename = $1;
} else {
return ();
Index: git-diff1.txt
===================================================================
RCS file: git-diff1.txt
diff -N git-diff1.txt
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ git-diff1.txt 11 Jul 2008 09:50:22 -0000 1.1
@@ -0,0 +1,80 @@
+diff --git a/builtin-apply.c b/builtin-apply.c
+index b3fc290..d13313f 100644
+--- a/builtin-apply.c
++++ b/builtin-apply.c
+@@ -2296,7 +2296,8 @@ static int apply_data(struct patch *patch, struct stat
*st, struct cache_entry *
+
+ strbuf_init(&buf, 0);
+
+- if ((tpatch = in_fn_table(patch->old_name)) != NULL) {
++ if (!(patch->is_copy || patch->is_rename) &&
++ ((tpatch = in_fn_table(patch->old_name)) != NULL)) {
+ if (tpatch == (struct patch *) -1) {
+ return error("patch %s has been renamed/deleted",
+ patch->old_name);
+@@ -2375,7 +2376,7 @@ static int verify_index_match(struct cache_entry *ce,
struct stat *st)
+ static int check_preimage(struct patch *patch, struct cache_entry **ce,
struct stat *st)
+ {
+ const char *old_name = patch->old_name;
+- struct patch *tpatch;
++ struct patch *tpatch = NULL;
+ int stat_ret = 0;
+ unsigned st_mode = 0;
+
+@@ -2389,7 +2390,9 @@ static int check_preimage(struct patch *patch, struct
cache_entry **ce, struct s
+ return 0;
+
+ assert(patch->is_new <= 0);
+- if ((tpatch = in_fn_table(old_name)) != NULL) {
++
++ if (!(patch->is_copy || patch->is_rename) &&
++ (tpatch = in_fn_table(old_name)) != NULL) {
+ if (tpatch == (struct patch *) -1) {
+ return error("%s: has been deleted/renamed", old_name);
+ }
+@@ -2399,6 +2402,7 @@ static int check_preimage(struct patch *patch, struct
cache_entry **ce, struct s
+ if (stat_ret && errno != ENOENT)
+ return error("%s: %s", old_name, strerror(errno));
+ }
++
+ if (check_index && !tpatch) {
+ int pos = cache_name_pos(old_name, strlen(old_name));
+ if (pos < 0) {
+diff --git a/t/t4112-apply-renames.sh b/t/t4112-apply-renames.sh
+index 70a1859..f9ad183 100755
+--- a/t/t4112-apply-renames.sh
++++ b/t/t4112-apply-renames.sh
+@@ -36,6 +36,9 @@ typedef struct __jmp_buf jmp_buf[1];
+
+ #endif /* _SETJMP_H */
+ EOF
++cat >klibc/README <<\EOF
++This is a simple readme file.
++EOF
+
+ cat >patch <<\EOF
+ diff --git a/klibc/arch/x86_64/include/klibc/archsetjmp.h
b/include/arch/cris/klibc/archsetjmp.h
+@@ -113,6 +116,23 @@ rename to include/arch/m32r/klibc/archsetjmp.h
+
+ -#endif /* _SETJMP_H */
+ +#endif /* _KLIBC_ARCHSETJMP_H */
++diff --git a/klibc/README b/klibc/README
++--- a/klibc/README
+++++ b/klibc/README
++@@ -1,1 +1,4 @@
++ This is a simple readme file.
+++And we add a few
+++lines at the
+++end of it.
++diff --git a/klibc/README b/klibc/arch/README
++copy from klibc/README
++copy to klibc/arch/README
++--- a/klibc/README
+++++ b/klibc/arch/README
++@@ -1,1 +1,3 @@
++ This is a simple readme file.
+++And we copy it to one level down, and
+++add a few lines at the end of it.
+ EOF
+
+ find klibc -type f -print | xargs git update-index --add --
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits