56 Commits

Author SHA1 Message Date
Andreas Gruenbacher
8cc8b7061c * src/patch.c (longopts, get_some_switches): Add an optional argument
to the --merge option to choose the output formats for conflicts.
* patch.man: Document the new optional argument of --merge.
* src/merge.c (merge_hunk): Implement diff3-style conflicts.
* src/common.h (conflict_style): This global variable determines the
output format for conflicts.
* tests/merge: Add test cases for the diff3 output format.
2009-12-29 17:03:14 +01:00
Andreas Gruenbacher
ab59a14a7b * src/pch.c: When the input files to diff have CRLF line endings, the
'<' and '>' lines of normal-style diffs will have CRLF endings even
when the patch itself has not been CRLF mangled.  Do not assume a
mangled patch in this case.
* tests/crlf-handling: Update test case to cover this case.
2009-12-28 15:14:20 +01:00
Andreas Gruenbacher
59ae87bd5b * tests/create-delete: Clean up a syntactic glitch. 2009-12-28 14:28:47 +01:00
Andreas Gruenbacher
e2218ace73 * src/pch.c (intuit_diff_type): Fix regression introduced after patch
2.5.9: when none of the filenames in the old, new, and index headers
exists, patch chose the wrong filename (bug 28367).
(maybe_reverse): Return if the patch looks reversed, not if this
function toggled the reverse flag.
* tests/filename-choice: New test case.
* Makefile.in (TESTS): Add test case.
2009-12-23 00:15:30 +01:00
Andreas Gruenbacher
87f54e80e1 Clarify the message when (part of) a hunk cannot be merged 2009-10-27 16:46:25 +01:00
Andreas Gruenbacher
62d03acb14 The -m option hasn't been officially allocated yet; use only the long form for now (--merge) 2009-07-19 17:50:54 +02:00
Andreas Gruenbacher
917aa4f4f1 When the file to patch is specified on the command line, apply all patches to that file 2009-05-12 21:55:35 +02:00
Andreas Gruenbacher
da45b67685 Preserve timestamps in reject files 2009-04-07 22:03:49 +02:00
Andreas Gruenbacher
b3a9ff4f13 Fix the "patch would create" fix from 2009-03-28 2009-04-06 05:47:52 +02:00
Andreas Gruenbacher
fea737a1b5 Document that merging can be slow 2009-04-05 23:46:02 +02:00
Andreas Gruenbacher
802b26e78d Revert (almost) to the original asymmetric hunk behavior and document that 2009-04-05 20:24:04 +02:00
Andreas Gruenbacher
018b7b56c0 Remove dir_name() and base_name() in create_backup(): too many problems 2009-04-05 19:39:06 +02:00
Andreas Gruenbacher
1d204bbab2 Don't assume the target directory exists when making a backup copy 2009-04-05 17:42:20 +02:00
Andreas Gruenbacher
85cd8a4cfe Move all source and header files into src/ 2009-04-05 08:12:05 +02:00
Andreas Gruenbacher
6b2ddf184b Fix two backup file creation bugs 2009-04-04 17:24:37 +02:00
Andreas Gruenbacher
1ce9b303ce If an asymmmetric hunk starts at a line > 1, it is not from the start of the file 2009-04-03 22:28:38 +02:00
Andreas Gruenbacher
ccba56be0c Make the ed utility optional in the test suite 2009-04-03 18:53:13 +02:00
Andreas Gruenbacher
b45358fa11 Another minor merge message improvement 2009-04-03 15:58:39 +02:00
Andreas Gruenbacher
9e15efdd5e Slightly improved merge result reporting 2009-04-03 15:40:11 +02:00
Andreas Gruenbacher
dd8abc0b38 Fix two failed assertions in merge_hunk() 2009-04-02 16:00:58 +02:00
Andreas Gruenbacher
8d7f4cc344 The maximum position for a merge was computed too low 2009-04-02 14:36:28 +02:00
Andreas Gruenbacher
276afe5ec2 Add better merge support 2009-04-02 06:42:48 +02:00
Andreas Gruenbacher
e81ef4feae Locate hunks to merge more intelligently 2009-04-02 06:33:57 +02:00
Andreas Gruenbacher
b709d77ca8 Add a simple form of merge support 2009-04-02 06:25:22 +02:00
Andreas Gruenbacher
106fcaa341 Allow asymmetric hunks to apply anywhere in a file (2)
Allow such hunks to apply only when no more context remains (and the
hunk has become symmetric).
2009-04-02 05:10:56 +02:00
Andreas Gruenbacher
900dd889c0 Unset GDB in case it is set in the environment 2009-04-02 02:41:29 +02:00
Andreas Gruenbacher
0f1c530a4d Test suite: when $GDB is set, run patch in gdbserver for debugging 2009-04-02 02:40:06 +02:00
Andreas Gruenbacher
57d696a9f4 Fix line number counting and reporting
Decouple the current input and output offsets.  Count the line numbers
instead of reporting numbers that may be wrong.
2009-03-31 19:11:41 +02:00
Jim Meyering
0d4e18782d "make check" failures
tests: accommodate ls' "alternate access control method" indicator
ls can output an additional byte after a file's permissions string,
e.g., rather than "rwxr--r-- ..." it can output "rwxr--r--+ ..."
or "rwxr--r--. ..." to indicate the presence of an ACL.
* tests/create-delete: Adjust sed filter to accommodate that.
* tests/preserve-mode-and-timestamp: Likewise.
2009-03-30 07:16:05 +02:00
Andreas Gruenbacher
af57793704 Test suite and debug message fixes
* tests/test-lib.sh: Unset environment variables that influence
the behavior of patch.
* util.c (move_file): Add debug message when files have been seen
already.  Fix leftover "empty uneadable" debug message.
2009-03-30 03:11:38 +02:00
Andreas Gruenbacher
df890caf03 Prepare for second alpha release
Update NEWS.
Packaging and various other minor fixes.
2009-03-29 00:59:26 +01:00
Andreas Gruenbacher
ad80a8ed1e No more empty unreadable backup files
This is bug 25834.
2009-03-29 00:26:55 +01:00
Andreas Gruenbacher
edea71d2a7 Allow asymmetric hunks to apply anywhere in a file
This is bug 25833.
2009-03-29 00:15:12 +01:00
Andreas Gruenbacher
d85ba027a7 Fix failed `i0 != NONE' assertion and fix the create/delete/empty out checking
This is bug 25970.
2009-03-28 23:48:24 +01:00
Andreas Gruenbacher
5a0fbfa88d Add a test case for munged contex format diffs 2009-03-28 16:51:25 +01:00
Andreas Gruenbacher
8a3f4d70e4 Enforce simple backup mode and compute the backup file name if -B, -Y, or -z is used
This fixes the case where -B or -Y is combined with -z (bug 25968).
2009-03-28 16:50:09 +01:00
Andreas Gruenbacher
19947785bf When applying an empty patch to a file and -o is given, copy the input file to the output file 2009-03-28 16:48:04 +01:00
Andreas Gruenbacher
17c16b669c Avoid replacing files when nothing has changed
When a patch didn't actually modify a file (i.e., only rejects),
the file was still being replaced (bug 25969).
2009-03-28 16:35:55 +01:00
Andreas Gruenbacher
d9861a6cd9 Omit superfluous "missing header" warnings 2009-03-28 15:33:49 +01:00
Andreas Gruenbacher
1818b03d6e Cross-platform compatibility improvements 2009-03-24 18:30:58 +01:00
Andreas Gruenbacher
2acc9dd6b5 Preserve Index lines in reject files as well 2009-03-24 11:05:22 +01:00
Andreas Gruenbacher
e3e8e48b8c Don't look for filename headers in ed and normal diffs
(Those formats don't have filename headers.)
2009-03-23 03:18:38 +01:00
Andreas Gruenbacher
f10b753b70 Add test for "diff -p" context with a CRLF ine ending. 2009-03-22 20:40:39 +01:00
Andreas Gruenbacher
2684e74048 Prepare for first alpha release
Update NEWS.
Don't make $(TESTS) a prerequisite of dist: this would run the tests.
Add reminder for myself how to upload.
2009-03-22 14:30:15 +01:00
Andreas Gruenbacher
f38c7345d8 Be more strict in recognizing normal format commands 2009-03-22 13:40:15 +01:00
Andreas Gruenbacher
9e9849fde9 Require filename in patch if none specified on the command line
Unless a filename has been specified on the command line, look only
for filenames in the patch until one is found before looking for
hunks.
2009-03-22 13:40:09 +01:00
Andreas Gruenbacher
b7687446d1 Disable trailing CR stripping with --binary
Patch recognizes patches that have had their line endings converted
to CRLF and automatically strips CRs in that case.  This generally is
the desired behavior, but if both the patch and the file(s) being patched have
CRLF line endings, patches that would apply without this heuristic will fail.

Modify the --binary option to disable the trailing CR stripping heuristic.
2009-03-22 13:39:46 +01:00
Andreas Gruenbacher
6f399f7548 Remember which reject files have been created
When a patch references a file more than once, patch may override
reject files it had just created.

Avoid this by first checking whether we have created reject files
ourselves, and append to such files instead of overwriting them in
that case.  (This is similar to the backup file case except that
in the backup case, we must skip creating another backup instead
of appending.)
2009-03-22 13:39:36 +01:00
Andreas Gruenbacher
b80bfda68f Make "patch -r rejfile" work even when there are several rejects
With a patch that includes rejects in more than one file and with the -r
option, rejects would overwrite themselves and only the rejects from
the last file would remain.  Fix this.
2009-03-22 13:39:09 +01:00
Andreas Gruenbacher
9371e1ac99 No longer preserve reject file modes
No longer set reject file modes to the modes of the files they are
assiciated with: the previous behavior is inconsistent with global
reject files (-r), which are not associated with any particular file.
2009-03-22 13:39:03 +01:00