git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] test suite broken with GIT_TEST_SPLIT_INDEX

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 21, 2017, 04:01 UTC
Message-ID
<xmqqfuh25rzz.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAP8UFD1LAU8hg4ioes=y4o_Phgd1zBhUJOmkqTPo++4SprWWpw@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
> Could you try with the following patch:
>
> http://public-inbox.org/git/20170330210354.20018-1-chriscool@tuxfamily.org/

Ah, this reminds me. The patch has been in the stalled state for quite some time due to confusing description. How about explaining it like so and merge it to 'next'?

-- >8 --
From: Christian Couder <christian.couder@gmail.com>
Date: Thu, 30 Mar 2017 23:03:54 +0200
Subject: [PATCH] read-cache: avoid using git_path() in freshen_shared_index()

When performing an interactive rebase in split-index mode, the commit message that one should rework when squashing commits can contain some garbage instead of the usual concatenation of both of the commit messages.

The code uses git_path() to compute the shared index filename, and passes it to check_and_freshen_file() as its argument; there is no guarantee that the rotating pathname buffer passed as argument will stay valid during the life of this call. Make our own copy before calling the function and pass the copy as its argument to avoid this risky pattern.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 read-cache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/read-cache.c b/read-cache.c
index 8cf0673adc..0b166c211a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1690,9 +1690,10 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
  */
 static void freshen_shared_index(char *base_sha1_hex, int warn)
 {
-	const char *shared_index = git_path("sharedindex.%s", base_sha1_hex);
+	char *shared_index = git_pathdup("sharedindex.%s", base_sha1_hex);
 	if (!check_and_freshen_file(shared_index, 1) && warn)
 		warning("could not freshen shared index '%s'", shared_index);
+	free(shared_index);
 }
 
 int read_index_from(struct index_state *istate, const char *path)
-- 
2.13.0-rc0-176-gf5d713c632
Previous: Thomas GummererNext: Christian Couder
Message 14 of 16 in “[BUG] test suite broken with GIT_TEST_SPLIT_INDEX”
  1. Thomas GummererApr 20, 2017
  2. Christian CouderApr 20, 2017
  3. Thomas GummererApr 20, 2017
  4. Christian CouderApr 21, 2017
  5. Duy NguyenApr 21, 2017
  6. Christian CouderApr 21, 2017
  7. Christian CouderApr 21, 2017
  8. Duy NguyenApr 21, 2017
  9. Jeff KingApr 21, 2017
  10. Christian CouderApr 21, 2017
  11. Christian CouderApr 21, 2017
  12. Jeff KingApr 21, 2017
  13. Thomas GummererApr 24, 2017
  14. Junio C HamanoApr 21, 2017
  15. Christian CouderApr 21, 2017
  16. Jeff KingApr 20, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.