1
0
mirror of https://github.com/git/git.git synced 2024-10-03 16:22:22 +02:00
Commit Graph

1017 Commits

Author SHA1 Message Date
Junio C Hamano
c30e699fc5 tests: propagate $(TAR) down from the toplevel Makefile
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-25 11:09:48 -07:00
Junio C Hamano
d0594be162 Makefile: update check-docs target
Earlier series to rename documentation pages around did not update this
target and left check-docs broken.  This should fix it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-15 13:43:32 -07:00
Johan Herland
8da1e21231 Consistency: Use "libcurl" instead of "cURL library" and "curl"
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-15 13:35:10 -07:00
Boyd Lynn Gerber
457bb45291 Port to 12 other Platforms.
This patch adds support to compile and run git on 12 additional platforms.
The platforms are based on UNIX Systems Labs (USL)/Novell/SYS V code base.
The most common are Novell UnixWare 2.X.X, SCO UnixWare 7.X.X,
OpenServer 5.0.X, OpenServer 6.0.X, and SCO pre OSR 5 platforms.

Looking at the the various platform headers, I find:

	#if defined(_KERNEL) || !defined(_POSIX_SOURCE) \
	     && !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)

which hides u_short and other typedefs that other header files on these
platforms depend on.  WIth _XOPEN_SOURCE defined, sources that include
system header files that depend on the typedefs such as u_short cannot be
compiled on these platforms.

__USLC__ indicates UNIX System Labs Corperation (USLC), or a Novell-derived
compiler and/or some SysV based OS's.

__M_UNIX indicates XENIX/SCO UNIX/OpenServer 5.0.7 and prior releases
of the SCO OS's.  It is used just like Apple and BSD, both of these
shouldn't have _XOPEN_SOURCE defined.

This is with suggestions and modifications from

Daniel Barkalow, Junio C Hamano, Thomas Harning, and Jeremy Maitin-Shepard.

Signed-off-by: Boyd Lynn Gerber <gerberb@zenez.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-06-08 14:27:46 -07:00
Junio C Hamano
3beb56bde6 Merge branch 'jc/diff-no-no-index'
* jc/diff-no-no-index:
  git diff --no-index: default to page like other diff frontends
  git-diff: allow  --no-index semantics a bit more
  "git diff": do not ignore index without --no-index
  diff-files: do not play --no-index games
  tests: do not use implicit "git diff --no-index"
2008-05-26 22:38:19 -07:00
Junio C Hamano
d3d20b8468 Makefile: fix dependency on wt-status.h
Noticed by Hannes, reported by Dscho.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-26 14:56:19 -07:00
Junio C Hamano
b84c343c88 Merge branch 'db/clone-in-c'
* db/clone-in-c:
  Add test for cloning with "--reference" repo being a subset of source repo
  Add a test for another combination of --reference
  Test that --reference actually suppresses fetching referenced objects
  clone: fall back to copying if hardlinking fails
  builtin-clone.c: Need to closedir() in copy_or_link_directory()
  builtin-clone: fix initial checkout
  Build in clone
  Provide API access to init_db()
  Add a function to set a non-default work tree
  Allow for having for_each_ref() list extra refs
  Have a constant extern refspec for "--tags"
  Add a library function to add an alternate to the alternates file
  Add a lockfile function to append to a file
  Mark the list of refs to fetch as const

Conflicts:

	cache.h
	t/t5700-clone-reference.sh
2008-05-25 13:41:37 -07:00
Junio C Hamano
0569e9b8ce "git diff": do not ignore index without --no-index
Even if "foo" and/or "bar" does not exist in index, "git diff foo bar"
should not change behaviour drastically from "git diff foo bar baz" or
"git diff foo".  A feature that "sometimes works and is handy" is an
unreliable cute hack.

"git diff foo bar" outside a git repository continues to work as a more
colourful alternative to "diff -u" as before.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-24 00:16:39 -07:00
Junio C Hamano
c748152612 Merge branch 'as/graph'
* as/graph:
  graph API: eliminate unnecessary indentation
  log and rev-list: add --graph option
  Add history graph API
  revision API: split parent rewriting and parent printing options
