| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
| |
* src/safe.c (traverse_another_path): Don't report errors here.
* src/patch.c (main): Instead, recognize and report them here. Detect when an
output file name is invalid; it doesn't make sense to try creating a
reject file based on the same outbut file name in that case.
|
| |
|
|
|
|
|
| |
* src/util.c (make_tempfile): Remove error reporting here.
* src/inp.c (plan_b): Readd error reporting here.
* src/patch.c (main): Likewise.
* src/pch.c (open_patch_file): Likewise.
|
| |
|
|
|
|
|
|
| |
When a file has already been renamed, make sure it is not renamed back to its
old name. Reported by Guido Draheim.
* src/patch.c (main): Make sure we never rename a file back to its previous
name. Report when a file was renamed already.
* tests/copy-rename: Add "already renamed" test cases.
|
| |
|
|
|
|
| |
mode change.
Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
|
| |
|
|
|
|
|
|
|
| |
Use the symlink-safe replacements for system calls in many places throughout
the code: In some places this makes patch safe against path traversal attacks;
in other places, it saves the kernel from having to re-traverse the pathnames.
* src/inp.c (plan_b): Use safe_open() + fdopen() instead of fopen().
* src/util.c (copy_attr): Document why we are safe here.
(create_backup): Use safe_open() instead of creat().
|
| |
|
|
|
| |
* src/patch.c (main): Make sure we don't close() outfd after passing it on to
fdopen(): the file descriptor might have been reused in the meantime.
|
| |
|
|
|
|
|
|
|
| |
* src/patch.c (main): Allow there_is_another_patch() to set the
skip_rest_of_patch flag.
* src/pch.c (intuit_diff_type): For renames and copies, also check the "other"
file name.
(pch_copy, pch_rename): Now that both names are checked in intuit_diff_type(),
we know they are defined here.
|
| |
|
|
|
|
| |
* src/patch.c (locate_hunk): Start trying to apply the hunk at the minimum
offset which puts the hunk in the valid range of lines. This will often still
be offset 0.
|
| |
|
|
|
|
|
|
| |
* src/patch.c (get_some_switches): The function savebuf (and therefore savestr)
copies strings using malloc. If malloc fails, NULL is returned. This is
intentional behavior so that in case of failure during "plan a" patching, "plan
b" can step in. The return value has to be properly checked for NULL. If the
return value must not be NULL, use xstrdup instead.
|
| |
|
|
|
| |
* src/patch.c: Improve error message.
* tests/create-delete: Update the test case.
|
| |
|
|
|
| |
* src/patch.c (option_help): The --merge option does not have a short
form; update the help text.
|
| |
|
|
|
|
|
| |
* src/patch.c (main): Preserve function names in reject files.
* tests/reject-format: Update the test case.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andreas Gruenbacher <agruen@linbit.com>
|
| |
|
|
|
|
|
|
|
| |
Reported by Thomas Moschny <thomas.moschny@gmx.de>:
src/patch.c (main): Temporary output files are created in the same directory as
the output file. Make sure to remove them before removing empty files and
their empty ancestor directories; else the directories won't be empty.
tests/remove-directories: Add directory removal test case.
tests/Makefile.am (TESTS): Add new test case.
|
| |
|
|
|
|
|
| |
* src/patch.c (main): Initialize data structures early enough, before error
paths can access them.
* tests/bad-usage: Test bad command line usage.
* tests/Makefile.am (TESTS): Add bad-usage here.
|
| |
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
|
| |
* 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.
|
| | |
|
| |
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
| |
* 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.
|
| |
|
|
|
|
|
| |
* 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.
|
| |
|
|
| |
* src/patch.c (main): Rename outst to tmpoutst.
|
| |
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
* 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.
|
| |
|
|
|
| |
* 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.
|
| |
|
|
|
|
| |
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).
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Failing when trying to patch read-only files causes various users of patch to
break. Instead, warn by default and introduce a command line option for
choosing a different behavior.
* patch.man: Describe the new behavior and command-line option.
* src/patch.c (read_only_behavior): New variable.
(main): Implement the new behavior.
(longopts): Add the new --read-only option.
(option_help): Describe the new behavior.
(get_some_switches): Recognize the new --read-only option.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In git-style patch files, all patches refer to the initial state of the input
files; files cannot be modified more than once. Implement these semantics by
creating all output files once all patches in the patch file have been
processed.
* src/patch.c (init_files_to_output, output_files): Add prototypes.
(main): Remember which type of patch file we are processing. Initialize the
output files list. Output files of git-style patches once all patches have
been read, or when from git-style to normal patches.
(file_to_output): New struct.
(files_to_output): List of the files to output.
(output_file, output_file_now, output_file_later): Either queue a file for
deletion, remember to output a file later (git-style), or output the file
immediately (normal).
(dispose_file_to_output, init_files_to_output, output_files,
forget_output_files): New functions.
(gl_list_clear): Should be provided by gnulib but isn't.
(cleanup): Clean up any left-over temporary output files as well.
* tests/Makefile-am (XFAIL_TESTS): Remove criss-cross; this test case works now.
* tests/mixed-patch-types: Patch files that change from normal to git-style, or
from git-style to normal.
|
| |
|
|
|
|
|
|
|
|
| |
Remembering backup files was needed because we would have lost track of deleted
files before -- but we don't delete files immediately anymore.
* src/util.c (create_backup_copy): No longer remember backup files.
(create_backup): Likewise; update comment.
(move_file): Update create_backup() call.
* src/util.h (create_backup): Update prototype.
* src/patch.c (output_file): Update create_backup() call.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Fixes the bug that more than one numbered backup would be created when a patch
file deletes and recreates a file.
* bootstrap.conf (gnulib_modules): Add linked-list and xlist modules.
* src/util.h (file_id_type): Add DELETE_LATER and OVERWRITTEN types.
(create_backup, set_file_attributes): Update prototype.
(insert_file_id): Add prototype.
* src/util.c (insert_file_id): Export.
(set_file_attributes, create_backup_copy): Make the st argument const.
(create_backup): Pass in to_st instead of returning it from create_backup().
This obsoletes the to_errno argument.
(move_file): Determine to_st here and pass it to create_backup(). Remember
when a file is overwritten.
* src/patch.c (output_file): Add to_st parameter. Remember files to delete
instead of deleting them immediately. Pass from-st to create_backup().
(file_to_delete): New struct.
(init_files_to_delete, delete_file_later, delete_files): New functions.
(main): Use init_files_to_delete() and delete_files(). Pass to_st to
output_file() where we already have it.
* src/pch.c (intuit_diff_type): Assume that files which are marked for deletion
don't exist.
|
| |
|
|
|
|
|
| |
* src/patch.c (output_file): New function for creating or deleting an output
file and backing the old file up as needed.
(main): Use the new function.
* src/util.c (move_file): Allow FROM_NEEDS_REMOVAL to be NULL.
|
| |
|
|
|
|
|
|
|
|
|
| |
* src/util.h (file_id_type): New enum.
* src/util.c (file_id): Add a file_id_type field.
(insert_file_id): Rename from insert_file(); specify a type when inserting a
file id.
(lookup_file_id): Rename from file_id_exists(); return a file id type.
(create_backup_copy, create_backup, move_file): Use insert_file_id() instead of
insert_file(), and lookup_file_id() instead of file_already_seen().
* src/patch.c (main): Use lookup_file_id() instead of file_already_seen().
|
| |
|
|
|
| |
* src/common.h, src/patch.c, src/pch.c, src/util.c, src/util.h: Switch from the
`old' gnu quoting style to the 'new' one in messages and comments.
|
| |
|
|
|
|
| |
* cfg.mk (local-checks-to-skip): Remove sc_useless_cpp_parens,
thus enabling this syntax-check rule.
* src/patch.c: Remove unneeded parentheses.
|
| |
|
|
| |
Run "make update-copyright".
|
| |
|
|
|
|
|
|
|
|
|
| |
* src/util.h (enum file_attributes): Add FA_XATTRS flag for extended
attributes.
* src/patch.c (main): Use set_file_attributes() even when the infile doesn't
exist: it may still set the file time (FA_TIMES). Omit all other FA_ flags if
infile doesn't exist. Otherwise, add FA_XATTRS as well.
* src/util.c (set_file_attributes): Only copy extended attributes if FA_XATTRS
is set. Avoid using st where it may be undefined.
* tests/preserve-mode-and-timestamp: Add file create test.
|
| |
|
|
|
| |
* src/patch.c (open_outfile): If dup fails, don't clobber its
errno value by calling fdopen with -1.
|
| |
|
|
|
|
|
|
|
|
| |
* src/patch.c (main): Call set_program_name rather than
initializing program_name explicitly.
* src/common.h: Include progname.h rather than declaring the extern,
program_name.
* bootstrap.conf (gnulib_modules): Add progname.
* cfg.mk (local-checks-to-skip): Remove sc_program_name,
thus enabling this test.
|
| |
|
|
|
| |
* bootstrap.conf (gnulib_modules): Add update-copyright.
Run "make update-copyright".
|
| |
|
|
|
|
| |
* src/patch.c (mangled_patch): Add "noreturn" attribute.
* src/pch.h (pch_timestamp): Remove ignored "const" attribute.
* src/version.c (XTERN): Remove unused #undef and #define.
|
| |
|
|
|
|
|
|
| |
There is no longer any need to avoid "free(NULL)" (since SunOS 4),
so replace each "if (P) free (P);" with "free (P);".
* src/inp.c (get_input_file): Remove unnecessary test-before-free.
* src/patch.c (get_some_switches): Likewise.
* src/pch.c (intuit_diff_type, pch_swap): Likewise.
|
| |
|
|
|
| |
* src/patch.c (main): Fix use of initialized outst and add an
additional assert. Reported by Jim Meyering.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* src/patch.c (main): Set all file attributes of the temporary output
file before renaming it over the final output file (possibly replacing
the input file). Pass the input file name to set_file_attributes().
* src/util.c (set_file_attributes): When enabled (USE_XATTR), also
copy extended attributes including attributes which define
permissions.
(copy_attr_error, copy_attr_quote, copy_attr_free, copy_attr_check,
copy_attr): Helper functions for copying extended attributes.
* m4/xattr.m4 (gl_FUNC_XATTR): Import from coreutils.
* src/Makefile.am (patch_LDADD): Add $(LIB_XATTR) here.
* bootstrap.conf: Use the gnulib verror module.
|
| |
|
|
| |
* src/patch.c (print_header_line): Remove obsolete comment.
|
| |
|
|
|
|
|
|
|
| |
* src/patch.c (main): Generate the "patching file" message here. When
the input and output file name is not he same, include both names in
the message.
* src/inp.c (scan_input): Previously the "patching file" message was
generated here.
* tests/unmodified-files, tests/copy-rename: Update.
|
| |
|
|
|
| |
* src/patch.c (main): Compute TMPOUTNAME with make_tempfile().
(make_temp): Remove obsolete function.
|