From: Junio C Hamano Date: Wed, 22 Oct 2008 00:58:11 +0000 (-0700) Subject: Merge branch 'jc/maint-co-track' X-Git-Tag: v1.6.1-rc1~115 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a157400c972bbdeab2b5629658c99839c855f5ab;p=git.git Merge branch 'jc/maint-co-track' * jc/maint-co-track: Enhance hold_lock_file_for_{update,append}() API demonstrate breakage of detached checkout with symbolic link HEAD Fix "checkout --track -b newbranch" on detached HEAD Conflicts: builtin-commit.c --- a157400c972bbdeab2b5629658c99839c855f5ab diff --cc builtin-commit.c index 33b659edc,b563a0d67..93ca49635 --- a/builtin-commit.c +++ b/builtin-commit.c @@@ -320,7 -320,8 +320,9 @@@ static char *prepare_index(int argc, co die("unable to write new_index file"); fd = hold_lock_file_for_update(&false_lock, - git_path("next-index-%"PRIuMAX, (uintmax_t) getpid()), 1); - git_path("next-index-%d", getpid()), ++ git_path("next-index-%"PRIuMAX, ++ (uintmax_t) getpid()), + LOCK_DIE_ON_ERROR); create_base_index(); add_remove_files(&partial); diff --cc t/t7201-co.sh index 82769b89f,f93478f97..0e21632f1 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@@ -330,46 -330,28 +330,60 @@@ test_expect_success test "$(git config branch.track2.merge)" git config branch.autosetupmerge false' - test_expect_success \ - 'checkout w/--track from non-branch HEAD fails' ' - git checkout -b delete-me master && - rm .git/refs/heads/delete-me && - test refs/heads/delete-me = "$(git symbolic-ref HEAD)" && - test_must_fail git checkout --track -b track' + test_expect_success 'checkout w/--track from non-branch HEAD fails' ' + git checkout master^0 && + test_must_fail git symbolic-ref HEAD && + test_must_fail git checkout --track -b track && + test_must_fail git rev-parse --verify track && + test_must_fail git symbolic-ref HEAD && + test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)" + ' + + test_expect_success 'detach a symbolic link HEAD' ' + git checkout master && + git config --bool core.prefersymlinkrefs yes && + git checkout side && + git checkout master && + it=$(git symbolic-ref HEAD) && + test "z$it" = zrefs/heads/master && + here=$(git rev-parse --verify refs/heads/master) && + git checkout side^ && + test "z$(git rev-parse --verify refs/heads/master)" = "z$here" + ' -test_expect_success 'checkout an unmerged path should fail' ' +test_expect_success \ + 'checkout with --track fakes a sensible -b ' ' + git update-ref refs/remotes/origin/koala/bear renamer && + git update-ref refs/new/koala/bear renamer && + + git checkout --track origin/koala/bear && + test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && + test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" && + + git checkout master && git branch -D koala/bear && + + git checkout --track refs/remotes/origin/koala/bear && + test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && + test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" && + + git checkout master && git branch -D koala/bear && + + git checkout --track remotes/origin/koala/bear && + test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && + test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" && + + git checkout master && git branch -D koala/bear && + + git checkout --track refs/new/koala/bear && + test "refs/heads/koala/bear" = "$(git symbolic-ref HEAD)" && + test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" +' + +test_expect_success \ + 'checkout with --track, but without -b, fails with too short tracked name' ' + test_must_fail git checkout --track renamer' + +setup_conflicting_index () { rm -f .git/index && O=$(echo original | git hash-object -w --stdin) && A=$(echo ourside | git hash-object -w --stdin) &&