@@ -469,7 +469,7 @@ static char *squash_slash(char *name)
469
469
return name ;
470
470
}
471
471
472
- static char * find_name_gnu (struct apply_state * state ,
472
+ static char * find_name_gnu (struct strbuf * root ,
473
473
const char * line ,
474
474
int p_value )
475
475
{
@@ -495,8 +495,8 @@ static char *find_name_gnu(struct apply_state *state,
495
495
}
496
496
497
497
strbuf_remove (& name , 0 , cp - name .buf );
498
- if (state -> root . len )
499
- strbuf_insert (& name , 0 , state -> root . buf , state -> root . len );
498
+ if (root -> len )
499
+ strbuf_insert (& name , 0 , root -> buf , root -> len );
500
500
return squash_slash (strbuf_detach (& name , NULL ));
501
501
}
502
502
@@ -659,7 +659,7 @@ static size_t diff_timestamp_len(const char *line, size_t len)
659
659
return line + len - end ;
660
660
}
661
661
662
- static char * find_name_common (struct apply_state * state ,
662
+ static char * find_name_common (struct strbuf * root ,
663
663
const char * line ,
664
664
const char * def ,
665
665
int p_value ,
@@ -702,30 +702,30 @@ static char *find_name_common(struct apply_state *state,
702
702
return squash_slash (xstrdup (def ));
703
703
}
704
704
705
- if (state -> root . len ) {
706
- char * ret = xstrfmt ("%s%.*s" , state -> root . buf , len , start );
705
+ if (root -> len ) {
706
+ char * ret = xstrfmt ("%s%.*s" , root -> buf , len , start );
707
707
return squash_slash (ret );
708
708
}
709
709
710
710
return squash_slash (xmemdupz (start , len ));
711
711
}
712
712
713
- static char * find_name (struct apply_state * state ,
713
+ static char * find_name (struct strbuf * root ,
714
714
const char * line ,
715
715
char * def ,
716
716
int p_value ,
717
717
int terminate )
718
718
{
719
719
if (* line == '"' ) {
720
- char * name = find_name_gnu (state , line , p_value );
720
+ char * name = find_name_gnu (root , line , p_value );
721
721
if (name )
722
722
return name ;
723
723
}
724
724
725
- return find_name_common (state , line , def , p_value , NULL , terminate );
725
+ return find_name_common (root , line , def , p_value , NULL , terminate );
726
726
}
727
727
728
- static char * find_name_traditional (struct apply_state * state ,
728
+ static char * find_name_traditional (struct strbuf * root ,
729
729
const char * line ,
730
730
char * def ,
731
731
int p_value )
@@ -734,18 +734,18 @@ static char *find_name_traditional(struct apply_state *state,
734
734
size_t date_len ;
735
735
736
736
if (* line == '"' ) {
737
- char * name = find_name_gnu (state , line , p_value );
737
+ char * name = find_name_gnu (root , line , p_value );
738
738
if (name )
739
739
return name ;
740
740
}
741
741
742
742
len = strchrnul (line , '\n' ) - line ;
743
743
date_len = diff_timestamp_len (line , len );
744
744
if (!date_len )
745
- return find_name_common (state , line , def , p_value , NULL , TERM_TAB );
745
+ return find_name_common (root , line , def , p_value , NULL , TERM_TAB );
746
746
len -= date_len ;
747
747
748
- return find_name_common (state , line , def , p_value , line + len , 0 );
748
+ return find_name_common (root , line , def , p_value , line + len , 0 );
749
749
}
750
750
751
751
/*
@@ -759,7 +759,7 @@ static int guess_p_value(struct apply_state *state, const char *nameline)
759
759
760
760
if (is_dev_null (nameline ))
761
761
return -1 ;
762
- name = find_name_traditional (state , nameline , NULL , 0 );
762
+ name = find_name_traditional (& state -> root , nameline , NULL , 0 );
763
763
if (!name )
764
764
return -1 ;
765
765
cp = strchr (name , '/' );
@@ -883,17 +883,17 @@ static int parse_traditional_patch(struct apply_state *state,
883
883
if (is_dev_null (first )) {
884
884
patch -> is_new = 1 ;
885
885
patch -> is_delete = 0 ;
886
- name = find_name_traditional (state , second , NULL , state -> p_value );
886
+ name = find_name_traditional (& state -> root , second , NULL , state -> p_value );
887
887
patch -> new_name = name ;
888
888
} else if (is_dev_null (second )) {
889
889
patch -> is_new = 0 ;
890
890
patch -> is_delete = 1 ;
891
- name = find_name_traditional (state , first , NULL , state -> p_value );
891
+ name = find_name_traditional (& state -> root , first , NULL , state -> p_value );
892
892
patch -> old_name = name ;
893
893
} else {
894
894
char * first_name ;
895
- first_name = find_name_traditional (state , first , NULL , state -> p_value );
896
- name = find_name_traditional (state , second , first_name , state -> p_value );
895
+ first_name = find_name_traditional (& state -> root , first , NULL , state -> p_value );
896
+ name = find_name_traditional (& state -> root , second , first_name , state -> p_value );
897
897
free (first_name );
898
898
if (has_epoch_timestamp (first )) {
899
899
patch -> is_new = 1 ;
@@ -940,7 +940,7 @@ static int gitdiff_verify_name(struct apply_state *state,
940
940
int side )
941
941
{
942
942
if (!* name && !isnull ) {
943
- * name = find_name (state , line , NULL , state -> p_value , TERM_TAB );
943
+ * name = find_name (& state -> root , line , NULL , state -> p_value , TERM_TAB );
944
944
return 0 ;
945
945
}
946
946
@@ -949,7 +949,7 @@ static int gitdiff_verify_name(struct apply_state *state,
949
949
if (isnull )
950
950
return error (_ ("git apply: bad git-diff - expected /dev/null, got %s on line %d" ),
951
951
* name , state -> linenr );
952
- another = find_name (state , line , NULL , state -> p_value , TERM_TAB );
952
+ another = find_name (& state -> root , line , NULL , state -> p_value , TERM_TAB );
953
953
if (!another || strcmp (another , * name )) {
954
954
free (another );
955
955
return error ((side == DIFF_NEW_NAME ) ?
@@ -1032,7 +1032,7 @@ static int gitdiff_copysrc(struct apply_state *state,
1032
1032
{
1033
1033
patch -> is_copy = 1 ;
1034
1034
free (patch -> old_name );
1035
- patch -> old_name = find_name (state , line , NULL , state -> p_value ? state -> p_value - 1 : 0 , 0 );
1035
+ patch -> old_name = find_name (& state -> root , line , NULL , state -> p_value ? state -> p_value - 1 : 0 , 0 );
1036
1036
return 0 ;
1037
1037
}
1038
1038
@@ -1042,7 +1042,7 @@ static int gitdiff_copydst(struct apply_state *state,
1042
1042
{
1043
1043
patch -> is_copy = 1 ;
1044
1044
free (patch -> new_name );
1045
- patch -> new_name = find_name (state , line , NULL , state -> p_value ? state -> p_value - 1 : 0 , 0 );
1045
+ patch -> new_name = find_name (& state -> root , line , NULL , state -> p_value ? state -> p_value - 1 : 0 , 0 );
1046
1046
return 0 ;
1047
1047
}
1048
1048
@@ -1052,7 +1052,7 @@ static int gitdiff_renamesrc(struct apply_state *state,
1052
1052
{
1053
1053
patch -> is_rename = 1 ;
1054
1054
free (patch -> old_name );
1055
- patch -> old_name = find_name (state , line , NULL , state -> p_value ? state -> p_value - 1 : 0 , 0 );
1055
+ patch -> old_name = find_name (& state -> root , line , NULL , state -> p_value ? state -> p_value - 1 : 0 , 0 );
1056
1056
return 0 ;
1057
1057
}
1058
1058
@@ -1062,7 +1062,7 @@ static int gitdiff_renamedst(struct apply_state *state,
1062
1062
{
1063
1063
patch -> is_rename = 1 ;
1064
1064
free (patch -> new_name );
1065
- patch -> new_name = find_name (state , line , NULL , state -> p_value ? state -> p_value - 1 : 0 , 0 );
1065
+ patch -> new_name = find_name (& state -> root , line , NULL , state -> p_value ? state -> p_value - 1 : 0 , 0 );
1066
1066
return 0 ;
1067
1067
}
1068
1068
0 commit comments