X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=checkout-index.c;h=f1e716d4126c7dc9a0fd1be665dee9f8d0fbc87e;hb=706fe6ae03e2c1452d59892944701c56237b903f;hp=596d320fb67983a7f899f184024dde26caec956e;hpb=a65a686f4967ecba0759289d0e918f652980e8a2;p=git.git diff --git a/checkout-index.c b/checkout-index.c index 596d320f..f1e716d4 100644 --- a/checkout-index.c +++ b/checkout-index.c @@ -34,6 +34,9 @@ */ #include "cache.h" +static const char *prefix; +static int prefix_length; + static struct checkout state = { .base_dir = "", .base_dir_len = 0, @@ -63,15 +66,24 @@ static int checkout_file(const char *name) static int checkout_all(void) { - int i; + int i, errs = 0; for (i = 0; i < active_nr ; i++) { struct cache_entry *ce = active_cache[i]; if (ce_stage(ce)) continue; + if (prefix && *prefix && + ( ce_namelen(ce) <= prefix_length || + memcmp(prefix, ce->name, prefix_length) )) + continue; if (checkout_entry(ce, &state) < 0) - return -1; + errs++; } + if (errs) + /* we have already done our error reporting. + * exit with the same code as die(). + */ + exit(128); return 0; } @@ -86,6 +98,9 @@ int main(int argc, char **argv) int newfd = -1; int all = 0; + prefix = setup_git_directory(); + prefix_length = prefix ? strlen(prefix) : 0; + if (read_cache() < 0) { die("invalid cache"); } @@ -150,7 +165,7 @@ int main(int argc, char **argv) if (all) die("git-checkout-index: don't mix '--all' and explicit filenames"); - checkout_file(arg); + checkout_file(prefix_path(prefix, prefix_length, arg)); } if (all)