2008-05-21 14:05:02 -07:00
Mike Ralphson
377d9c409f Makefile: update the default build options for AIX
NO_MKDTEMP is required to build, FREAD_READS_DIRECTORIES and the definition
of _LARGE_FILES fix test suite failures and INTERNAL_QSORT is required for
adequate performance.

Tested on AIX v5.3 Maintenance Level 06

Signed-off-by: Mike Ralphson <mike@abacus.co.uk>
Tested-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-17 02:39:30 -07:00
Junio C Hamano
380a742679 Merge branch 'lt/case-insensitive'
* lt/case-insensitive:
  Make git-add behave more sensibly in a case-insensitive environment
  When adding files to the index, add support for case-independent matches
  Make unpack-tree update removed files before any updated files
  Make branch merging aware of underlying case-insensitive filsystems
  Add 'core.ignorecase' option
  Make hash_name_lookup able to do case-independent lookups
  Make "index_name_exists()" return the cache_entry it found
  Move name hashing functions into a file of its own
  Make unpack_trees_options bit flags actual bitfields
2008-05-10 18:14:28 -07:00
Adam Simpkins
c12172d2ea Add history graph API
This new API allows the commit history to be displayed as a text-based
graphical representation.

Signed-off-by: Adam Simpkins <adam@adamsimpkins.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-05 17:56:36 -07:00
Daniel Barkalow
8434c2f1af Build in clone
Thanks to Johannes Schindelin for various comments and improvements,
including supporting cloning full bundles.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-04 17:41:45 -07:00
Junio C Hamano
628522ec14 sha1-lookup: more memory efficient search in sorted list of SHA-1
Currently, when looking for a packed object from the pack idx, a
simple binary search is used.

A conventional binary search loop looks like this:

        unsigned lo, hi;
        do {
                unsigned mi = (lo + hi) / 2;
                int cmp = "entry pointed at by mi" minus "target";
                if (!cmp)
                        return mi; "mi is the wanted one"
                if (cmp > 0)
                        hi = mi; "mi is larger than target"
                else
                        lo = mi+1; "mi is smaller than target"
        } while (lo < hi);
	"did not find what we wanted"

The invariants are:

  - When entering the loop, 'lo' points at a slot that is never
    above the target (it could be at the target), 'hi' points at
    a slot that is guaranteed to be above the target (it can
    never be at the target).

  - We find a point 'mi' between 'lo' and 'hi' ('mi' could be
    the same as 'lo', but never can be as high as 'hi'), and
    check if 'mi' hits the target.  There are three cases:

     - if it is a hit, we have found what we are looking for;

     - if it is strictly higher than the target, we set it to
       'hi', and repeat the search.

     - if it is strictly lower than the target, we update 'lo'
       to one slot after it, because we allow 'lo' to be at the
       target and 'mi' is known to be below the target.

    If the loop exits, there is no matching entry.

When choosing 'mi', we do not have to take the "middle" but
anywhere in between 'lo' and 'hi', as long as lo <= mi < hi is
satisfied.  When we somehow know that the distance between the
target and 'lo' is much shorter than the target and 'hi', we
could pick 'mi' that is much closer to 'lo' than (hi+lo)/2,
which a conventional binary search would pick.

This patch takes advantage of the fact that the SHA-1 is a good
hash function, and as long as there are enough entries in the
table, we can expect uniform distribution.  An entry that begins
with for example "deadbeef..." is much likely to appear much
later than in the midway of a reasonably populated table.  In
fact, it can be expected to be near 87% (222/256) from the top
of the table.

This is a work-in-progress and has switches to allow easier
experiments and debugging.  Exporting GIT_USE_LOOKUP environment
variable enables this code.

On my admittedly memory starved machine, with a partial KDE
repository (3.0G pack with 95M idx):

    $ GIT_USE_LOOKUP=t git log -800 --stat HEAD >/dev/null
    3.93user 0.16system 0:04.09elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+55588minor)pagefaults 0swaps

