Commit Graph

45 Commits

Author SHA1 Message Date
Junio C Hamano
a06f678eb9 Deprecate merge-recursive.py
This renames merge-recursive written in Python to merge-recursive-old,
and makes merge-recur as a synonym to merge-recursive.  We do not remove
merge-recur yet, but we will remove merge-recur and merge-recursive-old
in a few releases down the road.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-24 20:33:35 -07:00
Junio C Hamano
c1a788acee Merge branch 'js/read-tree' into js/c-merge-recursive
* js/read-tree: (107 commits)
  read-tree: move merge functions to the library
  read-trees: refactor the unpack_trees() part
  tar-tree: illustrate an obscure feature better
  git.c: allow alias expansion without a git directory
  setup_git_directory_gently: do not barf when GIT_DIR is given.
  Build on Debian GNU/kFreeBSD
  Call setup_git_directory() much earlier
  Call setup_git_directory() early
  Display an error from update-ref if target ref name is invalid.
  Fix http-fetch
  t4103: fix binary patch application test.
  git-apply -R: binary patches are irreversible for now.
  Teach git-apply about '-R'
  Makefile: ssh-pull.o depends on ssh-fetch.c
  log and diff family: honor config even from subdirectories
  git-reset: detect update-ref error and report it.
  lost-found: use fsck-objects --full
  Teach git-http-fetch the --stdin switch
  Teach git-local-fetch the --stdin switch
  Make pull() support fetching multiple targets at once
  ...
2006-07-30 23:42:10 -07:00
Junio C Hamano
06d30f4f3e recur vs recursive: help testing without touching too many stuff.
During git-merge-recur development, you could set an environment
variable GIT_USE_RECUR_FOR_RECURSIVE to use WIP recur in place
of the recursive strategy.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 23:10:19 -07:00
Johannes Schindelin
6d297f8137 Status update on merge-recursive in C
This is just an update for people being interested. Alex and me were
busy with that project for a few days now. While it has progressed nicely,
there are quite a couple TODOs in merge-recursive.c, just search for "TODO".

For impatient people: yes, it passes all the tests, and yes, according
to the evil test Alex did, it is faster than the Python script.

But no, it is not yet finished. Biggest points are:

- there are still three external calls
- in the end, it should not be necessary to write the index more than once
  (just before exiting)
- a lot of things can be refactored to make the code easier and shorter

BTW we cannot just plug in git-merge-tree yet, because git-merge-tree
does not handle renames at all.

This patch is meant for testing, and as such,

- it compile the program to git-merge-recur
- it adjusts the scripts and tests to use git-merge-recur instead of
  git-merge-recursive
- it provides "TEST", a script to execute the tests regarding -recursive
- it inlines the changes to read-cache.c (read_cache_from(), discard_cache()
  and refresh_cache_entry())

Brought to you by Alex Riesen and Dscho

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-13 23:10:19 -07:00
Shawn Pearce
e1447e38c0 Log ref changes made by git-merge and git-pull.
When git-merge updates HEAD as a result of a merge record what
happened during the merge into the reflog associated with HEAD
(if any).  The log reports who caused the update (git-merge or
git-pull, by invoking git-merge), what the remote ref names were
and the type of merge process used.

