369 Commits

Author SHA1 Message Date
Andreas Gruenbacher
bbb840edca Version 2.7.1 v2.7.1 2012-09-28 18:39:33 +02:00
Andreas Gruenbacher
6214f5e222 build: update gnulib submodule to latest 2012-09-28 18:39:33 +02:00
Andreas Gruenbacher
fc5ddce20e Repair 'backup of unmodified file' test
tests/create-delete: Repair 'backup of unmodified file' test.
2012-09-28 18:39:33 +02:00
Andreas Gruenbacher
ac59899327 Use gnulib errno module instead of our own default ENOTSUP fallback
* bootstrap.conf (gnulib_modules): Add errno module.
* src/common.h: Remove ENOTSUP fallback.
2012-09-28 16:00:04 +02:00
Andreas Gruenbacher
c9de555284 Trailing whitespace fix
* NEWS: Trailing whitespace fix.
2012-09-28 12:43:42 +02:00
Andreas Gruenbacher
e8bfce6547 Improve the previous commit
* src/patch.c: Only print the "file is not empty after patch" message when
trying to delete the output file.  Say that we were trying to delete the file.
* tests/create-delete: Fix the expected messages.  Add test cases for the
--remove-empty-files and --posix options.
* NEWS: Better describe this change.
2012-09-26 01:33:22 +02:00
Andreas Gruenbacher
1d9ed51e9c Only expect files to become empty if the patch says so
Test cases based on patches from Dmitry V. Levin <ldv@altlinux.org>.
* src/patch.c (main): Only expect files to become empty if the patch says so.
* NEWS: Document this change.
* tests/create-delete: Add (more) empty vs. non-empty test cases.
2012-09-25 04:07:53 +02:00
Jim Meyering
b272c2d535 build: avoid gcc warnings from -Wsuggest-attribute=format
* configure.ac (WARN_CFLAGS): Disable -Wsuggest-attribute=format,
to avoid some warnings that are not worth working around.
2012-09-22 21:35:04 +02:00
Andreas Gruenbacher
89e5f702eb Update NEWS
* NEWS: Update.
2012-09-22 20:34:53 +02:00
Andreas Gruenbacher
3ccb16e10b Improve messages when in --dry-run mode
* src/patch.c (main): Say that we are checking a file and not that we are
patching it in --dry-run mode.  Don't say "saving rejects to file" when we
don't create reject files.
* tests/reject-format: Add rejects with --dry-run test case.
* tests/bad-filenames, tests/fifo, tests/mixed-patch-types: Update.
2012-09-22 20:10:53 +02:00
Andreas Gruenbacher
db1bd7f693 Improve handling of LF vs. CRLF line endings
* src/patch.c (check_line_endings): New function.
(main): When a hunk fails, report when the line endings differ between the
input file and the patch.
* src/pch.c (there_is_another_patch): When saying that we strip trailing CRs,
also say how to turn this off.
* tests/crlf-handling: Update changed messages.  Add test case that fails.
2012-09-22 20:02:48 +02:00
Andreas Gruenbacher
d24f630fbc Ignore when preserving extended attributes is not supported or allowed
* src/common.h (ENOTSUP): Make sure this error code is defined.
* src/util.c (set_file_attributes): Ignore ENOSYS, ENOTSUP, and EPERM errors.
2012-09-22 18:32:10 +02:00
Andreas Gruenbacher
1d9d403394 Add a missing explanation in the tests/crlf-handling test case
* tests/crlf-handling: Add explanation.
2012-09-20 04:34:40 +02:00
Andreas Gruenbacher
293415dbcf Add --follow-symlinks option for backwards compatibility
* src/common.h (follow_symlinks): New variable.
* src/patch.c (longopts): Add new --follow-symlinks option.
(get_some_switches): Recognize the new option.
* src/util.c (stat_file): Follow symlinks if requested.
* patch.man: Document the new option.
* tests/symlinks: Add test case.
2012-09-19 03:16:07 +02:00
Andreas Gruenbacher
59609b50c5 Introduce function to lstat all input files
* src/util.c (stat_file): New function.
(move_file): Use here.
* src/util.h (stat_file): Declare here.
* src/inp.c (get_input_file): Use here.
* src/patch.c (main): Use here.
(delete_file_later): Use here.
* src/pch.c (there_is_another_patch): Use here.
(intuit_diff_type): Use here.
2012-09-19 03:07:31 +02:00
Andreas Gruenbacher
b578985c3c Use stat where we want to follow symlinks
* src/pch.c (prefix_components): Follow symlinks.
(cwd_is_root): Follow symlinks.
2012-09-19 02:51:23 +02:00
Andreas Gruenbacher
3b934d6903 Document command-line options in alphabetic order
* patch.man: The options are mostly listen in alphabetical order; stick to
that.
2012-09-19 02:51:23 +02:00
Andreas Gruenbacher
99f2638763 Fix file truncation when switching from git diff to non-git diff
* src/patch.c (main): Output queued output files only when switching from a git
diff to a non-git diff.  This can modify the input file, so make sure to
stat() it again.
* tests/concat-git-diff: Add test case growing a file with a git diff and then
with a non-git diff; without this fix; the result would be truncated.
2012-09-18 12:53:38 +02:00
Andreas Gruenbacher
0f22a35cec Rename get_input_file() parameter to clarify code
* src/inp.c (get_input_file): Rename mode parameter to file_type, it's all we
care about here.
2012-09-18 00:48:01 +02:00
Andreas Gruenbacher
4c7c0976ac Improve error message when patching a file of different type
* src/inp.c (get_input_file): Improve error message when patching a file of
different type.
* tests/symlinks: Update test case.
2012-09-18 00:48:01 +02:00
Andreas Gruenbacher
95f6823325 Minor test case updates
* tests/dash-o-append: Minor update (still expected to fail).
* tests/symlinks: Minor update.
2012-09-18 00:47:30 +02:00
Andreas Gruenbacher
1ea53aae17 Disable xattrs if libattr doesn't implement attr_copy_action()
* m4/xattr.m4 (gl_FUNC_XATTR): Only enable USE_XATTR if both attr_copy_file()
and attr_copy_action() are defined.
* src/util.c (copy_attr_check): No fallback needed if attr_copy_action() is not
defined.
2012-09-17 17:04:20 +02:00
Andreas Gruenbacher
20c9d7d5ab Allow to use potentially dangerous filenames from the root directory
* src/pch.c (cwd_is_root): New function to check if we are in the root
directory of a filename.
(name_is_valid): Allow to use potentially dangerous filenames when the current
working directory is the root directory: from there, those names are not
any more dangerous than other names.
* tests/bad-filenames: New test case.
2012-09-17 15:48:06 +02:00
Andreas Gruenbacher
2b2fb1f36c Update leftover license notice in README
* README: Change leftover GPLv2 license notice to GPLv3.
2012-09-14 11:39:09 +02:00
Andreas Gruenbacher
543906f1a4 Check if libattr implements attr_copy_action()
* m4/xattr.m4 (gl_FUNC_XATTR): Check if attr_copy_action() is defined.
* src/util.c: If attr_copy_action() doesn't exist, fall back to the default
copy_attr_file() behavior of copying most extended attributes except ACLs.
2012-09-14 11:39:02 +02:00
Andreas Gruenbacher
f0388d2dbf Change the type of *_needs_removal from int to bool 2012-09-13 16:34:58 +02:00
Andreas Gruenbacher
281537bcd9 In a git-style diff, make sure not to unlink the original by accident
* src/patch.c (main): Fail if a file is not empty as expected.
(output_files): In a git-style diff, make sure not to unlink the original when
making a backup of an unmodified file.
* tests/create-delete: Fix failed-file-deletion test and add
successful-file-deletion test.
2012-09-13 16:32:53 +02:00
Andreas Gruenbacher
dc3cdeebca Do not pass file type in mode of open(..., O_CREAT, mode)
* src/patch.c (main): Strip file type off of create mode for temporary output
files: some systems don't ignore the file type; we want to create a regular
file even when patching a symlink.
2012-09-13 16:31:25 +02:00
Andreas Gruenbacher
474bb7d333 Add note on GPLv3 license change in version 2.6
* NEWS: Add note.
2012-09-13 14:38:38 +02:00
Andreas Gruenbacher
58ec5b5643 Version 2.7
* NEWS: Update.
v2.7
2012-09-12 11:35:43 +02:00
Andreas Gruenbacher
e4b9ff4cfe maint: update gnulib submodule 2012-09-12 11:35:03 +02:00
Andreas Gruenbacher
66aeedee12 Support double-quoted filenames in all context diff formats
* src/util.c (fetchname): Always recognize double-quoted filenames.
* src/util.h (fetchname): Update prototype.
* src/pch.c (intuit_diff_type): Update calls to fetchname().
* tests/quoted-filenames: Change to a normal unified diff.
* NEWS: Update.
2012-08-11 11:09:11 +02:00
Andreas Gruenbacher
9a37354cc6 Remove SHA1 hashes from the file id cache
* src/util.c (file_id): Remove sha1 field.
(update_sha1, lookup_sha1): Remove functions.
* src/util.h (update_sha1, lookup_sha1): Remove declarations.
2012-08-08 13:39:19 +02:00
Andreas Gruenbacher
a18960d31e Detect concatenated git-style patches by tracking what's in the output queue
* src/patch.c (main): Instead of looking at the SHA hashes to detect
concatenated git-style patches, detect when a file to write to is already in
the output queue.
* tests/concat-git-diff: Add create/delete tests.
2012-08-08 13:39:08 +02:00
Andreas Gruenbacher
e294241b86 In the file id cache, allow to flag files in the output queue
* src/util.c (file_id): Add queued_output field.
(__insert_file_id): Initialize queued_output.
(set_queued_output, has_queued_output): New functions.
* src/util.h (set_queued_output, has_queued_output): Declare.
2012-08-08 13:10:41 +02:00
Dmitry V. Levin
3980c923dc Add another git-style diff concatenation regression test
* tests/concat-git-diff: Add test case here.
2012-08-08 13:02:31 +02:00
Andreas Gruenbacher
a3f2ca32c3 maint: ignore more build artifacts 2012-08-08 01:41:42 +02:00
Andreas Gruenbacher
81d006fe4b Change outst variable name to tmpoutst to be less misleading
* src/patch.c (main): Rename outst to tmpoutst.
2012-08-07 22:38:32 +02:00
Andreas Gruenbacher
1e6c0d07ab In git-style diffs, create new files immediatetly and only remember files to modify
* src/patch.c (output_file): Create new files immediately.  Document why
things are implemented that way.
* tests/concat-git-diff: Fix glitch in test case.
2012-08-02 20:38:31 +02:00
Jim Meyering
cdc94fade3 Don't close a negative file descriptor
* src/inp.c (re_input): Don't close FD if it's negative.
2012-08-01 15:51:54 +02:00
Andreas Gruenbacher
120927804d Add file create test case which still needs to be fixed
* tests/concat-git-diff: Add file create test case.
2012-08-01 15:10:22 +02:00
Jim Meyering
46e58be9cc build: remove unnecessary if-before-free
* src/util.c (update_sha1): Remove unnecessary if-before-free,
to avoid "make syntax-check" failure.
2012-08-01 15:05:42 +02:00
Jim Meyering
1118f832ef build: mark an internal function as "pure"
* src/pch.c (sha1_says_nonexistent): Apply _GL_ATTRIBUTE_PURE,
to avoid failure with -Werror=suggest-attribute=pure.
2012-08-01 15:05:42 +02:00
Andreas Gruenbacher
386ae15bce maint: update bootstrap and gnulib submodule
* bootstrap: Update from gnulib.
2012-08-01 04:50:00 +02:00
Andreas Gruenbacher
6be1a126bd Try to recognize concatenated git diffs and handle them appropriately
* src/patch.c (main): Remember the "before" SHA1 hashes of git-style patches;
the same patch will always use the same "before" SHA1 for a specific file.
Try to recognize concatenated patches based on that.
* tests/concat-git-diff: New test case.
* tests/Makefile.am (TESTS): Add new test case.
2012-08-01 04:28:07 +02:00
Andreas Gruenbacher
57eb3007ab Allow to process only part of the deferred output file list
* src/patch.c (output_files): Add parameter to specify which file to stop at.
(main): Pass NULL to output_files() to process the entire list.
2012-08-01 04:25:16 +02:00
Andreas Gruenbacher
ea4212ee51 Allow to remember SHA1 hashes in the file id cache
* src/util.c (file_id): New sha1 field.
(__insert_file_id): Split off from insert_file_id().  Initialize sha1 field.
(__lookup_file_id): Split off from lookup_file_id().
(update_sha1): Remember SHA1 hash of a file or update the remembered SHA1 hash.
(lookup_sha1): Look up the SHA1 hash of a file.
* src/util.h (update_sha1, lookup_sha1): Declare.
2012-07-31 21:58:30 +02:00
Andreas Gruenbacher
b0c22022be Accessor functions for SHA1 hashes in git-style diffs
* src/pch.c (p_sha1): New variable.
(get_sha1): New function for saving a sha1 checksum.
(sha1_says_nonexistent): Take a NULL terminated string instead of an end
pointer.
(intuit_diff_type): Remember the SHA1 hashes from index headers in git-style
diffs in p_sha1.
(pch_sha1): New function for accessing p_sha1.
* src/pch.h (pch_sha1): Declare.
2012-07-31 21:58:30 +02:00
Andreas Gruenbacher
6e21796422 Add missing "diff --git" index lines
* tests/copy-rename, tests/criss-cross, tests/file-modes,
tests/mixed-patch-types, tests/quoted-filenames: Add missing index lines in the
"dif --git" test cases: We will use some of them for consistency checks soon.
2012-07-31 21:58:24 +02:00
Andreas Gruenbacher
90d4e1f3d5 Fix segfault in output_file_later()
Bug reported by Dmitry V. Levin <ldv@altlinux.org>.
* src/patch.c (output_file_later): Fix case where the output file is identical
with the input file (and to == NULL).
2012-04-24 12:37:26 +02:00