1 |
Remove the code responsible for recognizing which branch HEAD pointed |
2 |
out to since it was unsafe and unnecessarily complex. A proper match is |
3 |
not really necessary since all operations can be safely performed on |
4 |
an opaque 'HEAD' (or rather refs/git-r3/HEAD since fetching to HEAD |
5 |
directly breaks git a bit). |
6 |
--- |
7 |
eclass/git-r3.eclass | 62 ++++------------------------------------------------ |
8 |
1 file changed, 4 insertions(+), 58 deletions(-) |
9 |
|
10 |
diff --git a/eclass/git-r3.eclass b/eclass/git-r3.eclass |
11 |
index 51f0ae5..e38284e 100644 |
12 |
--- a/eclass/git-r3.eclass |
13 |
+++ b/eclass/git-r3.eclass |
14 |
@@ -410,42 +410,6 @@ _git-r3_is_local_repo() { |
15 |
[[ ${uri} == file://* || ${uri} == /* ]] |
16 |
} |
17 |
|
18 |
-# @FUNCTION: _git-r3_find_head |
19 |
-# @USAGE: <head-ref> |
20 |
-# @INTERNAL |
21 |
-# @DESCRIPTION: |
22 |
-# Given a ref to which remote HEAD was fetched, try to find |
23 |
-# a branch matching the commit. Expects 'git show-ref' |
24 |
-# or 'git ls-remote' output on stdin. |
25 |
-_git-r3_find_head() { |
26 |
- debug-print-function ${FUNCNAME} "$@" |
27 |
- |
28 |
- local head_ref=${1} |
29 |
- local head_hash=$(git rev-parse --verify "${1}" || die) |
30 |
- local matching_ref |
31 |
- |
32 |
- # TODO: some transports support peeking at symbolic remote refs |
33 |
- # find a way to use that rather than guessing |
34 |
- |
35 |
- # (based on guess_remote_head() in git-1.9.0/remote.c) |
36 |
- local h ref |
37 |
- while read h ref; do |
38 |
- # look for matching head |
39 |
- if [[ ${h} == ${head_hash} ]]; then |
40 |
- # either take the first matching ref, or master if it is there |
41 |
- if [[ ! ${matching_ref} || ${ref} == refs/heads/master ]]; then |
42 |
- matching_ref=${ref} |
43 |
- fi |
44 |
- fi |
45 |
- done |
46 |
- |
47 |
- if [[ ! ${matching_ref} ]]; then |
48 |
- die "Unable to find a matching branch for remote HEAD (${head_hash})" |
49 |
- fi |
50 |
- |
51 |
- echo "${matching_ref}" |
52 |
-} |
53 |
- |
54 |
# @FUNCTION: git-r3_fetch |
55 |
# @USAGE: [<repo-uri> [<remote-ref> [<local-id>]]] |
56 |
# @DESCRIPTION: |
57 |
@@ -623,26 +587,10 @@ git-r3_fetch() { |
58 |
set -- "${fetch_command[@]}" |
59 |
echo "${@}" >&2 |
60 |
if "${@}"; then |
61 |
- if [[ ${clone_type} == mirror ]]; then |
62 |
- # find remote HEAD and update our HEAD properly |
63 |
- git symbolic-ref HEAD \ |
64 |
- "$(_git-r3_find_head refs/git-r3/HEAD \ |
65 |
- < <(git show-ref --heads || die))" \ |
66 |
- || die "Unable to update HEAD" |
67 |
- else # single or shallow |
68 |
- if [[ ${fetch_l} == HEAD ]]; then |
69 |
- # find out what branch we fetched as HEAD |
70 |
- local head_branch=$(_git-r3_find_head \ |
71 |
- refs/git-r3/HEAD \ |
72 |
- < <(git ls-remote --heads "${r}" || die)) |
73 |
- |
74 |
- # and move it to its regular place |
75 |
- git update-ref --no-deref "${head_branch}" \ |
76 |
- refs/git-r3/HEAD \ |
77 |
- || die "Unable to sync HEAD branch ${head_branch}" |
78 |
- git symbolic-ref HEAD "${head_branch}" \ |
79 |
+ if [[ ${clone_type} == mirror || ${fetch_l} == HEAD ]]; then |
80 |
+ # update our HEAD to match our remote HEAD ref |
81 |
+ git symbolic-ref HEAD refs/git-r3/HEAD \ |
82 |
|| die "Unable to update HEAD" |
83 |
- fi |
84 |
fi |
85 |
|
86 |
# now let's see what the user wants from us |
87 |
@@ -768,9 +716,7 @@ git-r3_checkout() { |
88 |
# setup 'alternates' to avoid copying objects |
89 |
echo "${orig_repo}/objects" > "${GIT_DIR}"/objects/info/alternates || die |
90 |
# now copy the refs |
91 |
- # [htn]* safely catches heads, tags, notes without complaining |
92 |
- # on non-existing ones, and omits internal 'git-r3' ref |
93 |
- cp -R "${orig_repo}"/refs/[htn]* "${GIT_DIR}"/refs/ || die |
94 |
+ cp -R "${orig_repo}"/refs/* "${GIT_DIR}"/refs/ || die |
95 |
|
96 |
# (no need to copy HEAD, we will set it via checkout) |
97 |
|
98 |
-- |
99 |
2.1.2 |