Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent interactive mode using the --batch flag #196

Closed
wants to merge 2 commits into from

Conversation

martijnhoutman
Copy link

We sometimes encounter patches that need to be applied on different directory levels, e.g. -p0, -p1, -p2, ...

The patch command however sometimes breaks on a certain level, unable to find the file and switching to interactive mode, asking the user to enter the correct path. This breaks our continuous deployment system.

The patch command has the -t | --batch flag in order to prevent the interactive mode.

I also need to apply the patch found in #182 to be compatible with our FreeBSD systems.

…ompatiblity;

- Added --batch flag to prevent interactive mode for patches that can not be applied in different -p levels;
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 2.41% when pulling 24352c4 on uncinc:master into a3366c7 on cweagans:master.

@martijnhoutman
Copy link
Author

Hmm, the --posix flag is actually not a replacement for --no-backup-if-mismatch flag, as it prevents creating new files from patches.

Will have to search for an alternative.

@cweagans cweagans mentioned this pull request Jun 2, 2018
36 tasks
@waleedq
Copy link
Contributor

waleedq commented Dec 10, 2018

I was testing with patch utility and the -t flag, the -t flag as its documented in man-pages would "assume that patches are reversed if they look like they are." which from my understanding to the reversed patches might lead to some issues if the patch is already applied in the current version. please correct me if i am wrong about this assumption. So instead we can use the -f flag as mentioned in the 'patch' man-pages

   -f  or  --force
      Assume that the user knows exactly what he or she is doing, and do
      not ask any questions.  Skip patches whose headers do not say
      which file is to be patched; patch files even though they have the
      wrong version for the Prereq: line in the patch; and assume that
      patches are not reversed even if they look like they are.  This
      option does not suppress commentary; use -s for that.

But what's better than using -t or -f is to test the patch before applying it using the --dry-run as proposed in this pull-request

#202

This way we can use the -f flag in the dry-run test, if the test passes then we can apply the patch without -f|-t flags because we will be 100% sure that the patch will apply without any questions from 'patch'.

Thank you.

@zrhoffman
Copy link

Hmm, the --posix flag is actually not a replacement for --no-backup-if-mismatch flag, as it prevents creating new files from patches.

New files can be created using --posix, you just need to provide that file as an argument, rather than interactively.

Here it is failing interactively:
username@computer:directory [0]$ <non-unified-patch patch --posix
can't find file to patch at input line 1
File to patch: example-file
example-file: No such file or directory
Skip this patch? [y]
Skipping patch.
1 out of 1 hunk ignored
Here it is succeeding when a filename is provided:
username@computer:directory [0]$ <non-unified-patch patch --posix example-file
patching file example-file

All of the unit and acceptance tests pass for me in Travis CI, not sure why an acceptance test failed before.

@cweagans
Copy link
Owner

cweagans commented Feb 4, 2023

We've been doing this for a while, I think. #447 has more support for individual arguments passed to various patchers. If you'd like, take a look at src/Patcher/* to make sure things are captured properly.

@cweagans cweagans closed this Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants