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

Re: [PATCH v0 3/3] Build in git-rebase.sh

From
Johannes Sixt <j.sixt@viscovery.net>
Date
May 25, 2009, 06:16 UTC
Message-ID
<4A1A37AD.4080309@viscovery.net>
In-Reply-To
<20090523145042.GA13139@dektop>
Nguyen Thai Ngoc Duy schrieb:
Show 16 quoted lines
> On Sat, May 23, 2009 at 07:26:03PM +1000, Nguyen Thai Ngoc Duy wrote:
>> On Fri, May 22, 2009 at 05:30:31PM +1000, Nguyen Thai Ngoc Duy wrote:
>>> 2009/5/22 Johannes Sixt <j.sixt@viscovery.net>:
>>>> Nguyễn Thái Ngọc Duy schrieb:
>>>>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>>>> Is it possible for you to test this series on Windows? Many rebase tests
>>>> fail, but I haven't investigated why.
>>> I'll try it this weekend.
>> This patch makes t3*rebase*.sh pass for me except t3412 (more exactly
>> t3412.8). That test failed even with git-rebase.sh. Hmm... Anyway
>> could you try again to see what tests still fail?
> 
> Someone with better Windows knowledge than me should explain how this works. Windows'
> snprintf() just cuts out the last character in this statement:
> 
> snprintf(buf, 8, "--%s", "onto"); // result: '--ont', expected: '--onto'

This doesn't happen for me: neither with Windows's original snprintf nor with the version from compat/. Are you using the latest msysgit environment to compile, i.e. gcc 4.4? There was a change regarding SNPRINTF_SIZE_CORR; perhaps that's the culprit?

I don't undertand what this patch does, anyway. Where is the detail that I am missing?

> All rebase tests now pass for me on Windows (Vista something, I have
> yet to find where it hides its "uname" command)

They also pass for me with your earlier fix-up patch, but with or without this patch to compat/snprintf.c.

Show 41 quoted lines
> diff --git a/compat/snprintf.c b/compat/snprintf.c
> index 357e733..1cea768 100644
> --- a/compat/snprintf.c
> +++ b/compat/snprintf.c
> @@ -13,7 +13,7 @@
>  int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap)
>  {
>  	char *s;
> -	int ret = -1;
> +	int size, ret = -1;
>  
>  	if (maxsize > 0) {
>  		ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap);
> @@ -26,18 +26,19 @@ int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap)
>  		return ret;
>  
>  	s = NULL;
> -	if (maxsize < 128)
> -		maxsize = 128;
> +	size = maxsize < 128 ? 128 : maxsize;
>  
>  	while (ret == -1) {
> -		maxsize *= 4;
> -		str = realloc(s, maxsize);
> -		if (! str)
> +		size *= 4;
> +		s = realloc(s, size);
> +		if (!s)
>  			break;
> -		s = str;
> -		ret = vsnprintf(str, maxsize-SNPRINTF_SIZE_CORR, format, ap);
> -		if (ret == maxsize-1)
> +		s = s;
> +		ret = vsnprintf(s, size-SNPRINTF_SIZE_CORR, format, ap);
> +		if (ret == size-1)
>  			ret = -1;
> +		else
> +			memcpy(str, s, maxsize-1);
>  	}
>  	free(s);
>  	return ret;
Previous: Nguyen Thai Ngoc DuyNext: Nguyen Thai Ngoc Duy
Message 13 of 21 in “doc/git-rebase.txt: remove mention of multiple strategies”
  1. 1/3 doc/git-rebase.txt: remove mention of multiple strategiesNguyễn Thái Ngọc Duy, May 21, 2009
  2. 2/3 t/t3400-rebase.sh: add more tests to help migrating git-rebase.sh to CNguyễn Thái Ngọc Duy, May 21, 2009
  3. 3/3 Build in git-rebase.shNguyễn Thái Ngọc Duy, May 21, 2009
  4. Jakub NarebskiMay 21, 2009
  5. Nguyen Thai Ngoc DuyMay 21, 2009
  6. Jakub NarebskiMay 21, 2009
  7. Nguyen Thai Ngoc DuyMay 21, 2009
  8. Junio C HamanoMay 21, 2009
  9. Johannes SixtMay 22, 2009
  10. Nguyen Thai Ngoc DuyMay 22, 2009
  11. Nguyen Thai Ngoc DuyMay 23, 2009
  12. Nguyen Thai Ngoc DuyMay 23, 2009
  13. Johannes SixtMay 25, 2009
  14. Nguyen Thai Ngoc DuyMay 25, 2009
  15. Johannes SixtMay 25, 2009
  16. Nguyen Thai Ngoc DuyMay 25, 2009
  17. Nguyen Thai Ngoc DuyMay 25, 2009
  18. Jakub NarebskiMay 21, 2009
  19. Nguyen Thai Ngoc DuyMay 21, 2009
  20. Junio C HamanoMay 21, 2009
  21. 2/3 t/t3400-rebase.sh: add more tests to help migrating git-rebase.sh to CNguyễn Thái Ngọc Duy, May 23, 2009

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.