The merge information can be useful when reviewing a reflog for
a branch such as `master` where fast forward and trivial in index
merges might be common as the user tracks an upstream.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-11 14:16:53 -07:00
Dennis Stosberg
8096fae726 Fix expr usage for FreeBSD
Some implementations of "expr" (e.g. FreeBSD's) fail, if an
argument starts with a dash.

Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-27 10:56:05 -07:00
Junio C Hamano
7d0c68871a git-merge --squash
Some people tend to do many little commits on a topic branch,
recording all the trials and errors, and when the topic is
reasonably cooked well, would want to record the net effect of
the series as one commit on top of the mainline, removing the
cruft from the history.  The topic is then abandoned or forked
off again from that point at the mainline.

The barebone porcelainish that comes with core git tools does
not officially support such operation, but you can fake it by
using "git pull --no-merge" when such a topic branch is not a
strict superset of the mainline, like this:

	git checkout mainline
	git pull --no-commit . that-topic-branch
	: fix conflicts if any
	rm -f .git/MERGE_HEAD
        git commit -a -m 'consolidated commit log message'
	git branch -f that-topic-branch ;# now fully merged

This however does not work when the topic branch is a fast
forward of the mainline, because normal "git pull" will never
create a merge commit in such a case, and there is nothing
special --no-commit could do to begin with.

This patch introduces a new option, --squash, to support such a
workflow officially in both fast-forward case and true merge
case.  The user-level operation would be the same in both cases:

	git checkout mainline
        git pull --squash . that-topic-branch
        : fix conflicts if any -- naturally, there would be
        : no conflict if fast forward.
	git commit -a -m  'consolidated commit log message'
	git branch -f that-topic-branch ;# now fully merged

When the current branch is already up-to-date with respect to
the other branch, there truly is nothing to do, so the new
option does not have any effect.

This was brought up in #git IRC channel recently.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-24 01:11:19 -07:00
Timo Hirvonen
5e7c91d6f7 git-merge: Don't use -p when outputting summary
-p is not needed and we only want diffstat and summary.

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-23 22:49:41 -07:00
Sean
9d76812b42 Convert some "apply --summary" users to "diff --summary".
Signed-off-by: Sean Estabrooks <seanlkml@sympatico.ca>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-14 16:29:20 -07:00
Junio C Hamano
50ac740801 git-merge: a bit more readable user guidance.
We said "fix up by hand" after failed automerge, which was a big
"Huh?  Now what?".  Be a bit more explicit without being too
verbose. Suggested by Carl Worth.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-04-19 15:37:36 -07:00
Junio C Hamano
6ea23343ce git-merge knows some strategies want to skip trivial merges
Most notably "ours".  Also this makes sure we do not record
duplicated parents on the parent list of the resulting commit.

This is based on Mark Wooding's work, but does not change the UI
nor introduce new flags.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-20 00:50:37 -08:00
Olaf Hering
180b0d7483 allow double click on current HEAD id after git-pull
Double click on to current HEAD commit id is not possible,
the dot has to go.

[jc: by popular requests.]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-09 18:13:19 -08:00
Junio C Hamano
816c02ce8e Merge fixes early for next maint series. 2006-02-23 22:27:03 -08:00
Junio C Hamano
744633cbf2 checkout - eye candy.
This implements "eye candy" similar to the pack-object/unpack-object
to entertain users while a large tree is being checked out after
a clone or a pull.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-22 19:04:06 -08:00
Junio C Hamano
d64e6b0429 Keep Porcelainish from failing by broken ident after making changes.
"empty ident not allowed" error makes commit-tree fail, so we
are already safer in that we would not end up with commit
objects that have bogus names on the author or committer fields.
However, before commit-tree is called there are already changes
made to the index file and the working tree.  The operation can
be resumed after fixing the environment problem, but when this
triggers to a newcomer with unusable gecos, the first question
becomes "what did I lose and how would I recover".

This patch modifies some Porcelainish commands to verify
GIT_COMMITTER_IDENT as soon as we know we are going to make some
commits before doing much damage to prevent confusion.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-22 13:14:57 -08:00
Junio C Hamano
6643688867 Merge part of jc/portable branch 2006-02-21 00:52:18 -08:00
Johannes Schindelin
abb7c7b31c Optionally work without python
In some setups (notably server setups) you do not need that dependency.
Gracefully handle the absence of python when NO_PYTHON is defined.

Signed-off-by: Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-18 23:16:09 -08:00
Junio C Hamano
e3b59a44f6 Keep Porcelainish from failing by broken ident after making changes.
"empty ident not allowed" error makes commit-tree fail, so we
are already safer in that we would not end up with commit
objects that have bogus names on the author or committer fields.
However, before commit-tree is called there are already changes
made to the index file and the working tree.  The operation can
be resumed after fixing the environment problem, but when this
triggers to a newcomer with unusable gecos, the first question
becomes "what did I lose and how would I recover".

This patch modifies some Porcelainish commands to verify
GIT_COMMITTER_IDENT as soon as we know we are going to make some
commits before doing much damage to prevent confusion.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-18 20:51:26 -08:00
Junio C Hamano
1536dd9c61 Only call git-rerere if $GIT_DIR/rr-cache exists.
Johannes noticed that git-rerere depends on Digest.pm, and if
one does not use the command, one can live without it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-11 18:55:43 -08:00
Junio C Hamano
8389b52b2a git-rerere: reuse recorded resolve.
In a workflow that employs relatively long lived topic branches,
the developer sometimes needs to resolve the same conflict over
and over again until the topic branches are done (either merged
to the "release" branch, or sent out and accepted upstream).

This commit introduces a new command, "git rerere", to help this
process by recording the conflicted automerge results and
corresponding hand-resolve results on the initial manual merge,
and later by noticing the same conflicted automerge and applying
the previously recorded hand resolution using three-way merge.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-06 21:53:11 -08:00
Junio C Hamano
c0c74a88f9 git-merge: Properly quote $merge_msg variable.
Otherwise it would go though shell expansion...

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-02-03 19:41:33 -08:00
Junio C Hamano
6b94f1e404 merge: seed the commit message with list of conflicted files.
The files with conflicts need to be hand resolved, and it is a
good discipline for the committer to explain which branch was
taken and why.  Pre-fill the merge message template with the
list of conflicted paths to encourage it.

This is from Linus.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-01-27 23:05:05 -08:00
Junio C Hamano
695bf722da merge --no-commit: tweak message
We did not distinguish the case the user asked not to make a
commit with --no-commit flag and the automerge failed.  Tell
these cases apart and phrase dying message differently.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-23 15:48:09 -08:00
freku045@student.liu.se
806f36d4d7 Trivial usage string clean-up
Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-14 02:53:43 -08:00
Junio C Hamano
9954f5b876 [PATCH] allow merging any committish
Although "git-merge" is advertised as the end-user level command
(instead of being a "git-pull" backend), it was not prepared to
take tag objects that point at commits and barfed when fed one.
Sanitize the input while we validate them, for which we already
have a loop.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-13 17:01:23 -08:00
Fredrik Kuivinen
4275df5170 git-merge: Exit with code 2 if no strategy was able to handle the merge.
This way it is possible to test in scripts if the merge was non-clean
or if the strategy had other problems with the merge.

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-12-03 12:28:52 -08:00
Junio C Hamano
ae2b0f1518 git-sh-setup: die if outside git repository.
Now all the users of this script detect its exit status and die,
complaining that it is outside git repository.  So move the code
that dies from all callers to git-sh-setup script.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-25 13:49:17 -08:00
Junio C Hamano
fbf8ac212c git-merge: make recursive the default strategy
git-pull invoked merge with recursive as the default strategy
for some time now; match it in the git-merge itself.  Also avoid
listing more than one strategy on default because we have only
one strategy that can resolve an octopus and we are already
counting heads here.  This reduces the need to stash away local
modifications.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-23 16:23:11 -08:00
Junio C Hamano
13956670a7 Use 'merge-base --all' where applicable.
It may get extra merge base on truly pathological commit histories,
but is a lot easier to understand, explain, and prove correctness.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-09 18:54:14 -08:00
Junio C Hamano
64da9e604e Add 'ours' merge strategy.
This adds the coolest merge strategy ever, "ours".  It can take
arbitrary number of foreign heads and merge them into the
current branch, with the resulting tree always taken from our
branch head, hence its name.

What this means is that you can declare that the current branch
supersedes the development histories of other branches using
this merge strategy.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-03 14:55:10 -08:00
Junio C Hamano
123ee3ca7b Add --no-commit to git-merge/git-pull.
With --no-commit flag, git-pull will perform the merge but pretends as
if the merge needed a hand resolve even if automerge cleanly resolves,
to give the user a chance to add further changes and edit the commit
message.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-03 14:55:10 -08:00
Chris Shoemaker
50b8e355b6 Documentation changes to recursive option for git-diff-tree
Update docs and usages regarding '-r' recursive option for git-diff-tree.
Remove '-r' from common diff options, mention it only for git-diff-tree.
Remove one extraneous use of '-r' with git-diff-files in get-merge.sh.
Sync the synopsis and usage string for git-diff-tree.

Signed-off-by: Chris Shoemaker <c.shoemaker at cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-28 13:37:38 -07:00
Junio C Hamano
4f692b1978 Allow git-merge not to commit.
Martin Langhoff wants to use git-merge from outside git-pull and wants
to do further processing; for this, he wants git-merge no to commit
even when it cleanly merges.  I think other script writers would want
something like that as well, so here it is.

Instead of the "merge commit message" parameter (which usually is made
for you by "git-pull" which calls this command), you pass an empty
string to it.  Then it will not update your HEAD -- you can do whatever
you want with the resulting index file, which contains the merge results.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-22 04:45:15 -07:00
Fredrik Kuivinen
88f8f0a52b [PATCH] Enable and fix support for base less merges.
Let the merge strategies handle the base less case if they are able to
do it. It also fixes git-resolve.sh to die if no common ancestors
exists, instead of doing the wrong thing. Furthermore, it contains a
small independent fix for git-merge.sh and a fix for a base less code
path in gitMergeCommon.py.

With this it's possible to use
    git merge -s recursive 'merge message' A B
to do a base less merge of A and B.

[jc: Thanks Fredrik for fixing the brown-paper-bag in git-merge.
 I fixed a small typo in git-merge-resolve fix; 'test' equality
 check is spelled with single equal sign -- C-style double equal
 sign is bashism.]

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-03 00:25:42 -07:00
Junio C Hamano
f9d72413bc Handle really trivial case inside git-merge.
Using Linus' --trivial option, this handles really trivial case
inside git-merge itself, without using any strategy modules.

A 'really trivial case' is:

 - we are merging one branch into the current branch;
 - there is only one merge base between the branches;
 - there is no file-level merge required.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-02 11:13:44 -07:00
Junio C Hamano
bf7960eb51 Use git-update-ref in scripts.
This uses the git-update-ref command in scripts for safer updates.
Also places where we used to read HEAD ref by using "cat" were fixed
to use git-rev-parse.  This will matter when we start using symbolic
references.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-28 16:42:44 -07:00
Junio C Hamano
60fa056052 Fastpath the normal case by not checking that index matches HEAD.
The merge strategy would check this itself and typically does it
by using git-read-tree -m -u 3-way merge.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-28 16:29:11 -07:00
Junio C Hamano
deca7e8c59 Give default merge message after failed automerge.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-26 18:04:17 -07:00
Junio C Hamano
a935824036 Fix overzealous cleanliness check in git-merge
Being able to try multiple strategies and automatically picking one
that seems to give less conflicting result may or may not much sense
in practice.  At least that should not force normal use case to
additionally require the working tree to be fully clean.  As Linus
shouted, local changes do not matter unless they interfere with the
merge.

This commit changes git-merge not to require a clean working tree.
Only when we will iterate through more than one merge strategies,
local changes are stashed away before trying the first merge, and
restored before second and later merges are attempted.

The index file must be in sync with HEAD in any case -- otherwise the
merge result would contain changes since HEAD that was done locally
and registered in the index.  This check is already enforced by
three-way read-tree existing merge strategies use, but is done here as
a safeguard as well.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-26 18:04:17 -07:00
Fredrik Kuivinen
8cc01e5019 [PATCH] More descriptive messages for conflict cases in merges
The merge strategies can give more descriptive error messages for
conflict cases if they are given the actual branch names instead of
the SHA1s.

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-25 16:08:54 -07:00
Fredrik Kuivinen
e4cf17ce0d [PATCH] Rename the 'fredrik' merge strategy to 'recursive'.
Otherwise we would regret when Fredrik comes up with another merge
algorithm with different pros-and-cons with the current one.

Signed-off-by: Fredrik Kuivinen <freku045@student.liu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-13 00:20:54 -07:00
Junio C Hamano
f88ed172e7 Fix off-by-one error in git-merge
'git-merge -s' without a strategy name does not fail and does
not give usage as it should.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-12 22:52:52 -07:00
Junio C Hamano
720d150c48 Add a new merge strategy by Fredrik Kuivinen.
I really wanted to try this out, instead of asking for an adjustment
to the 'git merge' driver and waiting.  For now the new strategy is
called 'fredrik' and not in the list of default strategies to be tried.

The script wants Python 2.4 so this commit also adjusts Debian and RPM
build procecure files.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-10 19:46:53 -07:00
Junio C Hamano
2276aa6c09 Use Daniel's read-tree in the merge strategy 'resolve'.
And rename the one Linus kept calling stupid, 'stupid'.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-10 18:30:41 -07:00
Junio C Hamano
91063bbc6c Multi-backend merge driver.
The new command 'git merge' takes the current head and one or more
remote heads, with the commit log message for the automated case.

If the heads being merged are simple fast-forwards, it acts the
same way as the current 'git resolve'.  Otherwise, it tries
different merge strategies and takes the result from the one that
succeeded auto-merging, if there is any.

If no merge strategy succeeds auto-merging, their results are
evaluated for number of paths needed for hand resolving, and the
one with the least number of such paths is left in the working
tree.  The user is asked to resolve them by hand and make a
commit manually.

The calling convention from the 'git merge' driver to merge
strategy programs is very simple:

 - A strategy program is to be called 'git-merge-<strategy>'.

 - They take input of this form:

	<common1> <common2> ... '--' <head> <remote1> <remote2>...

   That is, one or more the common ancestors, double dash, the
   current head, and one or more remote heads being merged into
   the current branch.

 - Before a strategy program is called, the working tree is
   matched to the current <head>.

 - The strategy program exits with status code 0 when it
   successfully auto-merges the given heads.  It should do
   update-cache for all the merged paths when it does so -- the
   index file will be used to record the merge result as a
   commit by the driver.

 - The strategy program exits with status code 1 when it leaves
   conflicts behind.  It should do update-cache for all the
   merged paths that it successfully auto-merged, and leave the
   cache entry in the index file as the same as <head> for paths
   it could not auto-merge, and leave its best-effort result
   with conflict markers in the working tree when it does so.

 - The strategy program exists with status code other than 0 or
   1 if it does not handle the given merge at all.

As examples, this commit comes with merge strategies based on
'git resolve' and 'git octopus'.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-10 18:30:41 -07:00