checkout-index: work from subdirectory.
With this, git-checkout-index from a subdirectory works as expected. Note that "git-checkout-index -a" checks out files only in the current directory and under. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
61e2b01529
commit
c3e9a6534c
@ -34,6 +34,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
|
|
||||||
|
static const char *prefix;
|
||||||
|
static int prefix_length;
|
||||||
|
|
||||||
static struct checkout state = {
|
static struct checkout state = {
|
||||||
.base_dir = "",
|
.base_dir = "",
|
||||||
.base_dir_len = 0,
|
.base_dir_len = 0,
|
||||||
@ -69,6 +72,10 @@ static int checkout_all(void)
|
|||||||
struct cache_entry *ce = active_cache[i];
|
struct cache_entry *ce = active_cache[i];
|
||||||
if (ce_stage(ce))
|
if (ce_stage(ce))
|
||||||
continue;
|
continue;
|
||||||
|
if (prefix && *prefix &&
|
||||||
|
( ce_namelen(ce) <= prefix_length ||
|
||||||
|
memcmp(prefix, ce->name, prefix_length) ))
|
||||||
|
continue;
|
||||||
if (checkout_entry(ce, &state) < 0)
|
if (checkout_entry(ce, &state) < 0)
|
||||||
errs++;
|
errs++;
|
||||||
}
|
}
|
||||||
@ -91,6 +98,9 @@ int main(int argc, char **argv)
|
|||||||
int newfd = -1;
|
int newfd = -1;
|
||||||
int all = 0;
|
int all = 0;
|
||||||
|
|
||||||
|
prefix = setup_git_directory();
|
||||||
|
prefix_length = prefix ? strlen(prefix) : 0;
|
||||||
|
|
||||||
if (read_cache() < 0) {
|
if (read_cache() < 0) {
|
||||||
die("invalid cache");
|
die("invalid cache");
|
||||||
}
|
}
|
||||||
@ -155,7 +165,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (all)
|
if (all)
|
||||||
die("git-checkout-index: don't mix '--all' and explicit filenames");
|
die("git-checkout-index: don't mix '--all' and explicit filenames");
|
||||||
checkout_file(arg);
|
checkout_file(prefix_path(prefix, prefix_length, arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (all)
|
if (all)
|
||||||
|
Loading…
Reference in New Issue
Block a user