Commit Graph

23 Commits

Author SHA1 Message Date
Rene Scharfe
c0fa8255c6 Fold get_merge_bases_clean() into get_merge_bases()
Change get_merge_bases() to be able to clean up after itself if
needed by adding a cleanup parameter.

We don't need to save the flags and restore them afterwards anymore;
that was a leftover from before the flags were moved out of the
range used in revision.c.  clear_commit_marks() sets them to zero,
which is enough.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-07-02 10:58:25 -07:00
Johannes Schindelin
7c6f8aaf6d move get_merge_bases() to core lib.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-29 13:50:46 -07:00
Johannes Schindelin
52cab8a084 refactor merge_bases() as preparation to libify merge-base
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-06-29 13:50:46 -07:00
Junio C Hamano
c82a22c39c merge-base: Clarify the comments on post processing.
The comment fooled myself believing that we still had an
unsolved horizon effect.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-16 17:18:22 -07:00
Dmitry V. Levin
31fff305bc Separate object name errors from usage errors
Separate object name errors from usage errors.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-08 16:25:33 -07:00
Junio C Hamano
84a9b58c42 sha1_name: warning ambiguous refs.
This makes sure that many commands that take refs on the command
line to honor core.warnambiguousrefs configuration.  Earlier,
the commands affected by this patch did not read the
configuration file.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-03-23 23:41:18 -08:00
Junio C Hamano
53228a5fb8 Make the rest of commands work from a subdirectory.
These commands are converted to run from a subdirectory.

    commit-tree convert-objects merge-base merge-index mktag
    pack-objects pack-redundant prune-packed read-tree tar-tree
    unpack-file unpack-objects update-server-info write-tree

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-28 23:13:02 -08:00
Junio C Hamano
9e5f4a5539 merge-base: avoid unnecessary postprocessing.
When we have only one merge-base candidates in the result list,
there is no point going back to mark the reachable commits
again.  And that is the most common case, so try not to waste
time on it.  Suggested by Linus.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-11 10:52:31 -08:00
Junio C Hamano
ed9a540b2b merge-base: fully contaminate the well.
The discussion on the list demonstrated a pathological case where
an ancestor of a merge-base can be left interesting.  This commit
introduces a postprocessing phase to fix it.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-11 10:52:30 -08:00
Junio C Hamano
9585e40622 Try to find the optimum merge base while resolving.
The merge-base command acquires a new option, '--all', that causes it
to output all the common ancestor candidates.  The "git resolve"
command then uses it to pick the optimum merge base by picking the one
that results in the smallest number of nontrivial merges.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-23 21:08:59 -07:00
Junio C Hamano
b4ad66b778 merge-base.c: pathological case fix.
Also add some illustration requested by Linus.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-11 18:26:13 -07:00
Linus Torvalds
0b9442d618 [PATCH] Speed up git-merge-base a lot
In commit 4f7eb2e5a3 I fixed git-merge-base
getting confused by datestamps that caused it to traverse things in a
non-obvious order.

However, my fix was a very brute-force one, and it had some really
horrible implications for more complex trees with lots of parallell
development. It might end up traversing all the way to the root commit.

Now, normally that isn't that horrible: it's used mainly for merging, and
the bad cases really tend to happen fairly rarely, so if it takes a few
seconds, we're not in too bad shape.

However, gitk will also do the git-merge-base for every merge it shows,
because it basically re-does the trivial merge in order to show the
"interesting" parts. And there we'd really like the result to be
instantaneous.

This patch does that by walking the tree more completely, and using the
same heuristic as git-rev-list to decide "ok, the rest is uninteresting".

In one - hopefully fairly extreme - case, it made a git-merge-base go from
just under five seconds(!) to a tenth of a second on my machine.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-08-11 18:26:12 -07:00
Linus Torvalds
4f7eb2e5a3 Fix merge-base from getting confused.
On Sat, 30 Jul 2005, Linus Torvalds wrote:
> 
> Yup, it's git-merge-base, and it is confused by the same thing that 
> confused git-rev-list.

Hmm.. Here's a tentative fix. I'm not really happy with it, and maybe
somebody else can come up with a better one. I think this one ends up
being quite a bit more expensive than the old one (it will look up _all_
common parents that have a child that isn't common, and then select the
newest one of the bunch), but I haven't really thought it through very
much.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-07-30 22:58:21 -07:00
Linus Torvalds
e99d59ff0b sparse cleanup
Fix various things that sparse complains about:
 - use NULL instead of 0
 - make sure we declare everything properly, or mark it static
 - use proper function declarations ("fn(void)" instead of "fn()")

Sparse is always right.
2005-05-20 11:46:10 -07:00
Alexey Nezhdanov
667bb59b2d [PATCH] cleanup of in-code names
Fixes all in-code names that leaved during "big name change".

Signed-off-by: Alexey Nezhdanov <snake@penza-gsm.ru>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-19 10:52:00 -07:00
Linus Torvalds
9b632be30c merge-base: use the new lookup_commit_reference() helper function
This allows you to use tags for merge bases.
2005-05-18 16:16:51 -07:00
Linus Torvalds
3c249c9506 Add "get_sha1()" helper function.
This allows the programs to use various simplified versions of
the SHA1 names, eg just say "HEAD" for the SHA1 pointed to by
the .git/HEAD file etc.

For example, this commit has been done with

	git-commit-tree $(git-write-tree) -p HEAD

instead of the traditional "$(cat .git/HEAD)" syntax.
2005-05-01 16:36:56 -07:00
Daniel Barkalow
58e28af6a4 [PATCH] Allow multiple date-ordered lists
Make pop_most_recent_commit() return the same objects multiple times, but only
if called with different bits to mark.

This is necessary to make merge-base work again.

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-23 20:29:22 -07:00
Daniel Barkalow
b6b15db3f4 [PATCH] Replace merge-base implementation
The old implementation was a nice algorithm, but, unfortunately, it could
be confused in some cases and would not necessarily do the obvious thing
if one argument was decended from the other. This version fixes that by
changing the criterion to the most recent common ancestor.

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-23 18:47:23 -07:00
Linus Torvalds
b51ad43140 Merge the new object model thing from Daniel Barkalow
This was a real git merge with conflicts. I'll commit the scripts I used
to do the merge next.

Not pretty, but it's half-way functional.
2005-04-18 12:12:00 -07:00
Daniel Barkalow
b5039db6d2 [PATCH] Switch implementations of merge-base, port to parsing
This switches to my implementation of merge-base, but with the new parsing
library.

Signed-Off-By: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-18 11:39:48 -07:00
Linus Torvalds
7d60ad7cc9 Make "parse_commit" return the "struct revision" for the commit.
Also, make it a fatal error to pass in a non-commit object. The callers
never checked, so better check here.

This simplifies merge-base further. It's now so trivial that it's almost
ridiculous.
2005-04-17 12:40:18 -07:00
Linus Torvalds
6683463ed6 Do a very simple "merge-base" that finds the most recent common
parent of two commits.

The question of "best" commit can probably be tweaked almost arbitrarily.
In particular, trying to take things like how big the tree differences
are into account migt be a good idea. This one is just very simple.
2005-04-17 12:18:17 -07:00