Skip to contentSkip to conversation

doc/git-rebase.txt: remove mention of multiple strategies

PATCH In review Nguyễn Thái Ngọc Duy 4 participants 21 messages Jun 15, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 doc/git-rebase.txt: remove mention of multiple strategies

git-rebase.sh does not seem to support this.

---
I have starred at git-rebase.sh many times and still don't know how it can do multiple strategies. So assume it's wrong, remove it.

 Documentation/git-rebase.txt |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Documentation/git-rebase.txt +1 -2
index 3d5a066..26f3b7b 100644
@@ -231,8 +231,7 @@ OPTIONS
 
 -s <strategy>::
 --strategy=<strategy>::
-	Use the given merge strategy; can be supplied more than
-	once to specify them in the order they should be tried.
+	Use the given merge strategy.
 	If there is no `-s` option, a built-in list of strategies
 	is used instead ('git-merge-recursive' when merging a single
 	head, 'git-merge-octopus' otherwise).  This implies --merge.
Signature · 1 line
test
#1 lore raw

PATCH 2/3 t/t3400-rebase.sh: add more tests to help migrating git-rebase.sh to C

These new tests make sure I don't miss any check being performed before rebase is proceeded (which is well tested by other tests)

---
 t/t3400-rebase.sh |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
t/t3400-rebase.sh +28 -0
index 6e391a3..37f86ab 100755
@@ -41,9 +41,37 @@ test_expect_success \
      git tag topic
 '
 
+test_expect_success 'rebase on dirty worktree' '
+     echo dirty >> A &&
+     ! git rebase master'
+
+test_expect_success 'rebase on dirty cache' '
+     git add  A &&
+     ! git rebase master'
+
 test_expect_success 'rebase against master' '
+     git reset HEAD &&
+     git checkout -f &&
      git rebase master'
 
+test_expect_success 'rebase against master twice' '
+	git rebase master 2>&1|grep "Current branch my-topic-branch is up to date\\."
+'
+
+test_expect_success 'rebase against master twice with --force' '
+	git rebase --force-rebase master 2>&1|grep "Current branch my-topic-branch is up to date, rebase forced"
+'
+
+test_expect_success 'rebase against master twice from another branch' '
+	git checkout my-topic-branch^ &&
+	git rebase master my-topic-branch 2>&1|grep "Current branch my-topic-branch is up to date\\."
+'
+
+test_expect_success 'rebase fast-forward to master' '
+	git checkout my-topic-branch^ &&
+	git rebase my-topic-branch 2>&1|grep "Fast-forwarded HEAD to my-topic-branch"
+'
+
 test_expect_success \
     'the rebase operation should not have destroyed author information' \
     '! (git log | grep "Author:" | grep "<>")'
Signature · 1 line
test
#2 lore raw

PATCH 3/3 Build in git-rebase.sh

---
Regression: "-M" is gone. Don't really want to mess up struct option for "-M"

 Makefile                       |    2 +-
 builtin-rebase.c               |  992 ++++++++++++++++++++++++++++++++++++++++
 builtin.h                      |    1 +
 contrib/examples/git-rebase.sh |  530 +++++++++++++++++++++
 git-rebase.sh                  |  530 ---------------------
 git.c                          |    1 +
 6 files changed, 1525 insertions(+), 531 deletions(-)
 create mode 100644 builtin-rebase.c
 create mode 100755 contrib/examples/git-rebase.sh
 delete mode 100755 git-rebase.sh
Makefile +1 -1
index fdb39fa..fec6c40 100644
@@ -302,7 +302,6 @@ SCRIPT_SH += git-parse-remote.sh
 SCRIPT_SH += git-pull.sh
 SCRIPT_SH += git-quiltimport.sh
 SCRIPT_SH += git-rebase--interactive.sh
-SCRIPT_SH += git-rebase.sh
 SCRIPT_SH += git-repack.sh
 SCRIPT_SH += git-request-pull.sh
 SCRIPT_SH += git-sh-setup.sh
@@ -597,6 +596,7 @@ BUILTIN_OBJS += builtin-prune-packed.o
 BUILTIN_OBJS += builtin-prune.o
 BUILTIN_OBJS += builtin-push.o
 BUILTIN_OBJS += builtin-read-tree.o
