Skip to content

Commit a541818

Browse files
committed
fix(update): Clarify meaning of --aggressive as --recursive
When working on cargo-upgrade, I found the meaning of `--aggressive` confusing and named it `--recursive` there. Renaming this in `cargo update` (with a backwards compatible alias) was referenced in #12425.
1 parent 5522091 commit a541818

File tree

12 files changed

+22
-20
lines changed

12 files changed

+22
-20
lines changed

src/bin/cargo/commands/update.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ pub fn cli() -> Command {
99
.arg_dry_run("Don't actually write the lockfile")
1010
.arg(
1111
flag(
12-
"aggressive",
12+
"recursive",
1313
"Force updating all dependencies of SPEC as well when used with -p",
1414
)
15+
.alias("aggressive")
1516
.conflicts_with("precise"),
1617
)
1718
.arg(
@@ -41,7 +42,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
4142
}
4243

4344
let update_opts = UpdateOptions {
44-
aggressive: args.flag("aggressive"),
45+
recursive: args.flag("recursive"),
4546
precise: args.get_one::<String>("precise").map(String::as_str),
4647
to_update: values(args, "package"),
4748
dry_run: args.dry_run(),

src/cargo/ops/cargo_generate_lockfile.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct UpdateOptions<'a> {
1414
pub config: &'a Config,
1515
pub to_update: Vec<String>,
1616
pub precise: Option<&'a str>,
17-
pub aggressive: bool,
17+
pub recursive: bool,
1818
pub dry_run: bool,
1919
pub workspace: bool,
2020
}
@@ -38,8 +38,8 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
3838
}
3939

