@@ -2999,7 +2999,7 @@ struct add_data {
2999
2999
};
3000
3000
#define ADD_DATA_INIT { .depth = -1 }
3001
3001
3002
- static void show_fetch_remotes ( FILE * output , const char * git_dir_path )
3002
+ static void append_fetch_remotes ( struct strbuf * msg , const char * git_dir_path )
3003
3003
{
3004
3004
struct child_process cp_remote = CHILD_PROCESS_INIT ;
3005
3005
struct strbuf sb_remote_out = STRBUF_INIT ;
@@ -3015,7 +3015,7 @@ static void show_fetch_remotes(FILE *output, const char *git_dir_path)
3015
3015
while ((next_line = strchr (line , '\n' )) != NULL ) {
3016
3016
size_t len = next_line - line ;
3017
3017
if (strip_suffix_mem (line , & len , " (fetch)" ))
3018
- fprintf ( output , " %.*s\n" , (int )len , line );
3018
+ strbuf_addf ( msg , " %.*s\n" , (int )len , line );
3019
3019
line = next_line + 1 ;
3020
3020
}
3021
3021
}
@@ -3047,19 +3047,27 @@ static int add_submodule(const struct add_data *add_data)
3047
3047
3048
3048
if (is_directory (submod_gitdir_path )) {
3049
3049
if (!add_data -> force ) {
3050
- fprintf (stderr , _ ("A git directory for '%s' is found "
3051
- "locally with remote(s):" ),
3052
- add_data -> sm_name );
3053
- show_fetch_remotes (stderr , submod_gitdir_path );
3050
+ struct strbuf msg = STRBUF_INIT ;
3051
+ char * die_msg ;
3052
+
3053
+ strbuf_addf (& msg , _ ("A git directory for '%s' is found "
3054
+ "locally with remote(s):\n" ),
3055
+ add_data -> sm_name );
3056
+
3057
+ append_fetch_remotes (& msg , submod_gitdir_path );
3054
3058
free (submod_gitdir_path );
3055
- die (_ ("If you want to reuse this local git "
3056
- "directory instead of cloning again from\n"
3057
- " %s\n"
3058
- "use the '--force' option. If the local git "
3059
- "directory is not the correct repo\n"
3060
- "or if you are unsure what this means, choose "
3061
- "another name with the '--name' option.\n" ),
3062
- add_data -> realrepo );
3059
+
3060
+ strbuf_addf (& msg , _ ("If you want to reuse this local git "
3061
+ "directory instead of cloning again from\n"
3062
+ " %s\n"
3063
+ "use the '--force' option. If the local git "
3064
+ "directory is not the correct repo\n"
3065
+ "or you are unsure what this means choose "
3066
+ "another name with the '--name' option." ),
3067
+ add_data -> realrepo );
3068
+
3069
+ die_msg = strbuf_detach (& msg , NULL );
3070
+ die ("%s" , die_msg );
3063
3071
} else {
3064
3072
printf (_ ("Reactivating local git directory for "
3065
3073
"submodule '%s'\n" ), add_data -> sm_name );
0 commit comments