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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>:
> > > Nguyễn Thái Ngọc Duy schrieb:
> > >> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> > >
> > > 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'

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

-->--
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;
-->--
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]