Skip to content

Commit 14e2a42

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 94770a5 commit 14e2a42

File tree

12 files changed

+23
-21
lines changed

12 files changed

+23
-21
lines changed

src/bin/cargo/commands/update.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ pub fn cli() -> Command {
2424
.arg_dry_run("Don't actually write the lockfile")
2525
.arg(
2626
flag(
27-
"aggressive",
27+
"recursive",
2828
"Force updating all dependencies of SPEC as well when used with -p",
2929
)
30+
.alias("aggressive")
3031
.conflicts_with("precise"),
3132
)
3233
.arg(
@@ -71,7 +72,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
7172
}
7273

7374
let update_opts = UpdateOptions {
74-
aggressive: args.flag("aggressive"),
75+
recursive: args.flag("recursive"),
7576
precise: args.get_one::<String>("precise").map(String::as_str),
7677
to_update,
7778
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 _spec_ is not specified, all dependencies are updated.
3434
{{/option}}
3535

36-
{{#option "`--aggressive`" }}
36+
{{#option "`--recursive`" }}
3737
When used with _spec_, 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 spec is not specified, all dependencies are updated.
2828

29-
--aggressive
29+
--recursive
3030
When used with spec, 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
@@ -31,7 +31,7 @@ will remain locked at their currently recorded versions.</p>
3131
<p>If <em>spec</em> is not specified, all dependencies are updated.</dd>
3232

3333

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

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
@@ -28,7 +28,7 @@ will remain locked at their currently recorded versions.
2828
If \fIspec\fR is not specified, all dependencies are updated.
2929
.RE
3030
.sp
31-
\fB\-\-aggressive\fR
31+
\fB\-\-recursive\fR
3232
.RS 4
3333
When used with \fIspec\fR, dependencies of \fIspec\fR are forced to update as well.
3434
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] [SPEC]...
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -769,9 +769,9 @@ Caused by:
769769
.with_stdout("")
770770
.run();
771771

772-
// Updating aggressively should, however, update the repo.
773-
println!("dep1 aggressive update");
774-
p.cargo("update dep1 --aggressive")
772+
// Updating recursively should, however, update the repo.
773+
println!("dep1 recursive update");
774+
p.cargo("update 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 serde:0.2.1 --aggressive")
456+
p.cargo("update 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 serde:0.2.1 --precise 0.2.2 --aggressive")
493+
p.cargo("update 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 --precise <PRECISE> <SPEC|--package [<SPEC>]>
500500

0 commit comments

Comments
 (0)