4040
pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoResult<()> {
41-
if opts.aggressive && opts.precise.is_some() {
42-
anyhow::bail!("cannot specify both aggressive and precise simultaneously")
41+
if opts.recursive && opts.precise.is_some() {
42+
anyhow::bail!("cannot specify both recursive and precise simultaneously")
4343
}
4444

4545
if ws.members().count() == 0 {
@@ -89,7 +89,7 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
8989
let mut sources = Vec::new();
9090
for name in opts.to_update.iter() {
9191
let dep = previous_resolve.query(name)?;
92-
if opts.aggressive {
92+
if opts.recursive {
9393
fill_with_deps(&previous_resolve, dep, &mut to_avoid, &mut HashSet::new());
9494
} else {
9595
to_avoid.insert(dep);

src/doc/man/cargo-update.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ will remain locked at their currently recorded versions.
3333
If `-p` is not specified, all dependencies are updated.
3434
{{/option}}
3535

36-
{{#option "`--aggressive`" }}
36+
{{#option "`--recursive`" }}
3737
When used with `-p`, dependencies of _spec_ are forced to update as well.
3838
Cannot be used with `--precise`.
3939
{{/option}}

src/doc/man/generated_txt/cargo-update.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ OPTIONS
2626

2727
If -p is not specified, all dependencies are updated.
2828

29-
--aggressive
29+
--recursive
3030
When used with -p, dependencies of spec are forced to update as
3131
well. Cannot be used with --precise.
3232

src/doc/src/commands/cargo-update.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ will remain locked at their currently recorded versions.</p>
3232
<p>If <code>-p</code> is not specified, all dependencies are updated.</dd>
3333

3434

35-
<dt class="option-term" id="option-cargo-update---aggressive"><a class="option-anchor" href="#option-cargo-update---aggressive"></a><code>--aggressive</code></dt>
35+
<dt class="option-term" id="option-cargo-update---recursive"><a class="option-anchor" href="#option-cargo-update---recursive"></a><code>--recursive</code></dt>
3636
<dd class="option-desc">When used with <code>-p</code>, dependencies of <em>spec</em> are forced to update as well.
3737
Cannot be used with <code>--precise</code>.</dd>
3838

src/doc/src/reference/resolver.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ instead.
342342
[`cargo update`] can be used to update the entries in `Cargo.lock` when new
343343
versions are published. Without any options, it will attempt to update all
344344
packages in the lock file. The `-p` flag can be used to target the update for
345-
a specific package, and other flags such as `--aggressive` or `--precise` can
345+
a specific package, and other flags such as `--recursive` or `--precise` can
346346
be used to control how versions are selected.
347347

348348
[`cargo build`]: ../commands/cargo-build.md

src/etc/_cargo

+1
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ _cargo() {
342342
update)
343343
_arguments -s -S $common $manifest \
344344
'--aggressive=[force dependency update]' \
345+
'--recursive=[force dependency update]' \
345346
"--dry-run[don't actually write the lockfile]" \
346347
'(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
347348
'--precise=[update single dependency to precise release]:release'

src/etc/cargo.bashcomp.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ _cargo()
8787
local opt__t="$opt__test"
8888
local opt__tree="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock --target -i --invert --prefix --no-dedupe --duplicates -d --charset -f --format -e --edges"
8989
local opt__uninstall="$opt_common $opt_lock $opt_pkg --bin --root"
90-
local opt__update="$opt_common $opt_mani $opt_lock $opt_pkg --aggressive --precise --dry-run"
90+
local opt__update="$opt_common $opt_mani $opt_lock $opt_pkg --aggressive --recursive --precise --dry-run"
9191
local opt__vendor="$opt_common $opt_mani $opt_lock $opt_sync --no-delete --respect-source-config --versioned-dirs"
9292
local opt__verify_project="$opt_common $opt_mani $opt_lock"
9393
local opt__version="$opt_common $opt_lock"

src/etc/man/cargo-update.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ will remain locked at their currently recorded versions.
2929
If \fB\-p\fR is not specified, all dependencies are updated.
3030
.RE
3131
.sp
32-
\fB\-\-aggressive\fR
32+
\fB\-\-recursive\fR
3333
.RS 4
3434
When used with \fB\-p\fR, dependencies of \fIspec\fR are forced to update as well.
3535
Cannot be used with \fB\-\-precise\fR\&.

tests/testsuite/cargo_update/help/stdout.log

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Usage: cargo[EXE] update [OPTIONS]
44

55
Options:
66
--dry-run Don't actually write the lockfile
7-
--aggressive Force updating all dependencies of SPEC as well when used with -p
7+
--recursive Force updating all dependencies of SPEC as well when used with -p
88
--precise <PRECISE> Update a single dependency to exactly PRECISE when used with -p
99
-q, --quiet Do not print cargo log messages
1010
-v, --verbose... Use verbose output (-vv very verbose/build.rs output)

tests/testsuite/git.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,8 @@ Caused by:
770770
.run();
771771

772772
// Updating aggressively should, however, update the repo.
773-
println!("dep1 aggressive update");
774-
p.cargo("update -p dep1 --aggressive")
773+
println!("dep1 rcursive update");
774+
p.cargo("update -p dep1 --recursive")
775775
.with_stderr(&format!(
776776
"[UPDATING] git repository `{}`\n\
777777
[UPDATING] bar v0.5.0 ([..]) -> #[..]\n\

tests/testsuite/update.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ fn update_precise_do_not_force_update_deps() {
428428
}
429429

430430
#[cargo_test]
431-
fn update_aggressive() {
431+
fn update_recursive() {
432432
Package::new("log", "0.1.0").publish();
433433
Package::new("serde", "0.2.1").dep("log", "0.1").publish();
434434

@@ -453,7 +453,7 @@ fn update_aggressive() {
453453
Package::new("log", "0.1.1").publish();
454454
Package::new("serde", "0.2.2").dep("log", "0.1").publish();
455455

456-
p.cargo("update -p serde:0.2.1 --aggressive")
456+
p.cargo("update -p serde:0.2.1 --recursive")
457457
.with_stderr(
458458
"\
459459
[UPDATING] `[..]` index
@@ -465,7 +465,7 @@ fn update_aggressive() {
465465
}
466466

467467
#[cargo_test]
468-
fn update_aggressive_conflicts_with_precise() {
468+
fn update_recursive_conflicts_with_precise() {
469469
Package::new("log", "0.1.0").publish();
470470
Package::new("serde", "0.2.1").dep("log", "0.1").publish();
471471

@@ -490,11 +490,11 @@ fn update_aggressive_conflicts_with_precise() {
490490
Package::new("log", "0.1.1").publish();
491491
Package::new("serde", "0.2.2").dep("log", "0.1").publish();
492492

493-
p.cargo("update -p serde:0.2.1 --precise 0.2.2 --aggressive")
493+
p.cargo("update -p serde:0.2.1 --precise 0.2.2 --recursive")
494494
.with_status(1)
495495
.with_stderr(
496496
"\
497-
error: the argument '--precise <PRECISE>' cannot be used with '--aggressive'
497+
error: the argument '--precise <PRECISE>' cannot be used with '--recursive'
498498
499499
Usage: cargo[EXE] update --package [<SPEC>] --precise <PRECISE>
500500

0 commit comments

Comments
 (0)