+BUILTIN_OBJS += builtin-rebase.o
 BUILTIN_OBJS += builtin-receive-pack.o
 BUILTIN_OBJS += builtin-reflog.o
 BUILTIN_OBJS += builtin-remote.o
builtin-rebase.c new file +992 -0

992 lines not on this page · raw message

builtin.h +1 -0
index 425ff8e..53bf2b0 100644
@@ -80,6 +80,7 @@ extern int cmd_prune(int argc, const char **argv, const char *prefix);
 extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
 extern int cmd_push(int argc, const char **argv, const char *prefix);
 extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_rebase(int argc, const char **argv, const char *prefix);
 extern int cmd_receive_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_reflog(int argc, const char **argv, const char *prefix);
 extern int cmd_remote(int argc, const char **argv, const char *prefix);
contrib/examples/git-rebase.sh new file +530 -0

530 lines not on this page · raw message

git-rebase.sh deleted +0 -530

530 lines not on this page · raw message

git.c +1 -0
index 5a00726..39456a0 100644
@@ -336,6 +336,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "prune-packed", cmd_prune_packed, RUN_SETUP },
 		{ "push", cmd_push, RUN_SETUP },
 		{ "read-tree", cmd_read_tree, RUN_SETUP },
+		{ "rebase", cmd_rebase, RUN_SETUP | NEED_WORK_TREE },
 		{ "receive-pack", cmd_receive_pack },
 		{ "reflog", cmd_reflog, RUN_SETUP },
 		{ "remote", cmd_remote, RUN_SETUP },
Signature · 1 line
test
#13 lore raw

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

In reply to Nguyễn Thái Ngọc Duy
Quoted 4 lines · Nguyễn Thái Ngọc Duy

---
Regression: "-M" is gone. Don't really want to mess up struct option for "-M"

Quoted 10 lines
 Makefile                       |    2 +-
 builtin-rebase.c               |  992 ++++++++++++++++++++++++++++++++++++++++
 builtin.h                      |    1 +
 contrib/examples/git-rebase.sh |  530 +++++++++++++++++++++
 git-rebase.sh                  |  530 ---------------------
 git.c                          |    1 +
 6 files changed, 1525 insertions(+), 531 deletions(-)
 create mode 100644 builtin-rebase.c
 create mode 100755 contrib/examples/git-rebase.sh
 delete mode 100755 git-rebase.sh

You should have used -M option to git-format-patch to make it clear that this patch moves git-rebase.sh to contrib/examples/git-rebase.sh without changes.

[...]

builtin-rebase.c line 39

Quoted 12 lines
builtin-rebase.c new file +12 -0
+#define REBASE_ABORT		0x0001
+#define REBASE_CONTINUE		0x0002
+#define REBASE_FORCE		0x0004
+#define REBASE_IGNORE_DATE	0x0008
+#define REBASE_INTERACTIVE	0x0010
+#define REBASE_MERGE		0x0020
+#define REBASE_STAT		0x0040
+#define REBASE_NO_VERIFY	0x0080
+#define REBASE_PRESERVE_MERGES	0x0100
+#define REBASE_ROOT		0x0200
+#define REBASE_SKIP		0x0400
+#define REBASE_VERBOSE		0x0800

I see misaligns here...

[...]

Couldn't you use parseopt also in subcommands?

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#14 lore raw

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

2009/5/21 Jakub Narebski <[email protected]>:

Quoted 17 lines
Quoted 10 lines · Nguyễn Thái Ngọc Duy

---
 Regression: "-M" is gone. Don't really want to mess up struct option for "-M"

 Makefile                       |    2 +-
 builtin-rebase.c               |  992 ++++++++++++++++++++++++++++++++++++++++ builtin.h                      |    1 + contrib/examples/git-rebase.sh |  530 +++++++++++++++++++++ git-rebase.sh                  |  530 ---------------------
 git.c                          |    1 +

Quoted 4 lines
 6 files changed, 1525 insertions(+), 531 deletions(-)

 create mode 100644 builtin-rebase.c create mode 100755 contrib/examples/git-rebase.sh delete mode 100755 git-rebase.sh

Quoted 3 lines

You should have used -M option to git-format-patch to make it clear that this patch moves git-rebase.sh to contrib/examples/git-rebase.sh without changes.

