Additional fast forward strategies.
Quoted 1 line
From
779142c6b22f032c877f550733e1bccc99aca761Mon Sep 17 00:00:00 2001
From: Sverre Hvammen Johansen <[email protected]>
Date: Sun, 9 Mar 2008 21:16:03 -0800
Subject: [PATCH] Additional fast forward strategies.
New fast forward strategies, common, fork, path, and same is introduced. These new fast forward strategies allows additional work flows.
FF strategy "common" does a fast-forward to the common ancestor of the specified heads. The merge will fail unless HEAD is the common ancestor or HEAD can be fast-forwarded to the common ancestor.
FF strategy "fork" does a fast-forward to the common ancestor of the real heads. The merge will fail unless HEAD is the common ancestor of these heads or HEAD can be fast-forwarded to the common ancestor of the real heads.
FF strategy "path" does a fast-forward to the first possible branch that no other branches are ahead of. HEAD will be fast-forwarded to such a branch if it exist. If no such branch exist, HEAD is considered to be up to date.
FF strategy "same" does a fast forward where all branches are required to point to the same commit. HEAD will be fast-forwarded to this branch unless it is up to date.
--- Documentation/fast-forward-strategies.txt | 25 ++ git-merge.sh | 53 ++++- t/t7601-merge-ff-strategies.sh | 373 +++++++++++++++++++++++++++++ 3 files changed, 446 insertions(+), 5 deletions(-)
(quoted diff) +0 -0
b/Documentation/fast-forward-strategies.txt
index 1d6da26..be94cfc 100644
Documentation/fast-forward-strategies.txt +25 -0
@@ -14,3 +14,28 @@ only:: Only allow a fast-forward. The merge will fail unless HEAD is up to date or the merge resolved as a fast-forward. + +common:: + Fast-forward to the common ancestor of the specified + branches if possible. The merge will fail unless + HEAD is the common ancestor or HEAD can be + fast-forwarded to the common ancestor. + +fork:: + Fast-forward to the earliest fork if possible. + The earliest fork is defined as the common ancestor + of the real branches. The merge will fail unless + HEAD is the earliest fork or HEAD can be + fast-forwarded to the earliest fork. + +path:: + Fast-forward to the first possible branch that + no other branches are ahead of. HEAD will be + fast-forwarded to such a branch if it exist. + If no such branch exist, HEAD is considered to be + up to date. + +same:: + The merge will fail unless HEAD is up to date or + the merge resolved as a fast-forward and each + branch is pointing to the same commit.
git-merge.sh +2 -2
@@ -164,21 +164,21 @@ parse_config () { no_commit=t ;; --ff) case "$2" in - allow|never|only) + allow|never|only|common|fork|path|same) fast_forward=$2 squash= no_commit= ; shift ;; -*) fast_forward=allow squash= no_commit= ;; *) - die "available fast-forward strategies are: allow, newer, and only" ;; + die "available fast-forward strategies are: allow, newer, only,
common, path" ;;
esac
;;
--ff=*)
fast_forward=$(echo $1 |cut -d = -f 2) squash= no_commit= case $fast_forward in
- allow|never|only) + allow|never|only|common|fork|path|same)
;;
*)
- die "available fast-forward strategies are: allow, newer, and only" ;;
+ die "available fast-forward strategies are: allow, newer, only,
common, path" ;;
esac
;;
--no-ff)
@@ -374,12 +374,22 @@ find_real_parents () {
done
}
-if test $fast_forward = never -o
+if test $fast_forward = never -o $fast_forward = common
then
real_parents="$@"
ff_head=$head
else
find_real_parents "$@"
+ if test $fast_forward = same
+ then
+ for b in "$@"
+ do
+ if test "$b" != "$1"
+ then
+ die "Fast forward strategy same requires all heads to be the same"
+ fi
+ done
+ fi
fi
if test -n "$real_parents"
@@ -387,6 +397,39 @@ then
case $fast_forward in
only)
die "Fast forward strategy only can only handle one real parent" ;;
+ same)
+ die "Fast forward strategy same have unexpected parents" ;;
+ path)
+ echo "Ignoring branches $real_parents"
+ real_parents=
+ ;;
+ common|fork)
+ if test $fast_forward = fork
+ then
+ common=$(git show-branch --merge-base $ff_head $real_parents)
+ else
+ common=$(git show-branch --merge-base $real_parents)
+ fi
+ if test -n "$common"
+ then
+ common_h=$(git show-branch --merge-base $common $head)
+ if test "$common_h" = $head
+ then
+ if test $common = $head
+ then
+ echo "Ignoring all branches"
+ else
+ echo "Ignoring all branches except for $common"
+ fi
+ ff_head=$common
+ else
+ die "HEAD is ahead of the common anchestor"
+ fi
+ else
+ die "The specified branches does not have any common anchestor"
+ fi
+ real_parents=
+ ;;
never|allow)
if test $head != $ff_head
then
t/t7601-merge-ff-strategies.sh +373 -0
377 lines not on this page · raw message
Signature · 4 lines
1.5.3.3 -- Sverre Hvammen Johansen
I may drop this patch or at least not prioritize it for now. I don't need it and implemented it just for fun. There are other features that are fare more important. The other patch I am working on that implement "--ff=only" is something I need
Signature · 1 line
Sverre Hvammen Johansen
Quoted 4 lines · Sverre Hvammen Johansen
Quoted 1 line
From
779142c6b22f032c877f550733e1bccc99aca761Mon Sep 17 00:00:00 2001From: Sverre Hvammen Johansen <[email protected]>
Date: Sun, 9 Mar 2008 21:16:03 -0800
Subject: [PATCH] Additional fast forward strategies.
Ditto..
Quoted 3 lines
New fast forward strategies, common, fork, path, and same is introduced. These new fast forward strategies allows additional work flows.
Is it sufficient to say "allows additional work flows" here? I only see what they do, and do not see why these are needed/useful anywhere in the proposed commit log message nor documentation.
You need to illustrate the motivation after the above three-line paragraph and before the description of what each of them does below. "Suppose your history looks like this, and you and your group's workflow is like this. Then you would want to only allow these but want to forbid those for such and such reasons." Then list what the "FF options" do. After that, you can conclude "By using these FF options this way, you can achieve that control like this..."
Then people might be convinced that "these allow additional work flows". What you wrote is insufficient, I am afraid. At least to me.
Review
Quoted 3 lines
(quoted diff) +3
-0+ if test $fast_forward = same + then + for b in "$@"
'in "$@"' is always redundant after "for X".
More seriously, why is the user forced to give more than one "same" thing to begin with? The user can give a single thing and be done with it.
Quoted 6 lines · Sverre Hvammen Johansen
From: Sverre Hvammen Johansen <[email protected]>
Subject: [PATCH] Additional fast forward strategies.New fast forward strategies, common, fork, path, and same is introduced. These new fast forward strategies allows additional work flows.
It would be better (read: greater chance to be accepted) if you had provided examples of those "additional workflows", best in EXAMPLES section (or something like that) of fast-forward documentation, and "see documentation" (or something like that) in commit message.
Quoted 3 lines
FF strategy "common" does a fast-forward to the common ancestor of the specified heads. The merge will fail unless HEAD is the common ancestor or HEAD can be fast-forwarded to the common ancestor.
Don't you mean "common descendant" here?
Quoted 4 lines
FF strategy "fork" does a fast-forward to the common ancestor of the real heads. The merge will fail unless HEAD is the common ancestor of these heads or HEAD can be fast-forwarded to the common ancestor of the real heads.
What is the difference between 'real heads' and 'soecified heads'? Example, please.
Quoted 10 lines
FF strategy "path" does a fast-forward to the first possible branch that no other branches are ahead of. HEAD will be fast-forwarded to such a branch if it exist. If no such branch exist, HEAD is considered to be up to date.
FF strategy "same" does a fast forward where all branches are required to point to the same commit. HEAD will be fast-forwarded to this branch unless it is up to date.
Signed-off-by Sverre Hvammen Johansen <[email protected]>
It will be easier to understand those descriptions if you have provided with ASCII-art diagrams (in the documentation, not necessarily in fast-forward strategies^W options description, but perhaps somewhere below, above FAST-FORWARD OPTIONS EXAMPLES section).
For example, by default you can fast-forward only when doing single branch merge.
%%
A---B---C---D <--- master <--- HEAD
\
\-1---2 <--- aIf you have situation as above, you are on branch 'master', and you do "git merge a" it would result in merge commit.
A---B---C---D---M <--- master <--- HEAD
\ /
\-1---2-/ <--- a%%
A---B <--- master <--- HEAD
\
\-1---2 <--- aIf you have situation as above, you are on branch 'master', and you do "git merge a" it would result in fast-forward.
A---B---1---2 <--- master <--- HEAD
^------- a
or
A---B---1---2 <--- master <--- HEAD
^
\------ a%%
A---B <--- master <--- HEAD
\
\-1---2 <--- a^------- b
This I think is 'FF strategy "same"' situation.
%%
A---B <--- master <--- HEAD
\
\-1---2 <--- a
\
\-3 <--- bThis I guess is either 'common' or 'fork' situation.
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git