summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2015-02-14 10:33:06 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-02-27 13:50:32 -0500
commite6da3e4496188b36dbc83950f5e771a373c8ebcc (patch)
treec966272518558cb2fd101e01b00f264e554997ec /src/checkout.c
parent5cbe950fb8b18e930f79c81bdab0aebf21443596 (diff)
downloadlibgit2-e6da3e4496188b36dbc83950f5e771a373c8ebcc.tar.gz
checkout: upgrade to `SAFE_CREATE` when no index file
When the repository does not contain an index, emulate git's behavior and upgrade to `SAFE_CREATE`. This allows us to check out repositories created with `git clone --no-checkout`.
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/checkout.c b/src/checkout.c
index f71be26f9..6e1abce4a 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -2346,6 +2346,13 @@ static int checkout_data_init(
}
}
+ /* if the repository does not actually have an index file, then this
+ * is an initial checkout (perhaps from clone), so we allow safe updates
+ */
+ if (!data->index->on_disk &&
+ (data->opts.checkout_strategy & GIT_CHECKOUT_SAFE) != 0)
+ data->opts.checkout_strategy |= GIT_CHECKOUT_SAFE_CREATE;
+
/* if you are forcing, definitely allow safe updates */
if ((data->opts.checkout_strategy & GIT_CHECKOUT_FORCE) != 0)
data->opts.checkout_strategy |= GIT_CHECKOUT_SAFE_CREATE;