Yes, much shorter patch. I recall some issues about reversable patch long ago so I did not bother finding this option.

Quoted 15 lines

[...]

builtin-rebase.c line 39

Quoted 12 lines
builtin-rebase.c new file +12 -0
+#define REBASE_ABORT         0x0001
+#define REBASE_CONTINUE              0x0002
+#define REBASE_FORCE         0x0004
+#define REBASE_IGNORE_DATE   0x0008
+#define REBASE_INTERACTIVE   0x0010
+#define REBASE_MERGE         0x0020
+#define REBASE_STAT          0x0040
+#define REBASE_NO_VERIFY     0x0080
+#define REBASE_PRESERVE_MERGES       0x0100
+#define REBASE_ROOT          0x0200
+#define REBASE_SKIP          0x0400
+#define REBASE_VERBOSE               0x0800

I see misaligns here...

Hmm.. it's perfectly aligned in complete source form. Probably because of TABs.

Quoted 3 lines

[...]

Couldn't you use parseopt also in subcommands?

I don't understand. You mean parseopt for --continue, --skip and --abort?

Signature · 1 line
Duy
#15 lore raw

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

Quoted 19 lines · Nguyen Thai Ngoc Duy

2009/5/21 Jakub Narebski <[email protected]>:

Quoted 17 lines

Nguyễn Thái Ngọc Duy    <[email protected]> writes:

[...]

builtin-rebase.c line 39

Quoted 12 lines
builtin-rebase.c new file +12 -0
+#define REBASE_ABORT         0x0001
+#define REBASE_CONTINUE              0x0002
+#define REBASE_FORCE         0x0004
+#define REBASE_IGNORE_DATE   0x0008
+#define REBASE_INTERACTIVE   0x0010
+#define REBASE_MERGE         0x0020
+#define REBASE_STAT          0x0040
+#define REBASE_NO_VERIFY     0x0080
+#define REBASE_PRESERVE_MERGES       0x0100
+#define REBASE_ROOT          0x0200
+#define REBASE_SKIP          0x0400
+#define REBASE_VERBOSE               0x0800

I see misaligns here...

Quoted 2 lines

Hmm.. it's perfectly aligned in complete source form. Probably because of TABs.

Yes, it is because of using TABs to align (and not only to indent), and probably because of changing tabstop because of extra character ('+' at beginning). I don't know good solution for this problem.

Quoted 6 lines
Quoted 3 lines

[...]

Couldn't you use parseopt also in subcommands?

I don't understand. You mean parseopt for --continue, --skip and --abort?

Yes. I don't know if it possible, and if it would make sense, but it seems strange to me having both parseopts in main, and strcmp comparisons for other parts...

Signature · 2 lines
Jakub Narebski
Poland
#16 lore raw

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

Quoted 10 lines · Jakub Narebski
Quoted 6 lines
Quoted 3 lines

[...]

Couldn't you use parseopt also in subcommands?

I don't understand. You mean parseopt for --continue, --skip and --abort?

Yes. I don't know if it possible, and if it would make sense, but it seems strange to me having both parseopts in main, and strcmp comparisons for other parts...

Ah you meant --interactive. It's because git-rebase--interactive.sh is a separate command and it needs full arguments. parseopts eats arguments. I'm too lazy to rebuild argv after being eaten by parseopts. So just search for "interactive" sign, then pass them all to git-rebase--interactive.sh (until git-rebase--interactive.sh is built in)

Signature · 1 line
Duy
#17 lore raw

Re: [PATCH v0 2/3] t/t3400-rebase.sh: add more tests to help migrating git-rebase.sh to C

In reply to Nguyễn Thái Ngọc Duy

t/t3400-rebase.sh test_expect_success \ · line 46

Quoted 3 lines · Nguyễn Thái Ngọc Duy
t/t3400-rebase.sh +3 -0
+test_expect_success 'rebase on dirty worktree' '
+     echo dirty >> A &&
+     ! git rebase master'

It is a good defensive way to use "test_must_fail" instead of "!" when testing git itself; test_must_fail does not allow the program to terminate with non-zero value by segfaulting, while "!" does.

t/t3400-rebase.sh test_expect_success \ · line 49

