Re: [PATCH] git-merge: do up-to-date check also for strategies ours, subtree.
- From
Gerrit Pape <pape@smarden.org>
- Date
- Aug 10, 2007, 13:58 UTC
- Message-ID
- <20070810135815.15682.qmail@16a33814590a07.315fe32.mid.smarden.org>
- In-Reply-To
- <7v3aysxvk3.fsf@assigned-by-dhcp.cox.net>
On Thu, Aug 09, 2007 at 02:11:24PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> Right now I do not have time to dig mailing list archive around > mid March 2006, and I do not recall the requestor's original > rationale, but I have a vague recollection that we added this > "no fast-forward check" specifically in response to a user > request.
Hmm, I don't think my patch affects fast-forwards at all, it checks for no_trivial_merge_strategies whether the remote, that should be merged, has any commits that are not in the current head. If not, no merge strategy should have to do anything.
The patch moves the first case switch at the third position. If, with the patch, the first switch matches, it doesn't change behavior as it does the same as the third; if the second switch matches, git-merge will report 'Already up-to-date.' and exit.
This is with the patch:
$ (git init && touch foo && git add foo && git commit -m foo) >/dev/null
$ git checkout -b b
Switched to a new branch "b"
$ (touch bar && git add bar && git commit -m bar) >/dev/null
$ git checkout master
Switched to branch "master"
$ git merge b
Updating 769e777..8a03d99
Fast forward
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 bar
$ git reset --hard HEAD^
HEAD is now at 769e777... foo
$ git merge -s ours b
Merge made by ours.
$ git show
commit f0dc487c15e502bc7ee823b6907468eb78668dbb
Author: Gerrit Pape <pape@smarden.org>
Date: Fri Aug 10 13:44:10 2007 +0000
Merge branch 'b'
diff --git a/bar b/bar
deleted file mode 100644
index e69de29..0000000
$ git merge -s ours b
Already up-to-date.
$ Without the patch, the last command results in
$ git merge -s ours b
Merge made by ours.
$ git show
commit 21154261ff23f64fc38e8a2ae79c7a1cccaeacd4
Author: Gerrit Pape <pape@smarden.org>
Date: Fri Aug 10 13:48:54 2007 +0000
Merge branch 'b'
$ Regards, Gerrit.