Allow patch of symlinks

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












When I try to run a patch command with a patchfile against a link, patch gives me the error:




File path/to/file is not a regular file -- refusing to patch




The following command produces this error when I have links to the files in question in my staging directory.



~> cd staging
~/staging> ls -l path/to/
lrwxrwxrwx 1 user users 15 Jan 1 00:00 file1 -> ../../../actual/path/file1
lrwxrwxrwx 1 user users 15 Jan 1 00:00 file2 -> ../../../actual/path/file2
~/staging> patch -p 1 -i ../patchfile
File path/to/file1 is not a regular file -- refusing to patch
2 out of 2 hunks ignored -- saving rejects to file path/to/file1.rej
File path/to/file2 is not a regular file -- refusing to patch
1 out of 1 hunk ignored -- saving rejects to file path/to/file2.rej


How can I tell patch not to ignore the symbolic links and patch them in-place as if they were normal files?







share|improve this question





















  • I can work around this by modifying the patch file itself, but that doesn't answer the question.
    – palswim
    Jun 14 at 21:09






  • 1




    Perhaps --follow-symlinks option.
    – Thomas Dickey
    Jun 14 at 21:18










  • Not all implementations of patch have such an option (e. g. patch provided my Mac OS).
    – DopeGhoti
    Jun 14 at 21:30










  • None of the POSIX compliant patch implementations have this option and if they would be anhanced, they did most likely implement -H/-L/-P that has been chosen by POSIX approx. 20 years ago for this purpose.
    – schily
    Jun 15 at 8:46














up vote
1
down vote

favorite












When I try to run a patch command with a patchfile against a link, patch gives me the error:




File path/to/file is not a regular file -- refusing to patch




The following command produces this error when I have links to the files in question in my staging directory.



~> cd staging
~/staging> ls -l path/to/
lrwxrwxrwx 1 user users 15 Jan 1 00:00 file1 -> ../../../actual/path/file1
lrwxrwxrwx 1 user users 15 Jan 1 00:00 file2 -> ../../../actual/path/file2
~/staging> patch -p 1 -i ../patchfile
File path/to/file1 is not a regular file -- refusing to patch
2 out of 2 hunks ignored -- saving rejects to file path/to/file1.rej
File path/to/file2 is not a regular file -- refusing to patch
1 out of 1 hunk ignored -- saving rejects to file path/to/file2.rej


How can I tell patch not to ignore the symbolic links and patch them in-place as if they were normal files?







share|improve this question





















  • I can work around this by modifying the patch file itself, but that doesn't answer the question.
    – palswim
    Jun 14 at 21:09






  • 1




    Perhaps --follow-symlinks option.
    – Thomas Dickey
    Jun 14 at 21:18










  • Not all implementations of patch have such an option (e. g. patch provided my Mac OS).
    – DopeGhoti
    Jun 14 at 21:30










  • None of the POSIX compliant patch implementations have this option and if they would be anhanced, they did most likely implement -H/-L/-P that has been chosen by POSIX approx. 20 years ago for this purpose.
    – schily
    Jun 15 at 8:46












up vote
1
down vote

favorite









up vote
1
down vote

favorite











When I try to run a patch command with a patchfile against a link, patch gives me the error:




File path/to/file is not a regular file -- refusing to patch




The following command produces this error when I have links to the files in question in my staging directory.



~> cd staging
~/staging> ls -l path/to/
lrwxrwxrwx 1 user users 15 Jan 1 00:00 file1 -> ../../../actual/path/file1
lrwxrwxrwx 1 user users 15 Jan 1 00:00 file2 -> ../../../actual/path/file2
~/staging> patch -p 1 -i ../patchfile
File path/to/file1 is not a regular file -- refusing to patch
2 out of 2 hunks ignored -- saving rejects to file path/to/file1.rej
File path/to/file2 is not a regular file -- refusing to patch
1 out of 1 hunk ignored -- saving rejects to file path/to/file2.rej


