@@ -38,7 +38,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
3838 return commit ;
3939}
4040
41- static int push_commit (git_revwalk * walk , const git_oid * oid , int uninteresting , int from_glob )
41+ int git_revwalk__push_commit (git_revwalk * walk , const git_oid * oid , const git_revwalk__push_options * opts )
4242{
4343 git_oid commit_id ;
4444 int error ;
@@ -54,7 +54,7 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting,
5454
5555 if (error == GIT_ENOTFOUND || error == GIT_EINVALIDSPEC || error == GIT_EPEEL ) {
5656 /* If this comes from e.g. push_glob("tags"), ignore this */
57- if (from_glob )
57+ if (opts -> from_glob )
5858 return 0 ;
5959
6060 git_error_set (GIT_ERROR_INVALID , "object is not a committish" );
@@ -74,14 +74,14 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting,
7474 if (commit -> uninteresting )
7575 return 0 ;
7676
77- if (uninteresting ) {
77+ if (opts -> uninteresting ) {
7878 walk -> limited = 1 ;
7979 walk -> did_hide = 1 ;
8080 } else {
8181 walk -> did_push = 1 ;
8282 }
8383
84- commit -> uninteresting = uninteresting ;
84+ commit -> uninteresting = opts -> uninteresting ;
8585 list = walk -> user_input ;
8686 if (git_commit_list_insert (commit , & list ) == NULL ) {
8787 git_error_set_oom ();
@@ -95,29 +95,36 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting,
9595
9696int git_revwalk_push (git_revwalk * walk , const git_oid * oid )
9797{
98+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
99+
98100 assert (walk && oid );
99- return push_commit (walk , oid , 0 , false);
101+
102+ return git_revwalk__push_commit (walk , oid , & opts );
100103}
101104
102105
103106int git_revwalk_hide (git_revwalk * walk , const git_oid * oid )
104107{
108+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
105109 assert (walk && oid );
106- return push_commit (walk , oid , 1 , false);
110+
111+ opts .uninteresting = 1 ;
112+ return git_revwalk__push_commit (walk , oid , & opts );
107113}
108114
109- static int push_ref (git_revwalk * walk , const char * refname , int hide , int from_glob )
115+ int git_revwalk__push_ref (git_revwalk * walk , const char * refname , const git_revwalk__push_options * opts )
110116{
111117 git_oid oid ;
112118
113119 if (git_reference_name_to_id (& oid , walk -> repo , refname ) < 0 )
114120 return -1 ;
115121
116- return push_commit (walk , & oid , hide , from_glob );
122+ return git_revwalk__push_commit (walk , & oid , opts );
117123}
118124
119- static int push_glob (git_revwalk * walk , const char * glob , int hide )
125+ int git_revwalk__push_glob (git_revwalk * walk , const char * glob , const git_revwalk__push_options * given_opts )
120126{
127+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
121128 int error = 0 ;
122129 git_buf buf = GIT_BUF_INIT ;
123130 git_reference * ref ;
@@ -126,6 +133,9 @@ static int push_glob(git_revwalk *walk, const char *glob, int hide)
126133
127134 assert (walk && glob );
128135
136+ if (given_opts )
137+ memcpy (& opts , given_opts , sizeof (opts ));
138+
129139 /* refs/ is implied if not given in the glob */
130140 if (git__prefixcmp (glob , GIT_REFS_DIR ) != 0 )
131141 git_buf_joinpath (& buf , GIT_REFS_DIR , glob );
@@ -141,8 +151,9 @@ static int push_glob(git_revwalk *walk, const char *glob, int hide)
141151 if ((error = git_reference_iterator_glob_new (& iter , walk -> repo , buf .ptr )) < 0 )
142152 goto out ;
143153
154+ opts .from_glob = true;
144155 while ((error = git_reference_next (& ref , iter )) == 0 ) {
145- error = push_ref (walk , git_reference_name (ref ), hide , true );
156+ error = git_revwalk__push_ref (walk , git_reference_name (ref ), & opts );
146157 git_reference_free (ref );
147158 if (error < 0 )
148159 break ;
@@ -158,36 +169,49 @@ static int push_glob(git_revwalk *walk, const char *glob, int hide)
158169
159170int git_revwalk_push_glob (git_revwalk * walk , const char * glob )
160171{
172+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
161173 assert (walk && glob );
162- return push_glob (walk , glob , 0 );
174+
175+ return git_revwalk__push_glob (walk , glob , & opts );
163176}
164177
165178int git_revwalk_hide_glob (git_revwalk * walk , const char * glob )
166179{
180+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
167181 assert (walk && glob );
168- return push_glob (walk , glob , 1 );
182+
183+ opts .uninteresting = 1 ;
184+ return git_revwalk__push_glob (walk , glob , & opts );
169185}
170186
171187int git_revwalk_push_head (git_revwalk * walk )
172188{
189+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
173190 assert (walk );
174- return push_ref (walk , GIT_HEAD_FILE , 0 , false);
191+
192+ return git_revwalk__push_ref (walk , GIT_HEAD_FILE , & opts );
175193}
176194
177195int git_revwalk_hide_head (git_revwalk * walk )
178196{
197+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
179198 assert (walk );
180- return push_ref (walk , GIT_HEAD_FILE , 1 , false);
199+
200+ opts .uninteresting = 1 ;
201+ return git_revwalk__push_ref (walk , GIT_HEAD_FILE , & opts );
181202}
182203
183204int git_revwalk_push_ref (git_revwalk * walk , const char * refname )
184205{
206+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
185207 assert (walk && refname );
186- return push_ref (walk , refname , 0 , false);
208+
209+ return git_revwalk__push_ref (walk , refname , & opts );
187210}
188211
189212int git_revwalk_push_range (git_revwalk * walk , const char * range )
190213{
214+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
191215 git_revspec revspec ;
192216 int error = 0 ;
193217
@@ -207,10 +231,12 @@ int git_revwalk_push_range(git_revwalk *walk, const char *range)
207231 goto out ;
208232 }
209233
210- if ((error = push_commit (walk , git_object_id (revspec .from ), 1 , false)))
234+ opts .uninteresting = 1 ;
235+ if ((error = git_revwalk__push_commit (walk , git_object_id (revspec .from ), & opts )))
211236 goto out ;
212237
213- error = push_commit (walk , git_object_id (revspec .to ), 0 , false);
238+ opts .uninteresting = 0 ;
239+ error = git_revwalk__push_commit (walk , git_object_id (revspec .to ), & opts );
214240
215241out :
216242 git_object_free (revspec .from );
@@ -220,8 +246,10 @@ int git_revwalk_push_range(git_revwalk *walk, const char *range)
220246
221247int git_revwalk_hide_ref (git_revwalk * walk , const char * refname )
222248{
249+ git_revwalk__push_options opts = GIT_REVWALK__PUSH_OPTIONS_INIT ;
223250 assert (walk && refname );
224- return push_ref (walk , refname , 1 , false);
251+ opts .uninteresting = 1 ;
252+ return git_revwalk__push_ref (walk , refname , & opts );
225253}
226254
227255static int revwalk_enqueue_timesort (git_revwalk * walk , git_commit_list_node * commit )
0 commit comments