@@ -47,15 +47,19 @@ static int compare_file(void *payload, git_buf *actual_path)
47
47
git_buf expected_contents = GIT_BUF_INIT ;
48
48
struct compare_data * cd = payload ;
49
49
bool failed = true;
50
+ int cmp_git , cmp_gitattributes ;
51
+ char * basename ;
50
52
51
- if (strcmp (git_path_basename (actual_path -> ptr ), ".git" ) == 0 ||
52
- strcmp (git_path_basename (actual_path -> ptr ), ".gitattributes" ) == 0 ) {
53
+ basename = git_path_basename (actual_path -> ptr );
54
+ cmp_git = strcmp (basename , ".git" );
55
+ cmp_gitattributes = strcmp (basename , ".gitattributes" );
56
+
57
+ if (cmp_git == 0 || cmp_gitattributes == 0 ) {
53
58
failed = false;
54
59
goto done ;
55
60
}
56
61
57
- cl_git_pass (git_buf_joinpath (& expected_path , cd -> dirname ,
58
- git_path_basename (actual_path -> ptr )));
62
+ cl_git_pass (git_buf_joinpath (& expected_path , cd -> dirname , basename ));
59
63
60
64
if (!git_path_isfile (expected_path .ptr ) ||
61
65
!git_path_isfile (actual_path -> ptr ))
@@ -83,6 +87,7 @@ static int compare_file(void *payload, git_buf *actual_path)
83
87
git_buf_free (& details );
84
88
}
85
89
90
+ git__free (basename );
86
91
git_buf_free (& expected_contents );
87
92
git_buf_free (& actual_contents );
88
93
git_buf_free (& expected_path );
@@ -151,7 +156,12 @@ static void empty_workdir(const char *name)
151
156
152
157
git_path_dirload (& contents , name , 0 , 0 );
153
158
git_vector_foreach (& contents , i , fn ) {
154
- if (strncasecmp (git_path_basename (fn ), ".git" , 4 ) == 0 )
159
+ char * basename = git_path_basename (fn );
160
+ int cmp = strncasecmp (basename , ".git" , 4 );
161
+
162
+ git__free (basename );
163
+
164
+ if (cmp == 0 )
155
165
continue ;
156
166
p_unlink (fn );
157
167
}
0 commit comments