Quoted 2 lines
t/t3400-rebase.sh +2 -0
+test_expect_success 'rebase on dirty cache' '
+     git add  A &&

Two-spaces?

t/t3400-rebase.sh test_expect_success \ · line 54

Quoted 5 lines
t/t3400-rebase.sh +4 -0
+     ! git rebase master'
+
 test_expect_success 'rebase against master' '
+     git reset HEAD &&
+     git checkout -f &&

Hmm, why not "reset --hard HEAD". Not asking to change (yet), but just asking if there is a reason.

t/t3400-rebase.sh test_expect_success \ · line 62

Quoted 8 lines

git rebase master'

t/t3400-rebase.sh +6 -0
+test_expect_success 'rebase against master twice' '
+	git rebase master 2>&1|grep "Current branch my-topic-branch is up to date\\."
+'
+
+test_expect_success 'rebase against master twice with --force' '
+	git rebase --force-rebase master 2>&1|grep "Current branch my-topic-branch is up to date, rebase forced"

Do not to use any pipe while testing, i.e.

	git rebase >out 2>err &&
        grep "what you expect in 'out'" out &&
        grep "what you expect in 'err'" err

so that you can catch exit status from the command you placed in the upstream of the pipe.

#19 lore raw

Re: [PATCH v0 2/3] t/t3400-rebase.sh: add more tests to help migrating git-rebase.sh to C

In reply to Nguyễn Thái Ngọc Duy
Quoted 13 lines · Nguyễn Thái Ngọc Duy

These new tests make sure I don't miss any check being performed before rebase is proceeded (which is well tested by other tests)

---
 t/t3400-rebase.sh |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
t/t3400-rebase.sh +0 -0
index 6e391a3..37f86ab 100755

t/t3400-rebase.sh test_expect_success \ · line 46

Quoted 6 lines
t/t3400-rebase.sh +3 -0
@@ -41,9 +41,37 @@ test_expect_success \
      git tag topic
 '
 
+test_expect_success 'rebase on dirty worktree' '
+     echo dirty >> A &&
+     ! git rebase master'

Shouldn't you use test_must_fail instead? From t/test-lib.sh (paraphrasing):

Writing this as "! git rebase master" is wrong, because the failure could be due to a segv. We want a controlled failure.

t/t3400-rebase.sh test_expect_success \ · line 59

Quoted 13 lines
t/t3400-rebase.sh +10 -0
+
+test_expect_success 'rebase on dirty cache' '
+     git add  A &&
+     ! git rebase master'
+
 test_expect_success 'rebase against master' '
+     git reset HEAD &&
+     git checkout -f &&
      git rebase master'
 
+test_expect_success 'rebase against master twice' '
+	git rebase master 2>&1|grep "Current branch my-topic-branch is up to date\\."
+'

It would be more readable to split this line on '|', i.e.:

+test_expect_success 'rebase against master twice' '
+ git rebase master 2>&1 |
+ grep "Current branch my-topic-branch is up to date\\."
+'

I think we prefer to save output to a file, and compare this file with expected output (using test_cmp). Additionally you can check if the message you want is in correct stream (is in STDERR, and STDOUT is empty).

Quoted 4 lines
t/t3400-rebase.sh +4 -0
+
+test_expect_success 'rebase against master twice with --force' '
+	git rebase --force-rebase master 2>&1|grep "Current branch my-topic-branch is up to date, rebase forced"
+'

t/t3400-rebase.sh test_expect_success \ · line 73

Quoted 10 lines
t/t3400-rebase.sh +10 -0
+
+test_expect_success 'rebase against master twice from another branch' '
+	git checkout my-topic-branch^ &&
+	git rebase master my-topic-branch 2>&1|grep "Current branch my-topic-branch is up to date\\."
+'
+
+test_expect_success 'rebase fast-forward to master' '
+	git checkout my-topic-branch^ &&
+	git rebase my-topic-branch 2>&1|grep "Fast-forwarded HEAD to my-topic-branch"
+'

Same as above.

t/t3400-rebase.sh test_expect_success \ · line 77

Quoted 4 lines
t/t3400-rebase.sh +1 -0
+
 test_expect_success \
     'the rebase operation should not have destroyed author information' \
     '! (git log | grep "Author:" | grep "<>")'

