@@ -13,7 +13,8 @@ static struct lock_file credential_lock;
1313static int parse_credential_file (const char * fn ,
1414 struct credential * c ,
1515 void (* match_cb )(struct credential * ),
16- void (* other_cb )(struct strbuf * ))
16+ void (* other_cb )(struct strbuf * ),
17+ int match_password )
1718{
1819 FILE * fh ;
1920 struct strbuf line = STRBUF_INIT ;
@@ -30,7 +31,7 @@ static int parse_credential_file(const char *fn,
3031 while (strbuf_getline_lf (& line , fh ) != EOF ) {
3132 if (!credential_from_url_gently (& entry , line .buf , 1 ) &&
3233 entry .username && entry .password &&
33- credential_match (c , & entry )) {
34+ credential_match (c , & entry , match_password )) {
3435 found_credential = 1 ;
3536 if (match_cb ) {
3637 match_cb (& entry );
@@ -60,7 +61,7 @@ static void print_line(struct strbuf *buf)
6061}
6162
6263static void rewrite_credential_file (const char * fn , struct credential * c ,
63- struct strbuf * extra )
64+ struct strbuf * extra , int match_password )
6465{
6566 int timeout_ms = 1000 ;
6667
@@ -69,7 +70,7 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
6970 die_errno (_ ("unable to get credential storage lock in %d ms" ), timeout_ms );
7071 if (extra )
7172 print_line (extra );
72- parse_credential_file (fn , c , NULL , print_line );
73+ parse_credential_file (fn , c , NULL , print_line , match_password );
7374 if (commit_lock_file (& credential_lock ) < 0 )
7475 die_errno ("unable to write credential store" );
7576}
@@ -91,7 +92,7 @@ static void store_credential_file(const char *fn, struct credential *c)
9192 is_rfc3986_reserved_or_unreserved );
9293 }
9394
94- rewrite_credential_file (fn , c , & buf );
95+ rewrite_credential_file (fn , c , & buf , 0 );
9596 strbuf_release (& buf );
9697}
9798
@@ -138,15 +139,15 @@ static void remove_credential(const struct string_list *fns, struct credential *
138139 return ;
139140 for_each_string_list_item (fn , fns )
140141 if (!access (fn -> string , F_OK ))
141- rewrite_credential_file (fn -> string , c , NULL );
142+ rewrite_credential_file (fn -> string , c , NULL , 1 );
142143}
143144
144145static void lookup_credential (const struct string_list * fns , struct credential * c )
145146{
146147 struct string_list_item * fn ;
147148
148149 for_each_string_list_item (fn , fns )
149- if (parse_credential_file (fn -> string , c , print_entry , NULL ))
150+ if (parse_credential_file (fn -> string , c , print_entry , NULL , 0 ))
150151 return ; /* Found credential */
151152}
152153
0 commit comments