Without the patch, the numbers are:

    $ git log -800 --stat HEAD >/dev/null
    4.00user 0.15system 0:04.17elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+60258minor)pagefaults 0swaps

In the same repository:

    $ GIT_USE_LOOKUP=t git log -2000 HEAD >/dev/null
    0.12user 0.00system 0:00.12elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+4241minor)pagefaults 0swaps

Without the patch, the numbers are:

    $ git log -2000 HEAD >/dev/null
    0.05user 0.01system 0:00.07elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
    0inputs+0outputs (0major+8506minor)pagefaults 0swaps

There isn't much time difference, but the number of minor faults
seems to show that we are touching much smaller number of pages,
which is expected.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:23:52 -07:00
Linus Torvalds
96872bc200 Move name hashing functions into a file of its own
It's really totally separate functionality, and if we want to start
doing case-insensitive hash lookups, I'd rather do it when it's
separated out.

It also renames "remove_index_entry()" to "remove_name_hash()", because
that really describes the thing better. It doesn't actually remove the
index entry, that's done by "remove_index_entry_at()", which is something
very different, despite the similarity in names.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-09 01:22:25 -07:00
Gerrit Pape
26ffcb7690 gitweb: fallback to system-wide config file (fixup)
The earlier one did not correctly propagate GITWEB_CONFIG_SYSTEM from
Makefile to generated gitweb.cgi script.

Signed-off-by: Gerrit Pape <pape@smarden.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-05 12:03:01 -07:00
Gerrit Pape
17a8b25005 gitweb: fallback to system-wide config file if default config does not exist
From a distribution point of view, configuration files for applications
should reside in /etc/.  On the other hand it's convenient for multiple
instances of gitweb (e.g. virtual web servers on a single machine) to have
a per-instance configuration file, just as gitweb currently supports
through the file gitweb_config.perl next to the cgi.

To support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as
a system-wide configuration file which will be used as a fallback if the
config file sprecified throug GITWEB_CONFIG does not exist.

See also
 http://bugs.debian.org/450592

Signed-off-by: Gerrit Pape <pape@smarden.org>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-27 13:55:10 -07:00
Junio C Hamano
deda26b993 Merge branch 'jc/makefile'
* jc/makefile:
  Makefile: flatten enumeration of headers, objects and programs
  Makefile: DIFF_OBJS is not special at all these days
2008-03-17 00:52:19 -07:00
Jeff King
4bf9f27dfb filter-branch: use $SHELL_PATH instead of 'sh'
On some systems, 'sh' isn't very friendly. In particular,
t7003 fails on Solaris because it doesn't understand $().
Instead, use the specified SHELL_PATH to run shell code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-13 00:57:53 -07:00
Jeff King
5f7c643afe add NO_EXTERNAL_GREP build option
Previously, we just chose whether to allow external grep
based on the __unix__ define. However, there are systems
which define this macro but which have an inferior group
(e.g., one that does not support all options used by t7002).
This allows users to accept the potential speed penalty to
get a more consistent grep experience (and to pass the
testsuite).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-13 00:57:53 -07:00
Junio C Hamano
74ca5e6d7c Makefile: flatten enumeration of headers, objects and programs
With flattened one-line-per-item list that is sorted, hopefully we will
have less merge conflicts when various topics are merged.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-12 01:55:48 -07:00
Junio C Hamano
bd92cd0f74 Makefile: DIFF_OBJS is not special at all these days
It used to make sense back when nothing but diff-files, diff-index and
friends depended on diffcore infrastructure, but pretty much everything
depends on revision infrastructure which in turn depends on DIFF_OBJS.

There is no reason to treat them any differently in the Makefile.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-12 01:55:46 -07:00
Junio C Hamano
ae90e16a3a Merge branch 'js/remote'
* js/remote:
  "remote update": print remote name being fetched from
  builtin remote rm: remove symbolic refs, too
  remote: fix "update [group...]"
  remote show: Clean up connection correctly if object fetch wasn't done
  builtin-remote: prune remotes correctly that were added with --mirror
  Make git-remote a builtin
  Test "git remote show" and "git remote prune"
  parseopt: add flag to stop on first non option
  path-list: add functions to work with unsorted lists

