summaryrefslogtreecommitdiff
path: root/src/checkout.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-06-15 15:47:28 -0500
committerEdward Thomson <ethomson@github.com>2016-06-15 15:47:28 -0500
commitbb0bd71ab4f404509aefa3be923916e886c9d25d (patch)
tree4c78ae017a7090f3d4af25c2641e673fcc737ae8 /src/checkout.c
parentabb6f72aaacd4edb4131d1bdb8d0965bd189ee82 (diff)
downloadlibgit2-bb0bd71ab4f404509aefa3be923916e886c9d25d.tar.gz
checkout: use empty baseline when no indexethomson/checkout_no_index
When no index file exists and a baseline is not explicitly provided, use an empty baseline instead of trying to load `HEAD`.
Diffstat (limited to 'src/checkout.c')
-rw-r--r--src/checkout.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/checkout.c b/src/checkout.c
index b3e95dff8..f39c341d4 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -2430,8 +2430,13 @@ static int checkout_data_init(
if (!data->opts.baseline && !data->opts.baseline_index) {
data->opts_free_baseline = true;
+ error = 0;
- error = checkout_lookup_head_tree(&data->opts.baseline, repo);
+ /* if we don't have an index, this is an initial checkout and
+ * should be against an empty baseline
+ */
+ if (data->index->on_disk)
+ error = checkout_lookup_head_tree(&data->opts.baseline, repo);
if (error == GIT_EUNBORNBRANCH) {
error = 0;