cargo_new: drop the trailing slash for target exclusion in Git
authorBen Boeckel <ben.boeckel@kitware.com>
Mon, 15 Jan 2018 22:07:56 +0000 (17:07 -0500)
committerBen Boeckel <ben.boeckel@kitware.com>
Mon, 15 Jan 2018 22:07:56 +0000 (17:07 -0500)
When `target` is a symlink (e.g., to keep build outputs on a separate
partition), Git will not match the `/target/` ignore to the symlink
since it is not a directory. Drop the trailing slash to support ignoring
`target` as a symlink.

src/cargo/ops/cargo_new.rs

index 8fc52b4c6bf6fff783508d97f6a91fd333ac3930..c0d751d38e453f906d865d63f776d25a4827de96 100644 (file)
@@ -404,7 +404,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
     let name = opts.name;
     let cfg = global_config(config)?;
     // Please ensure that ignore and hgignore are in sync.
-    let ignore = ["\n", "/target/\n", "**/*.rs.bk\n",
+    let ignore = ["\n", "/target\n", "**/*.rs.bk\n",
         if !opts.bin { "Cargo.lock\n" } else { "" }]
         .concat();
     // Mercurial glob ignores can't be rooted, so just sticking a 'syntax: glob' at the top of the