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

Re: [BUG] realloc failed

From
Kazuki Tsujimoto <kazuki@callcc.net>
Date
May 21, 2011, 05:50 UTC
Message-ID
<20110521145056.E3F5.BA9123DE@callcc.net>
In-Reply-To
<7vhb8o25tt.fsf@alter.siamese.dyndns.org>
From: Junio C Hamano <gitster@pobox.com>
Date: Fri, 20 May 2011 18:35:58 -0700
> Care to send a patch with test (see Documentation/SubmittingPatches)?

Thanks for your comment. Here is a patch with test.

[PATCH] Avoid "realloc failed" error in alias expansion including -c option

When the -c option is specified, setenv will be called. Therefore, set envchanged flag to true so that git exits with "alias '%s' changes environment variables" error.

Signed-off-by: Kazuki Tsujimoto <kazuki@callcc.net>
---
 git.c                   |    2 ++
 t/t1020-subdirectory.sh |   15 +++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/git.c b/git.c
index a5ef3c6..e04e4d4 100644
--- a/git.c
+++ b/git.c
@@ -153,6 +153,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				usage(git_usage_string);
 			}
 			git_config_push_parameter((*argv)[1]);
+			if (envchanged)
+				*envchanged = 1;
 			(*argv)++;
 			(*argc)--;
 		} else {
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
index ddc3921..94fed9c 100755
--- a/t/t1020-subdirectory.sh
+++ b/t/t1020-subdirectory.sh
@@ -119,6 +119,21 @@ test_expect_success 'alias expansion' '
 	)
 '
 
+test_expect_success 'alias expansion including "-c <name>=<value>" option' '
+	printf "%s\n%s\n" \
+	       "fatal: alias '"'ss'"' changes environment variables" \
+	       "You can use '"'!git'"' in the alias to do this.">expect &&
+	(
+		cat > .git/config <<EOF &&
+[alias]
+ss = -c name=value status
+EOF
+		cd dir &&
+		test_must_fail git ss 2> ../actual
+	) &&
+	test_cmp expect actual
+'
+
 test_expect_success '!alias expansion' '
 	pwd >expect &&
 	(
-- 
Kazuki Tsujimoto
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 6 in “[BUG] realloc failed”
  1. Kazuki TsujimotoMay 21, 2011
  2. Junio C HamanoMay 21, 2011
  3. Kazuki TsujimotoMay 21, 2011
  4. Junio C HamanoMay 22, 2011
  5. Junio C HamanoMay 22, 2011
  6. Kazuki TsujimotoMay 27, 2011

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.