@@ -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() */
@@ -3814,59 +3816,31 @@ static int check_to_create(struct apply_state *state,
3814
3816
return 0 ;
3815
3817
}
3816
3818
3817
- static uintptr_t register_symlink_changes (struct apply_state * state ,
3818
- const char * path ,
3819
- uintptr_t what )
3820
- {
3821
- struct string_list_item * ent ;
3822
-
3823
- ent = string_list_lookup (& state -> symlink_changes , path );
3824
- if (!ent ) {
3825
- ent = string_list_insert (& state -> symlink_changes , path );
3826
- ent -> util = (void * )0 ;
3827
- }
3828
- ent -> util = (void * )(what | ((uintptr_t )ent -> util ));
3829
- return (uintptr_t )ent -> util ;
3830
- }
3831
-
3832
- static uintptr_t check_symlink_changes (struct apply_state * state , const char * path )
3833
- {
3834
- struct string_list_item * ent ;
3835
-
3836
- ent = string_list_lookup (& state -> symlink_changes , path );
3837
- if (!ent )
3838
- return 0 ;
3839
- return (uintptr_t )ent -> util ;
3840
- }
3841
-
3842
3819
static void prepare_symlink_changes (struct apply_state * state , struct patch * patch )
3843
3820
{
3844
3821
for ( ; patch ; patch = patch -> next ) {
3845
3822
if ((patch -> old_name && S_ISLNK (patch -> old_mode )) &&
3846
3823
(patch -> is_rename || patch -> is_delete ))
3847
3824
/* the symlink at patch->old_name is removed */
3848
- register_symlink_changes ( state , patch -> old_name , APPLY_SYMLINK_GOES_AWAY );
3825
+ strset_add ( & state -> removed_symlinks , patch -> old_name );
3849
3826
3850
3827
if (patch -> new_name && S_ISLNK (patch -> new_mode ))
3851
3828
/* the symlink at patch->new_name is created or remains */
3852
- register_symlink_changes ( state , patch -> new_name , APPLY_SYMLINK_IN_RESULT );
3829
+ strset_add ( & state -> kept_symlinks , patch -> new_name );
3853
3830
}
3854
3831
}
3855
3832
3856
3833
static int path_is_beyond_symlink_1 (struct apply_state * state , struct strbuf * name )
3857
3834
{
3858
3835
do {
3859
- unsigned int change ;
3860
-
3861
3836
while (-- name -> len && name -> buf [name -> len ] != '/' )
3862
3837
; /* scan backwards */
3863
3838
if (!name -> len )
3864
3839
break ;
3865
3840
name -> buf [name -> len ] = '\0' ;
3866
- change = check_symlink_changes (state , name -> buf );
3867
- if (change & APPLY_SYMLINK_IN_RESULT )
3841
+ if (strset_contains (& state -> kept_symlinks , name -> buf ))
3868
3842
return 1 ;
3869
- if (change & APPLY_SYMLINK_GOES_AWAY )
3843
+ if (strset_contains ( & state -> removed_symlinks , name -> buf ) )
3870
3844
/*
3871
3845
* This cannot be "return 0", because we may
3872
3846
* see a new one created at a higher level.
0 commit comments