{"thread":{"id":"45555","subject":"[PATCH v2] read-cache: avoid using git_path() in freshen_shared_index()","startedAt":"2017-03-30T21:04:16Z","lastAt":"2017-03-30T21:04:16Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"315832","messageId":"20170330210354.20018-1-chriscool@tuxfamily.org","threadId":"45555","inReplyTo":null,"subject":"[PATCH v2] read-cache: avoid using git_path() in freshen_shared_index()","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2017-03-30T21:03:54Z","receivedAt":"2017-03-30T21:04:16Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"When performing an interactive rebase in split-index mode,\nthe commit message that one should rework when squashing commits\ncan contain some garbage instead of the usual concatenation of\nboth of the commit messages.\n\nBisecting shows that c3a0082502 (read-cache: use\nfreshen_shared_index() in read_index_from(), 2017-03-06) is involved,\nwhich points to the unsafe use of git_path() in\nfreshen_shared_index().\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\nThe only changes in this v2 compared to the previous version are\nin the title and commit message, which have been changed according\nto:\n\nhttp://public-inbox.org/git/CAP8UFD29xWU5bHwewUSq26pVTwK-gy3uSVG2aGTCrDak3620=A@mail.gmail.com/\n\n read-cache.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex e447751823..2f10242c24 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1682,9 +1682,10 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)\n  */\n static void freshen_shared_index(char *base_sha1_hex, int warn)\n {\n-\tconst char *shared_index = git_path(\"sharedindex.%s\", base_sha1_hex);\n+\tchar *shared_index = git_pathdup(\"sharedindex.%s\", base_sha1_hex);\n \tif (!check_and_freshen_file(shared_index, 1) && warn)\n \t\twarning(\"could not freshen shared index '%s'\", shared_index);\n+\tfree(shared_index);\n }\n \n int read_index_from(struct index_state *istate, const char *path)\n-- \n2.12.0.rc0.23.g4ed838fb8d\n\n"}]}