Conflicts:

	parse-options.c
2008-03-11 22:33:51 -07:00
Junio C Hamano
5d921e2931 Merge branch 'jc/cherry-pick' (early part)
* 'jc/cherry-pick' (early part):
  expose a helper function peel_to_type().
  merge-recursive: split low-level merge functions out.

Conflicts:

	Makefile
	builtin-merge-recursive.c
	sha1_name.c
2008-03-11 02:05:12 -07:00
Junio C Hamano
6e79a88585 Merge branch 'mr/compat-snprintf'
* mr/compat-snprintf:
  Add compat/snprintf.c for systems that return bogus
2008-03-08 21:29:50 -08:00
Michal Rokos
c4582f93a2 Add compat/snprintf.c for systems that return bogus
Some systems (namely HPUX and Windows) return -1 when maxsize in snprintf()
and in vsnprintf() is reached. So replace snprintf() and vsnprintf()
functions with our own ones that return correct value upon overflow.

[jc: verified that review comments by J6t have been incorporated, and
 tightened the check to verify the resulting buffer contents, suggested
 by Wayne Davison]

Signed-off-by: Michal Rokos <michal.rokos@nextsoft.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-05 13:12:07 -08:00
Alex Riesen
81a24b52c1 Do not use GUID on dir in git init --shared=all on FreeBSD
It does not allow changing the bit to a non-root user.
This fixes t1301-shared-repo.sh on the platform.

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-05 12:22:26 -08:00
Junio C Hamano
c0b48ad777 Merge branch 'np/verify-pack'
* np/verify-pack:
  add storage size output to 'git verify-pack -v'
  fix unimplemented packed_object_info_detail() features
  make verify_one_pack() a bit less wrong wrt packed_git structure
  factorize revindex code out of builtin-pack-objects.c

Conflicts:

	Makefile
2008-03-02 16:07:30 -08:00
Junio C Hamano
eadbcd498a Merge branch 'mk/maint-parse-careful'
* mk/maint-parse-careful:
  receive-pack: use strict mode for unpacking objects
  index-pack: introduce checking mode
  unpack-objects: prevent writing of inconsistent objects
  unpack-object: cache for non written objects
  add common fsck error printing function
  builtin-fsck: move common object checking code to fsck.c
  builtin-fsck: reports missing parent commits
  Remove unused object-ref code
  builtin-fsck: move away from object-refs to fsck_walk
  add generic, type aware object chain walker

Conflicts:

	Makefile
	builtin-fsck.c
2008-03-02 15:11:07 -08:00
Johannes Schindelin
211c89682e Make git-remote a builtin
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-01 01:51:44 -08:00
Nicolas Pitre
3449f8c4cb factorize revindex code out of builtin-pack-objects.c
No functional change. This is needed to fix verify-pack in a later patch.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-01 01:44:45 -08:00
Jeff King
7cf7f54a65 use build-time SHELL_PATH in test scripts
The top-level Makefile now creates a GIT-BUILD-OPTIONS file
which stores any options selected by the make process that
may be of use to further parts of the build process.
Specifically, we store the SHELL_PATH so that it can be used
by tests to construct shell scripts on the fly.

The format of the GIT-BUILD-OPTIONS file is Bourne shell,
and it is sourced by test-lib.sh; all tests can rely on just
having $SHELL_PATH correctly set in the environment.

