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