Re: [PATCH] Allow cherry-picking root commits

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Allow cherry-picking root commits

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:53

Johannes Schindelin [off-list ref] writes:
There is no good reason why cherry-picking root commits should not be 
allowed.
Hmm, does "cherry-pick a root commit" even have a well defined semantics,
other than "if there is no overlap in files just add the files in"?  I
have a feeling that it is more likely to be a user error, a sign that the
user mistyped the name of the commit to pick.

Re: [PATCH] Allow cherry-picking root commits

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:44:53

Hi,

On Sat, 5 Jul 2008, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
There is no good reason why cherry-picking root commits should not be 
allowed.
Hmm, does "cherry-pick a root commit" even have a well defined 
semantics, other than "if there is no overlap in files just add the 
files in"?
Yes.  You can easily add the files identically, or some similar files, in 
which case you get an easily-resolved conflict.
I have a feeling that it is more likely to be a user error, a sign that 
the user mistyped the name of the commit to pick.
Now, now, that is too harsh a statement!

Often I start my work from a tarball, just because the git import takes so 
long that I can fiddle with the thing already while the import runs.

And guess what, it would be easier to rebase that series onto an imported 
tag for me.  The first commit would not result in changes, since it would 
import the identical tree.  Or it would barf, in which case I would know 
that I got the wrong branch point to rebase onto.

At the moment, I play games that need a deep knowledge of Git, which _I_ 
have, but not necessarily occasional Git users.

Ciao,
Dscho

t3503: Add test case for identical files

From: Stephan Beyer <hidden>
Date: 2016-06-15 22:44:53

---

On Sun, Jul 06, 2008, Johannes Schindelin wrote:
Hi,

On Sat, 5 Jul 2008, Junio C Hamano wrote:
quoted
Johannes Schindelin [off-list ref] writes:
quoted
There is no good reason why cherry-picking root commits should not be 
allowed.
Hmm, does "cherry-pick a root commit" even have a well defined 
semantics, other than "if there is no overlap in files just add the 
files in"?
Yes.  You can easily add the files identically, or some similar files, in 
which case you get an easily-resolved conflict.
I think this test case shows that it works for identical files.
This patch is btw just to show Junio that it works. ;)
Because I'd like to see Dscho's patch in git, too.

Regards.

 t/t3503-cherry-pick-root.sh |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/t/t3503-cherry-pick-root.sh b/t/t3503-cherry-pick-root.sh
index b0faa29..bcb6610 100755
--- a/t/t3503-cherry-pick-root.sh
+++ b/t/t3503-cherry-pick-root.sh
@@ -6,14 +6,23 @@ test_description='test cherry-picking a root commit'
 
 test_expect_success setup '
 
+	: > file0 &&
 	echo first > file1 &&
+	echo second > file2 &&
+	git add file0 &&
 	git add file1 &&
 	test_tick &&
 	git commit -m "first" &&
 
+	git symbolic-ref HEAD refs/heads/sharefile &&
+	rm .git/index file0 &&
+	git add file1 &&
+	git add file2 &&
+	test_tick &&
+	git commit -m "file1 and file2" &&
+
 	git symbolic-ref HEAD refs/heads/second &&
 	rm .git/index file1 &&
-	echo second > file2 &&
 	git add file2 &&
 	test_tick &&
 	git commit -m "second"
@@ -23,6 +32,16 @@ test_expect_success setup '
 test_expect_success 'cherry-pick a root commit' '
 
 	git cherry-pick master &&
+	test -f file0 &&
+	test first = $(cat file1)
+
+'
+
+test_expect_success 'cherry-pick a root commit with identical files' '
+
+	git checkout sharefile &&
+	git cherry-pick master &&
+	test -f file0 &&
 	test first = $(cat file1)
 
 '
-- 
1.5.6.361.g18ea7
Stephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help