git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix counting problem in `format-patch -<n>`
@ 2010-08-27 20:28 Ramkumar Ramachandra
  2010-08-27 20:28 ` [PATCH 1/2] t4014-format-patch: Call test_tick before committing Ramkumar Ramachandra
  2010-08-27 20:28 ` [PATCH 2/2] format-patch: Don't go over merge commits Ramkumar Ramachandra
  0 siblings, 2 replies; 3+ messages in thread
From: Ramkumar Ramachandra @ 2010-08-27 20:28 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Jonathan Nieder, Junio C Hamano

Hi,

Here's a patch avoid the 'git format-patch -3' confusion I complained
about earlier along with a test. 1/2 isn't strictly a prerequisite,
but results seem to be unpredictable without it.

Based on master.

Ramkumar Ramachandra (2):
  t4014-format-patch: Call test_tick before committing
  format-patch: Don't go over merge commits

 Documentation/git-format-patch.txt |    2 +-
 builtin/log.c                      |    7 +------
 t/t4014-format-patch.sh            |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 7 deletions(-)

-- 
1.7.2.2.409.gdbb11.dirty

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] t4014-format-patch: Call test_tick before committing
  2010-08-27 20:28 [PATCH 0/2] Fix counting problem in `format-patch -<n>` Ramkumar Ramachandra
@ 2010-08-27 20:28 ` Ramkumar Ramachandra
  2010-08-27 20:28 ` [PATCH 2/2] format-patch: Don't go over merge commits Ramkumar Ramachandra
  1 sibling, 0 replies; 3+ messages in thread
From: Ramkumar Ramachandra @ 2010-08-27 20:28 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Jonathan Nieder, Junio C Hamano

Call test_tick before attempting to commit in the setup routine to
preserve the order of the commits.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 t/t4014-format-patch.sh |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index f87434b..a77eeed 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -12,24 +12,29 @@ test_expect_success setup '
 	for i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&
 	cat file >elif &&
 	git add file elif &&
+	test_tick &&
 	git commit -m Initial &&
 	git checkout -b side &&
 
 	for i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file &&
 	test_chmod +x elif &&
+	test_tick &&
 	git commit -m "Side changes #1" &&
 
 	for i in D E F; do echo "$i"; done >>file &&
 	git update-index file &&
+	test_tick &&
 	git commit -m "Side changes #2" &&
 	git tag C2 &&
 
 	for i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file &&
 	git update-index file &&
+	test_tick &&
 	git commit -m "Side changes #3 with \\n backslash-n in it." &&
 
 	git checkout master &&
 	git diff-tree -p C2 | git apply --index &&
+	test_tick &&
 	git commit -m "Master accepts moral equivalent of #2"
 
 '
-- 
1.7.2.2.409.gdbb11.dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] format-patch: Don't go over merge commits
  2010-08-27 20:28 [PATCH 0/2] Fix counting problem in `format-patch -<n>` Ramkumar Ramachandra
  2010-08-27 20:28 ` [PATCH 1/2] t4014-format-patch: Call test_tick before committing Ramkumar Ramachandra
@ 2010-08-27 20:28 ` Ramkumar Ramachandra
  1 sibling, 0 replies; 3+ messages in thread
From: Ramkumar Ramachandra @ 2010-08-27 20:28 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Jonathan Nieder, Junio C Hamano

If the topmost three commits in a branch were merge commits, 'git
format-patch -3' used to output nothing. Since Git can't prepare
patches out of merge commits anyway, don't go over them in the first
place. 'git format-patch -3' now prepares three patches from the
topmost three commits without counting merge commits. Also add a
corresponding test in t4014-format-patch and update documentation.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 Documentation/git-format-patch.txt |    2 +-
 builtin/log.c                      |    7 +------
 t/t4014-format-patch.sh            |   16 ++++++++++++++++
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 4b3f5ba..df77474 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -74,7 +74,7 @@ OPTIONS
 include::diff-options.txt[]
 
 -<n>::
-	Limits the number of patches to prepare.
+	Prepare patches from the topmost <n> commits.
 
 -o <dir>::
 --output-directory <dir>::
diff --git a/builtin/log.c b/builtin/log.c
index eaa1ee0..22d1290 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1056,8 +1056,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	rev.commit_format = CMIT_FMT_EMAIL;
 	rev.verbose_header = 1;
 	rev.diff = 1;
-	rev.combine_merges = 0;
-	rev.ignore_merges = 1;
+	rev.no_merges = 1;
 	DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
 	rev.subject_prefix = fmt_patch_subject_prefix;
 	memset(&s_r_opt, 0, sizeof(s_r_opt));
@@ -1228,10 +1227,6 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 			continue;
 		}
 
-		/* ignore merges */
-		if (commit->parents && commit->parents->next)
-			continue;
-
 		if (ignore_if_in_upstream &&
 				has_commit_patch_id(commit, &ids))
 			continue;
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index a77eeed..07bf6eb 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -56,6 +56,22 @@ test_expect_success "format-patch --ignore-if-in-upstream" '
 
 '
 
+test_expect_success "format-patch doesn't consider merge commits" '
+
+	git checkout -b slave master &&
+	echo "Another line" >>file &&
+	test_tick &&
+	git commit -am "Slave change #1" &&
+	echo "Yet another line" >>file &&
+	test_tick &&
+	git commit -am "Slave change #2" &&
+	git checkout -b merger master &&
+	test_tick &&
+	git merge --no-ff slave &&
+	cnt=`git format-patch -3 --stdout | grep "^From " | wc -l` &&
+	test $cnt = 3
+'
+
 test_expect_success "format-patch result applies" '
 
 	git checkout -b rebuild-0 master &&
-- 
1.7.2.2.409.gdbb11.dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-27 20:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-27 20:28 [PATCH 0/2] Fix counting problem in `format-patch -<n>` Ramkumar Ramachandra
2010-08-27 20:28 ` [PATCH 1/2] t4014-format-patch: Call test_tick before committing Ramkumar Ramachandra
2010-08-27 20:28 ` [PATCH 2/2] format-patch: Don't go over merge commits Ramkumar Ramachandra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).