jangle789 / git-repo

Automatically exported from code.google.com/p/git-repo
Apache License 2.0
0 stars 0 forks source link

feature request: There should be a command to remove project and project-objects not in current manifest (repo gc?) #184

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Sometimes, it is convenient to "switch" (temporarily, or sometimes permanently) 
to a different manifest (either through repo init, or switching the branch of 
the manifest project in .repo) instead of repo init-ing and repo sync-ing in a 
new path and downloading a bunch of stuff (often, duplicated work and space if 
there is a large overlap in projects in the old and new manifests).

However, even if repo deletes the working directory of the git projects outside 
of the .repo folders for projects no longer listed in the manifest, repo keeps 
all of the project and project object folders in .repo intact, taking up space.

Now I understand this is by design, it not only will save effort if you "switch 
back" to the original manifest, but it also preserves your local branches for 
projects even if you don't have the project in the new manifest, so you don't 
lose work.

However, often times, there are no "local" branches I care about, and I don't 
need those old project files anymore. Thus, most of the stuff left behind is 
just "taking up space", and it isn't easy to clean it up by hand.

However, the use case of preserving local branches is also very important, so I 
would propose a command that is something like.

repo gc (or repo cleanup or repo purge-stale-projects, if repo gc would be too 
easily confused with repo forall -c git gc).

It would removes all project and project-objects folders in .repo for projects 
not in the current manifest ONLY IF that git project has no local branches.
Maybe a command line flag to control whether a repo prune is done ahead of time 
(to remove "stale" local branches that have already been merged in), with the 
repo prune step on by default.

I think this would help save space if you have switched manifests, but still 
not cause any work to be lost in the case of you having "uncommitted" local 
branches.

Original issue reported on code.google.com by csyo...@google.com on 23 Oct 2014 at 11:37