diff --git a/commands/core/core.drush.inc b/commands/core/core.drush.inc index 6f9908d474f87a24e917b7249c58b07633eac0c9..f8c638633f75dbef1789c2f30b7c2f151a433134 100644 --- a/commands/core/core.drush.inc +++ b/commands/core/core.drush.inc @@ -185,7 +185,6 @@ function core_drush_command() { ), 'options' => array( 'mode' => 'The unary flags to pass to rsync; --mode=rultz implies rsync -rultz. Default is -akz.', - 'RSYNC-FLAG' => 'Most rsync flags passed to drush sync will be passed on to rsync. See rsync documentation.', 'exclude-conf' => 'Excludes settings.php from being rsynced. Default.', 'include-conf' => 'Allow settings.php to be rsynced. Default is to exclude settings.php.', 'include-vcs' => 'Include special version control directories (e.g. .svn). Default is to exclude vcs files.', @@ -194,11 +193,14 @@ function core_drush_command() { 'exclude-other-sites' => 'Exclude all directories in "sites/" except for "sites/all" and the site directory for the site being synced. Note: if the site directory is different between the source and destination, use --exclude-sites followed by "drush rsync @from:%site @to:%site"', 'exclude-paths' => 'List of paths to exclude, seperated by : (Unix-based systems) or ; (Windows).', 'include-paths' => 'List of paths to include, seperated by : (Unix-based systems) or ; (Windows).', + '{rsync-option-name}' => "Replace {rsync-option-name} with the rsync option (or option='value') that you would like to pass through to rsync. Examples include --delete, --exclude=*.sql, --filter='merge /etc/rsync/default.rules', etc. See the rsync documentation for a complete explaination of all the rsync options and values.", + ), 'strict-option-handling' => TRUE, 'examples' => array( - 'drush rsync @dev @stage' => 'Rsync Drupal root from dev to stage (one of which must be local).', - 'drush rsync ./ @stage:%files/img' => 'Rsync all files in the current directory to the \'img\' directory in the file storage folder on stage.', + 'drush rsync @dev @stage' => 'Rsync Drupal root from Drush alias dev to the alias stage (one of which must be local).', + 'drush rsync ./ @stage:%files/img' => 'Rsync all files in the current directory to the \'img\' directory in the file storage folder on the Drush alias stage.', + 'drush -s rsync @dev @stage --exclude=*.sql --delete' => "Simulate Rsync Drupal root from the Drush alias dev to the alias stage (one of which must be local), excluding all files that match the filter '*.sql' and delete all files on the destination that are no longer on the source.", ), 'aliases' => array('rsync'), 'topics' => array('docs-aliases'), diff --git a/commands/core/rsync.core.inc b/commands/core/rsync.core.inc index eec5747b5f47252c0168950b87f80e0c5c8dcb36..48a6a877426a6bcabe041d26ee63e7432058ec1d 100644 --- a/commands/core/rsync.core.inc +++ b/commands/core/rsync.core.inc @@ -67,7 +67,7 @@ function drush_core_rsync($source, $destination, $additional_options = array()) $options .= ' ' . $original_option; } } - + // Go ahead and call rsync with the paths we determined return drush_core_exec_rsync($source_path, $destination_path, $options); } @@ -98,7 +98,7 @@ function drush_core_rsync($source, $destination, $additional_options = array()) * TRUE on success, FALSE on failure. */ function drush_core_call_rsync($source, $destination, $additional_options = array(), $include_settings_is_default = TRUE, $live_output = TRUE) { - $options = _drush_build_rsync_options($additional_options, $include_settings_is_default); + $options = _drush_build_rsync_options($additional_options, $include_settings_is_default); return drush_core_exec_rsync($source, $destination, $options, $additional_options, $live_output); } @@ -187,7 +187,7 @@ function _drush_build_rsync_options($additional_options, $include_settings_is_de } } if ((isset($test_option)) && !in_array($test_option, $options_to_exclude) && (isset($value) && !is_array($value))) { - if ($value === TRUE) { + if (($value === TRUE) || (!isset($value))) { $options .= " --$test_option"; } else { diff --git a/examples/example.aliases.drushrc.php b/examples/example.aliases.drushrc.php index 6990eb178712d48d0770f0b50123bb158be8f6ea..e153bc81c78162a42f50778bc2bbaec1a6a93cc2 100644 --- a/examples/example.aliases.drushrc.php +++ b/examples/example.aliases.drushrc.php @@ -211,6 +211,42 @@ * in fact are removed before making a backend invoke call (for example). These * kinds of values are useful in conjunction with shell aliases. See * `drush topic docs-shell-aliases` for more information on this. + * - rsync command options have specific requirements in order to + * be passed through by Drush. See the comments on the sample below: + * + * 'command-specific' => array ( + * 'core-rsync' => array ( + * + * // single-letter rsync options are placed in the 'mode' key + * // instead of adding '--mode=rultvz' to drush rsync command. + * 'mode' => 'rultvz', + * + * // multi-letter rsync options without values must be set to + * // TRUE or NULL to work (i.e. setting $VALUE to 1, 0, or '' + * // will not work). + * 'delete' => TRUE, + * + * // wrapping an option's value in "" preserves inner '' on output; + * // but is not always required. + * 'exclude' => "'*.gz'", + * + * // cannot add multiple options of same key; each key overwrites + * // the previous key's value. This 'exclude' option will overwrite + * // the previous one above. + * 'exclude' => '*.sql', + * + * // if you need multiple exludes, use an rsync exclude file + * 'exclude-from' => "'/etc/rsync/exclude.rules'", + * + * // filter options with white space must be wrapped in "" to preserve + * // the inner ''. + * 'filter' => "'exclude *.sql'", + * + * // if you need multple filter options, see rsync merge-file options + * 'filter' => "'merge /etc/rsync/default.rules'", + * ), + * ), + * * Some examples appear below. Remove the leading hash signs to enable. */ #$aliases['stage'] = array( diff --git a/includes/command.inc b/includes/command.inc index ee5e0a099196b9f0fa3d90a77d66f5f35c363045..dfec848044eab636511f4699142c63aeb0eda392 100644 --- a/includes/command.inc +++ b/includes/command.inc @@ -1593,7 +1593,12 @@ function drush_get_original_cli_args_and_options($command = NULL) { $command_options = ($command == NULL) ? array() : _drush_get_command_options($command); foreach ($command_specific_options as $key => $value) { if (!array_key_exists($key, $command_options)) { - $args[] = "--$key=$value"; + if (($value === TRUE) || (!isset($value))) { + $args[] = "--$key"; + } + else { + $args[] = "--$key=$value"; + } } } return $args;