ZheNing Hu [off-list ref] writes:
Junio C Hamano [off-list ref] 于2021年3月15日周一 上午7:52写道:
quoted
IOW this part would become ...
if (trailer_args.nr) {
strvec_pushl(&run_trailer.args, "interpret-trailers",
"--in-place", ...);
strvec_pushv(&run_trailer.args, trailer_args.v);
run_trailer.git_cmd = 1;
run_command(&run_trailer);
}
quoted
+ } else
+ strvec_clear(&run_trailer.args);
... and there is no need to have "else" that won't need to do
anything.
Yes, but we also should clear "trailer_args" in "else" here, and check the
return value of the "run_command()" for clear "run_trailer.args".
No. If you introduce the separate strvec, the "else" clause runs
only when trailer_args haven't got anything, so there is nothing to
clear.
Junio C Hamano [off-list ref] 于2021年3月15日周一 下午12:42写道:
ZheNing Hu [off-list ref] writes:
quoted
Junio C Hamano [off-list ref] 于2021年3月15日周一 上午7:52写道:
quoted
IOW this part would become ...
if (trailer_args.nr) {
strvec_pushl(&run_trailer.args, "interpret-trailers",
"--in-place", ...);
strvec_pushv(&run_trailer.args, trailer_args.v);
run_trailer.git_cmd = 1;
run_command(&run_trailer);
}
quoted
+ } else
+ strvec_clear(&run_trailer.args);
... and there is no need to have "else" that won't need to do
anything.
Yes, but we also should clear "trailer_args" in "else" here, and check the
return value of the "run_command()" for clear "run_trailer.args".
No. If you introduce the separate strvec, the "else" clause runs
only when trailer_args haven't got anything, so there is nothing to
clear.
I admit I was wrong before. But this may be the right thing to do.
+ if (trailer_args.nr) {
+ strvec_pushl(&run_trailer.args, "interpret-trailers",
+ "--in-place", "--where=end",
git_path_commit_editmsg(), NULL);
+ strvec_pushv(&run_trailer.args, trailer_args.v);
+ run_trailer.git_cmd = 1;
+ if (run_command(&run_trailer))
+ strvec_clear(&run_trailer.args);
+ strvec_clear(&trailer_args);
+ }