summaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-11-12 19:52:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-11-12 22:16:50 (GMT)
commitfa7b3c2f752a10a5dca9989d4a1c4b93ffa7f943 (patch)
tree4d11b9d9ecba11077d0db6a837e9a069d2581323 /builtin-checkout.c
parent0d641f75d1237b34d3cfb411a18c813cfacb4726 (diff)
downloadgit-fa7b3c2f752a10a5dca9989d4a1c4b93ffa7f943.zip
git-fa7b3c2f752a10a5dca9989d4a1c4b93ffa7f943.tar.gz
git-fa7b3c2f752a10a5dca9989d4a1c4b93ffa7f943.tar.bz2
checkout: Fix "initial checkout" detection
Earlier commit 5521883 (checkout: do not lose staged removal, 2008-09-07) tightened the rule to prevent switching branches from losing local changes, so that staged removal of paths can be protected, while attempting to keep a loophole to still allow a special case of switching out of an un-checked-out state. However, the loophole was made a bit too tight, and did not allow switching from one branch (in an un-checked-out state) to check out another branch. The change to builtin-checkout.c in this commit loosens it to allow this, by not insisting the original commit and the new commit to be the same. It also introduces a new function, is_index_unborn (and an associated macro, is_cache_unborn), to check if the repository is truly in an un-checked-out state more reliably, by making sure that $GIT_INDEX_FILE did not exist when populating the in-core index structure. A few places the earlier commit 5521883 added the check for the initial checkout condition are updated to use this function. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index 05eee4e..25845cd 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -269,8 +269,7 @@ static int merge_working_tree(struct checkout_opts *opts,
}
/* 2-way merge to the new branch */
- topts.initial_checkout = (!active_nr &&
- (old->commit == new->commit));
+ topts.initial_checkout = is_cache_unborn();
topts.update = 1;
topts.merge = 1;
topts.gently = opts->merge;