summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-10-15 06:12:57 +0200
committernulltoken <emeric.fermas@gmail.com>2012-10-15 20:40:37 +0200
commit4d968f134b8ccd20e5a5b26ee160372076c55f5c (patch)
tree04aa9a447bb977f2d14bef0cc876ffb19f1db3e0 /src
parent1ddc537c779a5796c4ed1d5fc2e41bd38cdeb394 (diff)
downloadlibgit2-4d968f134b8ccd20e5a5b26ee160372076c55f5c.tar.gz
clone: Explicit support of no-checkout option
Diffstat (limited to 'src')
-rw-r--r--src/clone.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/clone.c b/src/clone.c
index 00e39d3b5..71931664c 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -290,6 +290,19 @@ static bool path_is_okay(const char *path)
return true;
}
+static bool should_checkout(
+ git_repository *repo,
+ bool is_bare,
+ git_checkout_opts *opts)
+{
+ if (is_bare)
+ return false;
+
+ if (!opts)
+ return false;
+
+ return !git_repository_head_orphan(repo);
+}
static int clone_internal(
git_repository **out,
@@ -298,7 +311,7 @@ static int clone_internal(
git_indexer_stats *fetch_stats,
git_indexer_stats *checkout_stats,
git_checkout_opts *checkout_opts,
- int is_bare)
+ bool is_bare)
{
int retcode = GIT_ERROR;
git_repository *repo = NULL;
@@ -321,7 +334,7 @@ static int clone_internal(
}
}
- if (!retcode && !is_bare && !git_repository_head_orphan(repo))
+ if (!retcode && should_checkout(repo, is_bare, checkout_opts))
retcode = git_checkout_head(*out, checkout_opts, checkout_stats);
return retcode;