@@ -67,7 +67,6 @@ struct files_ref_store {
6767 struct ref_store base ;
6868 unsigned int store_flags ;
6969
70- char * gitdir ;
7170 char * gitcommondir ;
7271
7372 struct ref_cache * loose ;
@@ -94,18 +93,17 @@ static struct ref_store *files_ref_store_create(const char *gitdir,
9493 struct ref_store * ref_store = (struct ref_store * )refs ;
9594 struct strbuf sb = STRBUF_INIT ;
9695
96+ ref_store -> gitdir = xstrdup (gitdir );
9797 base_ref_store_init (ref_store , & refs_be_files );
9898 refs -> store_flags = flags ;
9999
100- refs -> gitdir = xstrdup (gitdir );
101100 get_common_dir_noenv (& sb , gitdir );
102101 refs -> gitcommondir = strbuf_detach (& sb , NULL );
103102 strbuf_addf (& sb , "%s/packed-refs" , refs -> gitcommondir );
104103 refs -> packed_ref_store = packed_ref_store_create (sb .buf , flags );
105104 strbuf_release (& sb );
106105
107- chdir_notify_reparent ("files-backend $GIT_DIR" ,
108- & refs -> gitdir );
106+ chdir_notify_reparent ("files-backend $GIT_DIR" , & refs -> base .gitdir );
109107 chdir_notify_reparent ("files-backend $GIT_COMMONDIR" ,
110108 & refs -> gitcommondir );
111109
@@ -176,7 +174,7 @@ static void files_reflog_path(struct files_ref_store *refs,
176174 switch (ref_type (refname )) {
177175 case REF_TYPE_PER_WORKTREE :
178176 case REF_TYPE_PSEUDOREF :
179- strbuf_addf (sb , "%s/logs/%s" , refs -> gitdir , refname );
177+ strbuf_addf (sb , "%s/logs/%s" , refs -> base . gitdir , refname );
180178 break ;
181179 case REF_TYPE_OTHER_PSEUDOREF :
182180 case REF_TYPE_MAIN_PSEUDOREF :
@@ -198,7 +196,7 @@ static void files_ref_path(struct files_ref_store *refs,
198196 switch (ref_type (refname )) {
199197 case REF_TYPE_PER_WORKTREE :
200198 case REF_TYPE_PSEUDOREF :
201- strbuf_addf (sb , "%s/%s" , refs -> gitdir , refname );
199+ strbuf_addf (sb , "%s/%s" , refs -> base . gitdir , refname );
202200 break ;
203201 case REF_TYPE_MAIN_PSEUDOREF :
204202 if (!skip_prefix (refname , "main-worktree/" , & refname ))
@@ -2203,12 +2201,11 @@ static struct ref_iterator *files_reflog_iterator_begin(struct ref_store *ref_st
22032201 files_downcast (ref_store , REF_STORE_READ ,
22042202 "reflog_iterator_begin" );
22052203
2206- if (!strcmp (refs -> gitdir , refs -> gitcommondir )) {
2204+ if (!strcmp (refs -> base . gitdir , refs -> gitcommondir )) {
22072205 return reflog_iterator_begin (ref_store , refs -> gitcommondir );
22082206 } else {
22092207 return merge_ref_iterator_begin (
2210- 0 ,
2211- reflog_iterator_begin (ref_store , refs -> gitdir ),
2208+ 0 , reflog_iterator_begin (ref_store , refs -> base .gitdir ),
22122209 reflog_iterator_begin (ref_store , refs -> gitcommondir ),
22132210 reflog_iterator_select , refs );
22142211 }
0 commit comments