How can I tell patch not to ignore the symbolic links and patch them in-place as if they were normal files?







share|improve this question













When I try to run a patch command with a patchfile against a link, patch gives me the error:




File path/to/file is not a regular file -- refusing to patch




The following command produces this error when I have links to the files in question in my staging directory.



~> cd staging
~/staging> ls -l path/to/
lrwxrwxrwx 1 user users 15 Jan 1 00:00 file1 -> ../../../actual/path/file1
lrwxrwxrwx 1 user users 15 Jan 1 00:00 file2 -> ../../../actual/path/file2
~/staging> patch -p 1 -i ../patchfile
File path/to/file1 is not a regular file -- refusing to patch
2 out of 2 hunks ignored -- saving rejects to file path/to/file1.rej
File path/to/file2 is not a regular file -- refusing to patch
1 out of 1 hunk ignored -- saving rejects to file path/to/file2.rej


How can I tell patch not to ignore the symbolic links and patch them in-place as if they were normal files?









share|improve this question












share|improve this question




share|improve this question








edited Jun 14 at 22:42
























asked Jun 14 at 21:03









palswim

1,26611627




1,26611627











  • I can work around this by modifying the patch file itself, but that doesn't answer the question.
    – palswim
    Jun 14 at 21:09






  • 1




    Perhaps --follow-symlinks option.
    – Thomas Dickey
    Jun 14 at 21:18










  • Not all implementations of patch have such an option (e. g. patch provided my Mac OS).
    – DopeGhoti
    Jun 14 at 21:30










  • None of the POSIX compliant patch implementations have this option and if they would be anhanced, they did most likely implement -H/-L/-P that has been chosen by POSIX approx. 20 years ago for this purpose.
    – schily
    Jun 15 at 8:46
















  • I can work around this by modifying the patch file itself, but that doesn't answer the question.
    – palswim
    Jun 14 at 21:09






  • 1




    Perhaps --follow-symlinks option.
    – Thomas Dickey
    Jun 14 at 21:18










  • Not all implementations of patch have such an option (e. g. patch provided my Mac OS).
    – DopeGhoti
    Jun 14 at 21:30










  • None of the POSIX compliant patch implementations have this option and if they would be anhanced, they did most likely implement -H/-L/-P that has been chosen by POSIX approx. 20 years ago for this purpose.
    – schily
    Jun 15 at 8:46















I can work around this by modifying the patch file itself, but that doesn't answer the question.
– palswim
Jun 14 at 21:09




I can work around this by modifying the patch file itself, but that doesn't answer the question.
– palswim
Jun 14 at 21:09




1




1




Perhaps --follow-symlinks option.
– Thomas Dickey
Jun 14 at 21:18




Perhaps --follow-symlinks option.
– Thomas Dickey
Jun 14 at 21:18












Not all implementations of patch have such an option (e. g. patch provided my Mac OS).
– DopeGhoti
Jun 14 at 21:30




Not all implementations of patch have such an option (e. g. patch provided my Mac OS).
– DopeGhoti
Jun 14 at 21:30












None of the POSIX compliant patch implementations have this option and if they would be anhanced, they did most likely implement -H/-L/-P that has been chosen by POSIX approx. 20 years ago for this purpose.
– schily
Jun 15 at 8:46




None of the POSIX compliant patch implementations have this option and if they would be anhanced, they did most likely implement -H/-L/-P that has been chosen by POSIX approx. 20 years ago for this purpose.
– schily
Jun 15 at 8:46










1 Answer
1






active

oldest

votes

















up vote
1
down vote













GNU patch 2.7.1 (since 2012) has a --follow-symlinks option:




When looking for input files, follow symbolic links. Replaces the
symbolic links, instead of modifying the files the symbolic links
point to. Git-style patches to symbolic links will no longer apply.
This option exists for backwards compatibility with previous versions of patch; its use is discouraged.







