Merge branch 'jh/checkout-auto-tracking'

Fix a minor regression in v1.8.3.2 and later that made it
impossible to base your local work on anything but a local branch
of the upstream repository you are tracking from.

* jh/checkout-auto-tracking:
  t3200: fix failure on case-insensitive filesystems
  branch.c: Relax unnecessary requirement on upstream's remote ref name
  t3200: Add test demonstrating minor regression in 41c21f2
  Refer to branch.<name>.remote/merge when documenting --track
  t3200: Minor fix when preparing for tracking failure
  t2024: Fix &&-chaining and a couple of typos
This commit is contained in:
Junio C Hamano 2013-09-20 12:31:57 -07:00
Родитель 26e53f8ac0 b0f49ff130
Коммит b05fc49adc
4 изменённых файлов: 45 добавлений и 8 удалений

Просмотреть файл

@ -48,7 +48,8 @@ working tree to it; use "git checkout <newbranch>" to switch to the
new branch.
When a local branch is started off a remote-tracking branch, Git sets up the
branch so that 'git pull' will appropriately merge from
branch (specifically the `branch.<name>.remote` and `branch.<name>.merge`
configuration entries) so that 'git pull' will appropriately merge from
the remote-tracking branch. This behavior may be changed via the global
`branch.autosetupmerge` configuration flag. That setting can be
overridden by using the `--track` and `--no-track` options, and
@ -156,7 +157,8 @@ This option is only applicable in non-verbose mode.
-t::
--track::
When creating a new branch, set up configuration to mark the
When creating a new branch, set up `branch.<name>.remote` and
`branch.<name>.merge` configuration entries to mark the
start-point branch as "upstream" from the new branch. This
configuration will tell git to show the relationship between the
two branches in `git status` and `git branch -v`. Furthermore,

Просмотреть файл

@ -203,8 +203,7 @@ static int check_tracking_branch(struct remote *remote, void *cb_data)
struct refspec query;
memset(&query, 0, sizeof(struct refspec));
query.dst = tracking_branch;
return !(remote_find_tracking(remote, &query) ||
prefixcmp(query.src, "refs/heads/"));
return !remote_find_tracking(remote, &query);
}
static int validate_remote_tracking_branch(char *ref)

Просмотреть файл

@ -104,7 +104,7 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
cd repo_c &&
test_commit c_master &&
git checkout -b bar &&
test_commit c_bar
test_commit c_bar &&
git checkout -b spam &&
test_commit c_spam
) &&
@ -113,9 +113,9 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
cd repo_d &&
test_commit d_master &&
git checkout -b baz &&
test_commit f_baz
test_commit d_baz &&
git checkout -b eggs &&
test_commit c_eggs
test_commit d_eggs
) &&
git remote add repo_c repo_c &&
git config remote.repo_c.fetch \

Просмотреть файл

@ -320,8 +320,9 @@ test_expect_success 'test tracking setup (non-wildcard, matching)' '
test_expect_success 'tracking setup fails on non-matching refspec' '
git config remote.local.url . &&
git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
(git show-ref -q refs/remotes/local/master || git fetch local) &&
git config remote.local.fetch refs/heads/s:refs/remotes/local/s &&
test_must_fail git branch --track my5 local/master &&
test_must_fail git config branch.my5.remote &&
test_must_fail git config branch.my5.merge
@ -871,4 +872,39 @@ test_expect_success '--merged catches invalid object names' '
test_must_fail git branch --merged 0000000000000000000000000000000000000000
'
test_expect_success 'tracking with unexpected .fetch refspec' '
rm -rf a b c d &&
git init a &&
(
cd a &&
test_commit a
) &&
git init b &&
(
cd b &&
test_commit b
) &&
git init c &&
(
cd c &&
test_commit c &&
git remote add a ../a &&
git remote add b ../b &&
git fetch --all
) &&
git init d &&
(
cd d &&
git remote add c ../c &&
git config remote.c.fetch "+refs/remotes/*:refs/remotes/*" &&
git fetch c &&
git branch --track local/a/master remotes/a/master &&
test "$(git config branch.local/a/master.remote)" = "c" &&
test "$(git config branch.local/a/master.merge)" = "refs/remotes/a/master" &&
git rev-parse --verify a >expect &&
git rev-parse --verify local/a/master >actual &&
test_cmp expect actual
)
'
test_done