Errrr... what? Why git-log and not git-cat-file? Why grep twice? Additionally you do not check here that author is unchanged, only that is not destroyed.

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git
#20 lore raw

Re: [PATCH v0 2/3] t/t3400-rebase.sh: add more tests to help migrating git-rebase.sh to C

2009/5/21 Jakub Narebski <[email protected]>:

Quoted 25 lines
Quoted 16 lines · Nguyễn Thái Ngọc Duy

These new tests make sure I don't miss any check being performed before rebase is proceeded (which is well tested by other tests)

---
 t/t3400-rebase.sh |   28 ++++++++++++++++++++++++++++

 1 files changed, 28 insertions(+), 0 deletions(-)
t/t3400-rebase.sh +0 -0
index 6e391a3..37f86ab 100755
@@ -41,9 +41,37 @@ test_expect_success \

      git tag topic
 '

Quoted 3 lines

+test_expect_success 'rebase on dirty worktree' '
+     echo dirty >> A &&
+     ! git rebase master'

Shouldn't you use test_must_fail instead? From t/test-lib.sh (paraphrasing):

Quoted 2 lines

 Writing this as "! git rebase master" is wrong, because the failure could be due to a segv.  We want a controlled failure.

Right. Shouldn't we have another patch to fix this once and for all? I did "grep -F '! git'" and find a few places applicable too.

Quoted 8 lines
Quoted 4 lines

+
 test_expect_success \
     'the rebase operation should not have destroyed author information' \
     '! (git log | grep "Author:" | grep "<>")'

Errrr... what?  Why git-log and not git-cat-file?  Why grep twice? Additionally you do not check here that author is unchanged, only that is not destroyed.

Errr.. this is not from me. No idea why.

Signature · 1 line
Duy
#5 lore raw

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

In reply to Nguyen Thai Ngoc Duy
Quoted 8 lines · Nguyen Thai Ngoc Duy

2009/5/22 Johannes Sixt <[email protected]>:

Quoted 5 lines
Quoted 1 line · Nguyễn Thái Ngọc Duy

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?

--<--

builtin-rebase.c +3 -2
index 2acea59..5582f1d 100644
@@ -56,7 +56,8 @@ static int rebase_config(const char *var, const char *value, void *data)
 			((struct rebase_opt*)data)->flags |= REBASE_STAT;
 		return 0;
 	}
-	return 0;
+
+	return git_default_config(var, value, data);
 }
 
 /* utility functions */
@@ -504,7 +505,7 @@ static void run_interactive(int argc, const char **argv)
 	ret = run_command(&cp);
 	if (IS_RUN_COMMAND_ERR(ret))
 		die("Failed to run git rebase--interactive");
-	exit(ret);
+	exit(-ret);
 }
 
 /* from diff.c */

--<--

#6 lore raw

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

Quoted 5 lines · Nguyen Thai Ngoc Duy
Quoted 4 lines · Nguyen Thai Ngoc Duy

2009/5/22 Johannes Sixt <[email protected]>:

Quoted 3 lines
Quoted 1 line · Nguyễn Thái Ngọc Duy
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

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)

-->--

compat/snprintf.c +10 -9
index 357e733..1cea768 100644
@@ -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;

-->--

#7 lore raw

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

Quoted 8 lines · Nguyen Thai Ngoc Duy
Quoted 7 lines · Nguyen Thai Ngoc Duy
Quoted 6 lines · Nguyen Thai Ngoc Duy

2009/5/22 Johannes Sixt <[email protected]>:

Quoted 4 lines
Quoted 1 line · Nguyễn Thái Ngọc Duy

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.

Quoted 8 lines
Quoted 3 lines

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?

Quoted 2 lines

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.

Quoted 41 lines
compat/snprintf.c +10 -9
index 357e733..1cea768 100644
@@ -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;
#8 lore raw

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

Quoted 16 lines · Johannes Sixt
Quoted 15 lines · Nguyen Thai Ngoc Duy
Quoted 10 lines · Nguyen Thai Ngoc Duy
Quoted 6 lines · Nguyen Thai Ngoc Duy

2009/5/22 Johannes Sixt <[email protected]>:

Quoted 4 lines
Quoted 1 line · Nguyễn Thái Ngọc Duy

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:

Quoted 6 lines
Quoted 1 line

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?

It could be. I used git.git's next branch, not msys4git or mingw.git repositories.

Quoted 2 lines

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

The first vsnprintf() in "onto" case above did not produce " --onto" as it should have been. I tried to recover by filling "str" with the second vsnprintf() in the loop.

Quoted 5 lines
Quoted 2 lines

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.

Good to know.

Signature · 1 line
Duy
#9 lore raw

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

Quoted 5 lines · Nguyen Thai Ngoc Duy
Quoted 4 lines · Johannes Sixt
Quoted 3 lines · Nguyen Thai Ngoc Duy

Someone with better Windows knowledge than me should explain how this works. Windows' snprintf() just cuts out the last character in this statement:

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

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?

It could be. I used git.git's next branch, not msys4git or mingw.git repositories.

OK. Assuming you are using the latest msysgit compiler, which is gcc 4.4, then you need the SNPRINTF_SIZE_CORR related patch from 4msysgit.git.

-- Hannes

#10 lore raw

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

Quoted 12 lines · Johannes Sixt
Quoted 11 lines · Nguyen Thai Ngoc Duy
Quoted 9 lines · Johannes Sixt
Quoted 4 lines · Nguyen Thai Ngoc Duy

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?

Quoted 5 lines
Quoted 2 lines

It could be. I used git.git's next branch, not msys4git or mingw.git repositories.

OK. Assuming you are using the latest msysgit compiler, which is gcc 4.4, then you need the SNPRINTF_SIZE_CORR related patch from 4msysgit.git.

It's cross compiler 4.3. Will try the patch.

Signature · 1 line
Duy
#11 lore raw

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

Quoted 13 lines · Nguyen Thai Ngoc Duy
Quoted 12 lines · Johannes Sixt
Quoted 11 lines · Nguyen Thai Ngoc Duy
Quoted 9 lines · Johannes Sixt
Quoted 4 lines · Nguyen Thai Ngoc Duy

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?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

It could be. I used git.git's next branch, not msys4git or mingw.git repositories.

OK. Assuming you are using the latest msysgit compiler, which is gcc 4.4, then you need the SNPRINTF_SIZE_CORR related patch from 4msysgit.git.

It's cross compiler 4.3. Will try the patch.

It is because of SNPRINTF_SIZE_CORR. Thank you.

Signature · 1 line
Duy
#18 lore raw

PATCH 2/3 t/t3400-rebase.sh: add more tests to help migrating git-rebase.sh to C

In reply to Junio C Hamano

These new tests make sure I don't miss any check being performed before rebase is proceeded (which is well tested by other tests)

---
Fixed pipe stuff, test_must_fail and spaces

 t/t3400-rebase.sh |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
t/t3400-rebase.sh +31 -0
index 6e391a3..7f62bfb 100755
@@ -41,9 +41,40 @@ test_expect_success \
      git tag topic
 '
 
+test_expect_success 'rebase on dirty worktree' '
+     echo dirty >> A &&
+     test_must_fail git rebase master'
+
+test_expect_success 'rebase on dirty cache' '
+     git add A &&
+     test_must_fail git rebase master'
+
 test_expect_success 'rebase against master' '
+     git reset --hard HEAD &&
      git rebase master'
 
+test_expect_success 'rebase against master twice' '
+     git rebase master 2>err &&
+     grep "Current branch my-topic-branch is up to date" err
+'
+
+test_expect_success 'rebase against master twice with --force' '
+     git rebase --force-rebase master >out &&
+     grep "Current branch my-topic-branch is up to date, rebase forced" out
+'
+
+test_expect_success 'rebase against master twice from another branch' '
+     git checkout my-topic-branch^ &&
+     git rebase master my-topic-branch 2>err &&
+     grep "Current branch my-topic-branch is up to date" err
+'
+
+test_expect_success 'rebase fast-forward to master' '
+     git checkout my-topic-branch^ &&
+     git rebase my-topic-branch 2>err &&
+     grep "Fast-forwarded HEAD to my-topic-branch" err
+'
+
 test_expect_success \
     'the rebase operation should not have destroyed author information' \
     '! (git log | grep "Author:" | grep "<>")'
Signature · 1 line
test