share|improve this answer





















  • My version of patch (GNU patch 2.7.4 on cygwin) did not list this option in patch --help, but still supported it.
    – palswim
    Jun 14 at 22:45










  • Good answer, but that it replaces the link, rather than modifies the target file makes it not work for my case. I updated the question slightly.
    – palswim
    Jun 14 at 22:46










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449896%2fallow-patch-of-symlinks%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













GNU patch 2.7.1 (since 2012) has a --follow-symlinks option:




When looking for input files, follow symbolic links. Replaces the
symbolic links, instead of modifying the files the symbolic links
point to. Git-style patches to symbolic links will no longer apply.
This option exists for backwards compatibility with previous versions of patch; its use is discouraged.







share|improve this answer





















  • My version of patch (GNU patch 2.7.4 on cygwin) did not list this option in patch --help, but still supported it.
    – palswim
    Jun 14 at 22:45










  • Good answer, but that it replaces the link, rather than modifies the target file makes it not work for my case. I updated the question slightly.
    – palswim
    Jun 14 at 22:46














up vote
1
down vote













GNU patch 2.7.1 (since 2012) has a --follow-symlinks option:




When looking for input files, follow symbolic links. Replaces the
symbolic links, instead of modifying the files the symbolic links
point to. Git-style patches to symbolic links will no longer apply.
This option exists for backwards compatibility with previous versions of patch; its use is discouraged.







share|improve this answer





















  • My version of patch (GNU patch 2.7.4 on cygwin) did not list this option in patch --help, but still supported it.
    – palswim
    Jun 14 at 22:45










  • Good answer, but that it replaces the link, rather than modifies the target file makes it not work for my case. I updated the question slightly.
    – palswim
    Jun 14 at 22:46












up vote
1
down vote










up vote
1
down vote









GNU patch 2.7.1 (since 2012) has a --follow-symlinks option:




When looking for input files, follow symbolic links. Replaces the
symbolic links, instead of modifying the files the symbolic links
point to. Git-style patches to symbolic links will no longer apply.
This option exists for backwards compatibility with previous versions of patch; its use is discouraged.







share|improve this answer













GNU patch 2.7.1 (since 2012) has a --follow-symlinks option:




When looking for input files, follow symbolic links. Replaces the
symbolic links, instead of modifying the files the symbolic links
point to. Git-style patches to symbolic links will no longer apply.
This option exists for backwards compatibility with previous versions of patch; its use is discouraged.








share|improve this answer













share|improve this answer



share|improve this answer











answered Jun 14 at 22:16









Thomas Dickey

49k584154




49k584154











  • My version of patch (GNU patch 2.7.4 on cygwin) did not list this option in patch --help, but still supported it.
    – palswim
    Jun 14 at 22:45










  • Good answer, but that it replaces the link, rather than modifies the target file makes it not work for my case. I updated the question slightly.
    – palswim
    Jun 14 at 22:46
















  • My version of patch (GNU patch 2.7.4 on cygwin) did not list this option in patch --help, but still supported it.
    – palswim
    Jun 14 at 22:45










  • Good answer, but that it replaces the link, rather than modifies the target file makes it not work for my case. I updated the question slightly.
    – palswim
    Jun 14 at 22:46















My version of patch (GNU patch 2.7.4 on cygwin) did not list this option in patch --help, but still supported it.
– palswim
Jun 14 at 22:45




My version of patch (GNU patch 2.7.4 on cygwin) did not list this option in patch --help, but still supported it.
– palswim
Jun 14 at 22:45












Good answer, but that it replaces the link, rather than modifies the target file makes it not work for my case. I updated the question slightly.
– palswim
Jun 14 at 22:46




Good answer, but that it replaces the link, rather than modifies the target file makes it not work for my case. I updated the question slightly.
– palswim
Jun 14 at 22:46












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f449896%2fallow-patch-of-symlinks%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)