Skip to contentSkip to conversation

merge -s ffonly

PATCH Shawn O. Pearce 4 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I really don't care about this feature. But Randal's whining on #git made me stop what I was doing and write something that might turn into it.

Totally untested code. It might reformat your C:\ drive and install Windows ME. Install as $(git --exec-path)/git-merge-ffonly and call as git merge -s ffonly.

If you care about this sort of feature, test it, write tests for it, make a formal patch, and send it for review. No, I will not do this for you. As I said, I don't care about this as a feature.

--8<--

git-merge-ffonly.sh new file +20 -0
new file mode 100644
index 0000000..24363b5
@@ -0,0 +1,20 @@
+#!/bin/sh
+while test $# -gt 0
+do
+	if test "z$1" = z--
+	then
+		shift
+		break
+	else
+		shift
+	fi
+done
+
+while test $# -gt 0
+do
+	if test -n "$(git rev-list $1..HEAD)"
+	then
+		exit 2
+	fi
+	shift
+done
Signature · 1 line
Shawn.
#1 lore raw

[RFC] git rev-contains [Was: merge -s ffonly]

Hello,

git-merge-ffonly.sh line 15

Quoted 1 line
git-merge-ffonly.sh new file +1 -0
+	if test -n "$(git rev-list $1..HEAD)"

I already wrote similar tests and I wonder if this couldn't be done in a new builtin command more effectively. Something like

git rev-contains HEAD "$1"

. I expect it to be faster and maybe it prevents a command line overflow?! (I remember something like 32000 chars max in a command, but I could not trigger that with bash.)

Best regards
Uwe

#2 lore raw

Re: [RFC] git rev-contains [Was: merge -s ffonly]

Quoted 8 lines · On Tue, Oct 07, 2008 at 08:58:15PM +0200, =?ISO-8859-1?Q?Uwe_Kleine-K=F6nig_…

git-merge-ffonly.sh line 15

Quoted 1 line
git-merge-ffonly.sh new file +1 -0
+	if test -n "$(git rev-list $1..HEAD)"

I already wrote similar tests and I wonder if this couldn't be done in a new builtin command more effectively. Something like

git rev-contains HEAD "$1"

. I expect it to be faster and maybe it prevents a command line overflow?! [...]

I'm not sure this warrants a builtin; seems like test is perfectly capable of doing what you want:

if test '(' -n "$(git rev-list --max-count=1 $1..HEAD)" ')' -a \
	'(' -z "$(git rev-list --max-count=1 HEAD..$1)" ')'

The second check is needed to ensure that the commits actually have an ancestor-descendant relationship. And --max-count means your command line won't overflow.

Or what about this:

if test "$(git merge-base $1 HEAD)" = "$(git rev-parse $1)"

My $0.02,
Deskin Miller

#3 lore raw

Re: [RFC] git rev-contains [Was: merge -s ffonly]

Hello Deskin,

Quoted 10 lines · Deskin Miller
Quoted 8 lines · On Tue, Oct 07, 2008 at 08:58:15PM +0200, =?ISO-8859-1?Q?Uwe_Kleine-K=F6nig_…

git-merge-ffonly.sh line 15

Quoted 1 line
git-merge-ffonly.sh new file +1 -0
+	if test -n "$(git rev-list $1..HEAD)"

I already wrote similar tests and I wonder if this couldn't be done in a new builtin command more effectively. Something like

git rev-contains HEAD "$1"

. I expect it to be faster and maybe it prevents a command line overflow?! [...]

Quoted 8 lines

I'm not sure this warrants a builtin; seems like test is perfectly capable of doing what you want:

if test '(' -n "$(git rev-list --max-count=1 $1..HEAD)" ')' -a \
	'(' -z "$(git rev-list --max-count=1 HEAD..$1)" ')'

The second check is needed to ensure that the commits actually have an ancestor-descendant relationship.

This is needed for the original patch, too, isn't it.

Quoted 2 lines

And --max-count means your command line
won't overflow.

ah, --max-count is a nice idea. Topgit could benefit from it.

Quoted 3 lines

Or what about this:

if test "$(git merge-base $1 HEAD)" = "$(git rev-parse $1)"

It's not entirely clear to me, this works in general, because a merge-base isn't unique. It should work in this case, though.

Best regards
Uwe

#4 lore raw

Re: [RFC] git rev-contains [Was: merge -s ffonly]

In reply to Uwe Kleine-König
Quoted 6 lines · Uwe Kleine-König

Hello,

git-merge-ffonly.sh line 15

Quoted 1 line
git-merge-ffonly.sh new file +1 -0
+	if test -n "$(git rev-list $1..HEAD)"

I already wrote similar tests and I wonder if this couldn't be done in a new builtin command more effectively. Something like

Quoted 6 lines

git rev-contains HEAD "$1"

. I expect it to be faster and maybe it prevents a command line overflow?! (I remember something like 32000 chars max in a command, but I could not trigger that with bash.)

On Linux (well, on my system anyways), it's 128K for arguments and environment combined.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231