The GIT-BUILD-OPTIONS file is written every time the
toplevel 'make' is invoked. Since the only users right now
are the test scripts, there's no drawback to updating its
timestamp. If something build-related depends on this, we
can do a trick similar to the one used by GIT-CFLAGS.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-29 00:00:29 -08:00
Junio C Hamano
5a4d707a6d Merge branch 'db/checkout'
* db/checkout: (21 commits)
  checkout: error out when index is unmerged even with -m
  checkout: show progress when checkout takes long time while switching branches
  Add merge-subtree back
  checkout: updates to tracking report
  builtin-checkout.c: Remove unused prefix arguments in switch_branches path
  checkout: work from a subdirectory
  checkout: tone down the "forked status" diagnostic messages
  Clean up reporting differences on branch switch
  builtin-checkout.c: fix possible usage segfault
  checkout: notice when the switched branch is behind or forked
  Build in checkout
  Move code to clean up after a branch change to branch.c
  Library function to check for unmerged index entries
  Use diff -u instead of diff in t7201
  Move create_branch into a library file
  Build-in merge-recursive
  Add "skip_unmerged" option to unpack_trees.
  Discard "deleted" cache entries after using them to update the working tree
  Send unpack-trees debugging output to stderr
  Add flag to make unpack_trees() not print errors.
  ...

Conflicts:

	Makefile
2008-02-27 12:53:26 -08:00
Junio C Hamano
d87aa32935 Merge branch 'jk/help-alias'
* jk/help-alias:
  help: respect aliases
  make alias lookup a public, procedural function
  help: use parseopt
2008-02-27 11:55:43 -08:00
Junio C Hamano
3c972e1ec4 Merge branch 'ae/pack-autothread'
* ae/pack-autothread:
  Revert "pack-objects: Print a message describing the number of threads for packing"
  pack-objects: Print a message describing the number of threads for packing
  pack-objects: Add runtime detection of online CPU's
2008-02-27 11:54:03 -08:00
Martin Koegler
7914053ba9 Remove unused object-ref code
Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-25 23:57:35 -08:00
Martin Koegler
355885d531 add generic, type aware object chain walker
The requirements are:
* it may not crash on NULL pointers
* a callback function is needed, as index-pack/unpack-objects
  need to do different things
* the type information is needed to check the expected <-> real type
  and print better error messages

Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-25 23:57:34 -08:00
Jeff King
94351118c0 make alias lookup a public, procedural function
This converts git_config_alias to the public alias_lookup
function. Because of the nature of our config parser, we
still have to rely on setting static data. However, that
interface is wrapped so that you can just say

  value = alias_lookup(key);

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-24 18:31:49 -08:00
Junio C Hamano
dc31cd8fcc Merge branch 'maint'
* maint:
  Protect peel_ref fallback case from NULL parse_object result
  Ensure 'make dist' compiles git-archive.exe on Cygwin
2008-02-24 10:01:19 -08:00
Shawn O. Pearce
6c0f86943e Ensure 'make dist' compiles git-archive.exe on Cygwin
On Cygwin we have to use git-archive.exe as the target, otherwise
running 'make dist' does not compile git-archive in the current
directory.  That may cause 'make dist' to fail on a clean source
tree that has never been built before.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-24 00:51:01 -08:00
Andreas Ericsson
833e3df171 pack-objects: Add runtime detection of online CPU's
Packing objects can be done in parallell nowadays, but it's
only done if the config option pack.threads is set to a value
above 1. Because of that, the code-path used is often not the
most optimal one.

This patch adds a routine to detect the number of online CPU's
at runtime (online_cpus()). When pack.threads (or --threads=) is
given a value of 0, the number of threads is set to the number of
online CPU's. This feature is also documented.

As per Nicolas Pitre's recommendations, the default is still to
run pack-objects single-threaded unless explicitly activated,
either by configuration or by command line parameter.

The routine online_cpus() is a rework of "numcpus.c", written by
one Philip Willoughby <pgw99@doc.ic.ac.uk>. numcpus.c is in the
public domain and can presently be downloaded from
http://csgsoft.doc.ic.ac.uk/numcpus/

Signed-off-by: Andreas Ericsson <ae@op5.se>
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-23 12:00:32 -08:00
Junio C Hamano
1736855c9b Add merge-subtree back
An earlier commit e1b3a2c (Build-in merge-recursive) made the
subtree merge strategy backend unavailable.  This resurrects
it.

