@@ -103,7 +103,8 @@ int init_apply_state(struct apply_state *state,
103
103
state -> linenr = 1 ;
104
104
string_list_init_nodup (& state -> fn_table );
105
105
string_list_init_nodup (& state -> limit_by_name );
106
- string_list_init_nodup (& state -> symlink_changes );
106
+ strset_init (& state -> removed_symlinks );
107
+ strset_init (& state -> kept_symlinks );
107
108
strbuf_init (& state -> root , 0 );
108
109
109
110
git_apply_config ();
@@ -117,7 +118,8 @@ int init_apply_state(struct apply_state *state,
117
118
void clear_apply_state (struct apply_state * state )
118
119
{
119
120
string_list_clear (& state -> limit_by_name , 0 );
120
- string_list_clear (& state -> symlink_changes , 0 );
121
+ strset_clear (& state -> removed_symlinks );
122
+ strset_clear (& state -> kept_symlinks );
121
123
strbuf_release (& state -> root );
122
124
123
125
/* &state->fn_table is cleared at the end of apply_patch() */
@@ -3812,59 +3814,31 @@ static int check_to_create(struct apply_state *state,
3812
3814
return 0 ;
3813
3815
}
3814
3816
3815
- static uintptr_t register_symlink_changes (struct apply_state * state ,
3816
- const char * path ,
3817
- uintptr_t what )
3818
- {
3819
- struct string_list_item * ent ;
3820
-
3821
- ent = string_list_lookup (& state -> symlink_changes , path );
3822
- if (!ent ) {
3823
- ent = string_list_insert (& state -> symlink_changes , path );
3824
- ent -> util = (void * )0 ;
3825
- }
3826
- ent -> util = (void * )(what | ((uintptr_t )ent -> util ));
3827
- return (uintptr_t )ent -> util ;
3828
- }
3829
-
3830
- static uintptr_t check_symlink_changes (struct apply_state * state , const char * path )
3831
- {
3832
- struct string_list_item * ent ;
3833
-
3834
- ent = string_list_lookup (& state -> symlink_changes , path );
3835
- if (!ent )
3836
- return 0 ;
3837
- return (uintptr_t )ent -> util ;
3838
- }
3839
-
3840
3817
static void prepare_symlink_changes (struct apply_state * state , struct patch * patch )
3841
3818
{
3842
3819
for ( ; patch ; patch = patch -> next ) {
3843
3820
if ((patch -> old_name && S_ISLNK (patch -> old_mode )) &&
3844
3821
(patch -> is_rename || patch -> is_delete ))
3845
3822
/* the symlink at patch->old_name is removed */
3846
- register_symlink_changes ( state , patch -> old_name , APPLY_SYMLINK_GOES_AWAY );
3823
+ strset_add ( & state -> removed_symlinks , patch -> old_name );
3847
3824
3848
3825
if (patch -> new_name && S_ISLNK (patch -> new_mode ))
3849
3826
/* the symlink at patch->new_name is created or remains */
3850
- register_symlink_changes ( state , patch -> new_name , APPLY_SYMLINK_IN_RESULT );
3827
+ strset_add ( & state -> kept_symlinks , patch -> new_name );
3851
3828
}
3852
3829
}
3853
3830
3854
3831
static int path_is_beyond_symlink_1 (struct apply_state * state , struct strbuf * name )
3855
3832
{
3856
3833
do {
3857
- unsigned int change ;
3858
-
3859
3834
while (-- name -> len && name -> buf [name -> len ] != '/' )
3860
3835
; /* scan backwards */
3861
3836
if (!name -> len )
3862
3837
break ;
3863
3838
name -> buf [name -> len ] = '\0' ;
3864
- change = check_symlink_changes (state , name -> buf );
3865
- if (change & APPLY_SYMLINK_IN_RESULT )
3839
+ if (strset_contains (& state -> kept_symlinks , name -> buf ))
3866
3840
return 1 ;
3867
- if (change & APPLY_SYMLINK_GOES_AWAY )
3841
+ if (strset_contains ( & state -> removed_symlinks , name -> buf ) )
3868
3842
/*
3869
3843
* This cannot be "return 0", because we may
3870
3844
* see a new one created at a higher level.
0 commit comments