Duy Nguyen <pclo...@gmail.com> writes:

> OK so your question was if there was a git_path() or mkpath() call
> earlier in update_refs_for_switch() and the result was expected to
> remain stable till the end of update_refs_for_switch(), then this
> conversion could ruin it, correct? I didn't think about that,...

Yeah, I couldn't tell if you thought about it, and that was why I

If a (recursively) caller does this:

        caller () {
                const char *path1 = git_path(...);
                const char *path2 = mkpath(...);
                const char *path3 = git_path_submodule(...);
                use(path1, path2, path3);

it was safe back when the callee() did not mess with the round-robin
pathname buffer, but it will be broken once callee() does.  While
looking at the patch I didn't check what the caller was doing hence
my question.

In general, in order to reduce that kind of hard-to-debug bugs, we
should be reducing the uses of these functions when we do not have
to (which applies equally to such a caller that expects multiple
temporary paths to persist, and to a callee as well).  Adding
multiple repeated calls to git_path(), especially two of them
formatting the same string into two separate round-robin pathname
buffer, looked strange in a patch that was supposed to be a
preparatory code-cleanup stage.

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to