File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -123,6 +123,42 @@ namespace vix::commands
123123 return fs::exists (dir / " .git" , ec);
124124 }
125125
126+ std::string join_for_log (const std::vector<std::string> &args)
127+ {
128+ std::ostringstream out;
129+
130+ for (std::size_t i = 0 ; i < args.size (); ++i)
131+ {
132+ if (i > 0 )
133+ out << ' ' ;
134+
135+ const std::string &arg = args[i];
136+
137+ const bool needsQuotes =
138+ arg.find (' ' ) != std::string::npos ||
139+ arg.find (' \t ' ) != std::string::npos ||
140+ arg.find (' "' ) != std::string::npos;
141+
142+ if (!needsQuotes)
143+ {
144+ out << arg;
145+ continue ;
146+ }
147+
148+ out << ' "' ;
149+ for (char c : arg)
150+ {
151+ if (c == ' "' )
152+ out << " \\\" " ;
153+ else
154+ out << c;
155+ }
156+ out << ' "' ;
157+ }
158+
159+ return out.str ();
160+ }
161+
126162 /* =========================
127163 Process runner (no system)
128164 ========================= */
You can’t perform that action at this time.
0 commit comments