@@ -708,10 +708,9 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log)
708
708
709
709
static int is_per_worktree_ref (const char * refname )
710
710
{
711
- return !strcmp (refname , "HEAD" ) ||
712
- starts_with (refname , "refs/worktree/" ) ||
713
- starts_with (refname , "refs/bisect/" ) ||
714
- starts_with (refname , "refs/rewritten/" );
711
+ return starts_with (refname , "refs/worktree/" ) ||
712
+ starts_with (refname , "refs/bisect/" ) ||
713
+ starts_with (refname , "refs/rewritten/" );
715
714
}
716
715
717
716
static int is_pseudoref_syntax (const char * refname )
@@ -771,102 +770,6 @@ long get_files_ref_lock_timeout_ms(void)
771
770
return timeout_ms ;
772
771
}
773
772
774
- static int write_pseudoref (const char * pseudoref , const struct object_id * oid ,
775
- const struct object_id * old_oid , struct strbuf * err )
776
- {
777
- const char * filename ;
778
- int fd ;
779
- struct lock_file lock = LOCK_INIT ;
780
- struct strbuf buf = STRBUF_INIT ;
781
- int ret = -1 ;
782
-
783
- if (!oid )
784
- return 0 ;
785
-
786
- strbuf_addf (& buf , "%s\n" , oid_to_hex (oid ));
787
-
788
- filename = git_path ("%s" , pseudoref );
789
- fd = hold_lock_file_for_update_timeout (& lock , filename , 0 ,
790
- get_files_ref_lock_timeout_ms ());
791
- if (fd < 0 ) {
792
- strbuf_addf (err , _ ("could not open '%s' for writing: %s" ),
793
- filename , strerror (errno ));
794
- goto done ;
795
- }
796
-
797
- if (old_oid ) {
798
- struct object_id actual_old_oid ;
799
-
800
- if (read_ref (pseudoref , & actual_old_oid )) {
801
- if (!is_null_oid (old_oid )) {
802
- strbuf_addf (err , _ ("could not read ref '%s'" ),
803
- pseudoref );
804
- rollback_lock_file (& lock );
805
- goto done ;
806
- }
807
- } else if (is_null_oid (old_oid )) {
808
- strbuf_addf (err , _ ("ref '%s' already exists" ),
809
- pseudoref );
810
- rollback_lock_file (& lock );
811
- goto done ;
812
- } else if (!oideq (& actual_old_oid , old_oid )) {
813
- strbuf_addf (err , _ ("unexpected object ID when writing '%s'" ),
814
- pseudoref );
815
- rollback_lock_file (& lock );
816
- goto done ;
817
- }
818
- }
819
-
820
- if (write_in_full (fd , buf .buf , buf .len ) < 0 ) {
821
- strbuf_addf (err , _ ("could not write to '%s'" ), filename );
822
- rollback_lock_file (& lock );
823
- goto done ;
824
- }
825
-
826
- commit_lock_file (& lock );
827
- ret = 0 ;
828
- done :
829
- strbuf_release (& buf );
830
- return ret ;
831
- }
832
-
833
- static int delete_pseudoref (const char * pseudoref , const struct object_id * old_oid )
834
- {
835
- const char * filename ;
836
-
837
- filename = git_path ("%s" , pseudoref );
838
-
839
- if (old_oid && !is_null_oid (old_oid )) {
840
- struct lock_file lock = LOCK_INIT ;
841
- int fd ;
842
- struct object_id actual_old_oid ;
843
-
844
- fd = hold_lock_file_for_update_timeout (
845
- & lock , filename , 0 ,
846
- get_files_ref_lock_timeout_ms ());
847
- if (fd < 0 ) {
848
- error_errno (_ ("could not open '%s' for writing" ),
849
- filename );
850
- return -1 ;
851
- }
852
- if (read_ref (pseudoref , & actual_old_oid ))
853
- die (_ ("could not read ref '%s'" ), pseudoref );
854
- if (!oideq (& actual_old_oid , old_oid )) {
855
- error (_ ("unexpected object ID when deleting '%s'" ),
856
- pseudoref );
857
- rollback_lock_file (& lock );
858
- return -1 ;
859
- }
860
-
861
- unlink (filename );
862
- rollback_lock_file (& lock );
863
- } else {
864
- unlink (filename );
865
- }
866
-
867
- return 0 ;
868
- }
869
-
870
773
int refs_delete_ref (struct ref_store * refs , const char * msg ,
871
774
const char * refname ,
872
775
const struct object_id * old_oid ,
@@ -875,11 +778,6 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
875
778
struct ref_transaction * transaction ;
876
779
struct strbuf err = STRBUF_INIT ;
877
780
878
- if (ref_type (refname ) == REF_TYPE_PSEUDOREF ) {
879
- assert (refs == get_main_ref_store (the_repository ));
880
- return delete_pseudoref (refname , old_oid );
881
- }
882
-
883
781
transaction = ref_store_transaction_begin (refs , & err );
884
782
if (!transaction ||
885
783
ref_transaction_delete (transaction , refname , old_oid ,
@@ -1210,18 +1108,13 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
1210
1108
struct strbuf err = STRBUF_INIT ;
1211
1109
int ret = 0 ;
1212
1110
1213
- if (ref_type (refname ) == REF_TYPE_PSEUDOREF ) {
1214
- assert (refs == get_main_ref_store (the_repository ));
1215
- ret = write_pseudoref (refname , new_oid , old_oid , & err );
1216
- } else {
1217
- t = ref_store_transaction_begin (refs , & err );
1218
- if (!t ||
1219
- ref_transaction_update (t , refname , new_oid , old_oid ,
1220
- flags , msg , & err ) ||
1221
- ref_transaction_commit (t , & err )) {
1222
- ret = 1 ;
1223
- ref_transaction_free (t );
1224
- }
1111
+ t = ref_store_transaction_begin (refs , & err );
1112
+ if (!t ||
1113
+ ref_transaction_update (t , refname , new_oid , old_oid , flags , msg ,
1114
+ & err ) ||
1115
+ ref_transaction_commit (t , & err )) {
1116
+ ret = 1 ;
1117
+ ref_transaction_free (t );
1225
1118
}
1226
1119
if (ret ) {
1227
1120
const char * str = _ ("update_ref failed for ref '%s': %s" );
0 commit comments