Skip to content

default .gitignore from cargo new should explicitly exclude vendor/ #15352

Open
@jyn514

Description

@jyn514

Problem

cargo vendor creates a bunch of files with paths from other people's crates. people sometimes write poorly specified .gitignore files that are too broad and don't anchor specific directories; this is silly but people do silly things, see for example rust-lang/rust#138978. in this case git add vendor/ doesn't do what they expect, some of the paths are ignored.

Proposed Solution

add !/vendor to the default gitignore.

Notes

i took a look at the code for this. currently the logic lives here:

// Using the push method with multiple arguments ensures that the entries
// for all mutually-incompatible VCS in terms of syntax are in sync.
let mut ignore = IgnoreList::new();
ignore.push("/target", "^target$", "target");

it's not as simple as adding another .push line, because Fossil requires these to be configured in a separate ignore-glob file and Mercurial doesn't support this kind of thing at all. Not sure if this has interactions with pijul.

the current design makes it hard to handle two different files for include and exclude, so that would need to be refactored somehow.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-vcsArea: general VCS issuesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-initCommand-newCommand-vendorS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions