|
20 | 20 | #include "repository.h" |
21 | 21 | #include "sigchain.h" |
22 | 22 | #include "date.h" |
| 23 | +#include "commit.h" |
23 | 24 |
|
24 | 25 | /* |
25 | 26 | * List of all available backends |
@@ -56,6 +57,88 @@ static unsigned char refname_disposition[256] = { |
56 | 57 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 4, 4 |
57 | 58 | }; |
58 | 59 |
|
| 60 | +struct ref_namespace_info ref_namespace[] = { |
| 61 | + [NAMESPACE_HEAD] = { |
| 62 | + .ref = "HEAD", |
| 63 | + .decoration = DECORATION_REF_HEAD, |
| 64 | + .exact = 1, |
| 65 | + }, |
| 66 | + [NAMESPACE_BRANCHES] = { |
| 67 | + .ref = "refs/heads/", |
| 68 | + .decoration = DECORATION_REF_LOCAL, |
| 69 | + }, |
| 70 | + [NAMESPACE_TAGS] = { |
| 71 | + .ref = "refs/tags/", |
| 72 | + .decoration = DECORATION_REF_TAG, |
| 73 | + }, |
| 74 | + [NAMESPACE_REMOTE_REFS] = { |
| 75 | + /* |
| 76 | + * The default refspec for new remotes copies refs from |
| 77 | + * refs/heads/ on the remote into refs/remotes/<remote>/. |
| 78 | + * As such, "refs/remotes/" has special handling. |
| 79 | + */ |
| 80 | + .ref = "refs/remotes/", |
| 81 | + .decoration = DECORATION_REF_REMOTE, |
| 82 | + }, |
| 83 | + [NAMESPACE_STASH] = { |
| 84 | + /* |
| 85 | + * The single ref "refs/stash" stores the latest stash. |
| 86 | + * Older stashes can be found in the reflog. |
| 87 | + */ |
| 88 | + .ref = "refs/stash", |
| 89 | + .exact = 1, |
| 90 | + .decoration = DECORATION_REF_STASH, |
| 91 | + }, |
| 92 | + [NAMESPACE_REPLACE] = { |
| 93 | + /* |
| 94 | + * This namespace allows Git to act as if one object ID |
| 95 | + * points to the content of another. Unlike the other |
| 96 | + * ref namespaces, this one can be changed by the |
| 97 | + * GIT_REPLACE_REF_BASE environment variable. This |
| 98 | + * .namespace value will be overwritten in setup_git_env(). |
| 99 | + */ |
| 100 | + .ref = "refs/replace/", |
| 101 | + .decoration = DECORATION_GRAFTED, |
| 102 | + }, |
| 103 | + [NAMESPACE_NOTES] = { |
| 104 | + /* |
| 105 | + * The refs/notes/commit ref points to the tip of a |
| 106 | + * parallel commit history that adds metadata to commits |
| 107 | + * in the normal history. This ref can be overwritten |
| 108 | + * by the core.notesRef config variable or the |
| 109 | + * GIT_NOTES_REFS environment variable. |
| 110 | + */ |
| 111 | + .ref = "refs/notes/commit", |
| 112 | + .exact = 1, |
| 113 | + }, |
| 114 | + [NAMESPACE_PREFETCH] = { |
| 115 | + /* |
| 116 | + * Prefetch refs are written by the background 'fetch' |
| 117 | + * maintenance task. It allows faster foreground fetches |
| 118 | + * by advertising these previously-downloaded tips without |
| 119 | + * updating refs/remotes/ without user intervention. |
| 120 | + */ |
| 121 | + .ref = "refs/prefetch/", |
| 122 | + }, |
| 123 | + [NAMESPACE_REWRITTEN] = { |
| 124 | + /* |
| 125 | + * Rewritten refs are used by the 'label' command in the |
| 126 | + * sequencer. These are particularly useful during an |
| 127 | + * interactive rebase that uses the 'merge' command. |
| 128 | + */ |
| 129 | + .ref = "refs/rewritten/", |
| 130 | + }, |
| 131 | +}; |
| 132 | + |
| 133 | +void update_ref_namespace(enum ref_namespace namespace, char *ref) |
| 134 | +{ |
| 135 | + struct ref_namespace_info *info = &ref_namespace[namespace]; |
| 136 | + if (info->ref_updated) |
| 137 | + free(info->ref); |
| 138 | + info->ref = ref; |
| 139 | + info->ref_updated = 1; |
| 140 | +} |
| 141 | + |
59 | 142 | /* |
60 | 143 | * Try to read one refname component from the front of refname. |
61 | 144 | * Return the length of the component found, or -1 if the component is |
|
0 commit comments