A new test t6029 currently only tests the strategy is available,
but it should be enhanced to check the real "subtree" case.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-23 11:14:56 -08:00
Junio C Hamano
c0284cea31 Merge branch 'bc/fopen'
* bc/fopen:
  Add compat/fopen.c which returns NULL on attempt to open directory
2008-02-20 16:13:19 -08:00
Junio C Hamano
525ab63950 merge-recursive: split low-level merge functions out.
This moves low-level merge functions out of merge-recursive.c and
places them in a new separate file, ll-merge.c

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-18 00:46:13 -08:00
Junio C Hamano
f8732c5596 Merge branch 'bd/qsort'
* bd/qsort:
  compat: Add simplified merge sort implementation from glibc
2008-02-16 18:11:47 -08:00
Daniel Barkalow
782c2d65c2 Build in checkout
The only differences in behavior should be:

 - git checkout -m with non-trivial merging won't print out
   merge-recursive messages (see the change in t7201-co.sh)

 - git checkout -- paths... will give a sensible error message if
   HEAD is invalid as a commit.

 - some intermediate states which were written to disk in the shell
   version (in particular, index states) are only kept in memory in
   this version, and therefore these can no longer be revealed by
   later write operations becoming impossible.

 - when we change branches, we discard MERGE_MSG, SQUASH_MSG, and
   rr-cache/MERGE_RR, like reset always has.

I'm not 100% sure I got the merge recursive setup exactly right; the
base for a non-trivial merge in the shell code doesn't seem
theoretically justified to me, but I tried to match it anyway, and the
tests all pass this way.

Other than these items, the results should be identical to the shell
version, so far as I can tell.

[jc: squashed lock-file fix from Dscho in]

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-16 15:05:02 -08:00
Brandon Casey
cba22528fa Add compat/fopen.c which returns NULL on attempt to open directory
Some systems do not fail as expected when fread et al. are called on
a directory stream. Replace fopen on such systems which will fail
when the supplied path is a directory.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-11 18:25:10 -08:00
Daniel Barkalow
e496c00348 Move create_branch into a library file
You can also create branches, in exactly the same way, with checkout -b.

This introduces branch.{c,h} library files for doing porcelain-level
operations on branches (such as creating them with their appropriate
default configuration).

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
2008-02-09 23:16:51 -08:00
Daniel Barkalow
e1b3a2cad7 Build-in merge-recursive
This makes write_tree_from_memory(), which writes the active cache as
a tree and returns the struct tree for it, available to other code. It
also makes available merge_trees(), which does the internal merge of
two trees with a known base, and merge_recursive(), which does the
recursive internal merge of two commits with a list of common
ancestors.

The first two of these will be used by checkout -m, and the third is
presumably useful in general, although the implementation of checkout
-m which entirely matches the behavior of the shell version does not
use it (since it ignores the difference of ancestry between the old
branch and the new branch).

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
2008-02-09 23:16:51 -08:00
Brian Downing
43fe901b71 compat: Add simplified merge sort implementation from glibc
qsort in Windows 2000 (and various other C libraries) is a Quicksort
with the usual O(n^2) worst case.  Unfortunately, sorting Git trees
seems to get very close to that worst case quite often:

    $ /git/gitbad runstatus
    # On branch master
    qsort, nmemb = 30842
    done, 237838087 comparisons.

This patch adds a simplified version of the merge sort that is glibc's
qsort(3).  As a merge sort, this needs a temporary array equal in size
to the array that is to be sorted, but has a worst-case performance of
O(n log n).

The complexity that was removed is:

* Doing direct stores for word-size and -aligned data.
* Falling back to quicksort if the allocation required to perform the
  merge sort would likely push the machine into swap.

Even with these simplifications, this seems to outperform the Windows
qsort(3) implementation, even in Windows XP (where it is "fixed" and
doesn't trigger O(n^2) complexity on trees).

[jes: moved into compat/qsort.c, as per Johannes Sixt's suggestion]
[bcd: removed gcc-ism, thanks to Edgar Toernig.  renamed make variable
      per Junio's comment.]

Signed-off-by: Brian Downing <bdowning@lavos.net>
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-02-06 22:35:28 -08:00