MCPcopy Index your code
hub / github.com/git/git / ref_iterator_select

Function ref_iterator_select

refs/iterator.c:97–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95};
96
97enum iterator_selection ref_iterator_select(struct ref_iterator *iter_worktree,
98 struct ref_iterator *iter_common,
99 void *cb_data UNUSED)
100{
101 if (iter_worktree && !iter_common) {
102 /*
103 * Return the worktree ref if there are no more common refs.
104 */
105 return ITER_SELECT_0;
106 } else if (iter_common) {
107 /*
108 * In case we have pending worktree and common refs we need to
109 * yield them based on their lexicographical order. Worktree
110 * refs that have the same name as common refs shadow the
111 * latter.
112 */
113 if (iter_worktree) {
114 int cmp = strcmp(iter_worktree->ref.name,
115 iter_common->ref.name);
116 if (cmp < 0)
117 return ITER_SELECT_0;
118 else if (!cmp)
119 return ITER_SELECT_0_SKIP_1;
120 }
121
122 /*
123 * We now know that the lexicographically-next ref is a common
124 * ref. When the common ref is a shared one we return it.
125 */
126 if (parse_worktree_ref(iter_common->ref.name, NULL, NULL,
127 NULL) == REF_WORKTREE_SHARED)
128 return ITER_SELECT_1;
129
130 /*
131 * Otherwise, if the common ref is a per-worktree ref we skip
132 * it because it would belong to the main worktree, not ours.
133 */
134 return ITER_SKIP_1;
135 } else {
136 return ITER_DONE;
137 }
138}
139
140static int merge_ref_iterator_advance(struct ref_iterator *ref_iterator)
141{

Callers

nothing calls this directly

Calls 1

parse_worktree_refFunction · 0.85

Tested by

no test coverage detected