aboutsummaryrefslogtreecommitdiff
path: root/checkout-index.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-11-26 00:22:48 -0800
committerJunio C Hamano <junkio@cox.net>2005-11-28 23:13:02 -0800
commitc3e9a6534c88767e2ad9126ed45598157c28d1f4 (patch)
treed47d57e8c8e90b86f7b56449daec83e69997c823 /checkout-index.c
parent61e2b01529d4cb4138c00a653006d16f7a9179ce (diff)
downloadgit-c3e9a6534c88767e2ad9126ed45598157c28d1f4.tar.gz
git-c3e9a6534c88767e2ad9126ed45598157c28d1f4.tar.xz
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>
Diffstat (limited to 'checkout-index.c')
-rw-r--r--checkout-index.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/checkout-index.c b/checkout-index.c
index dab3778a9..f1e716d41 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,
@@ -69,6 +72,10 @@ static int checkout_all(void)
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)
errs++;
}
@@ -91,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");
}
@@ -155,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)