Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Mar 26, 2009
  1. Junio C Hamano

    Merge branch 'js/maint-1.6.0-exec-path-env'

    gitster authored
    * js/maint-1.6.0-exec-path-env:
      Propagate --exec-path setting to external commands via GIT_EXEC_PATH
Commits on Mar 22, 2009
  1. Junio C Hamano

    Propagate --exec-path setting to external commands via GIT_EXEC_PATH

    Johannes Sixt authored gitster committed
    Let PATH0=$PATH that was set before the invocation.
    Let /foo be a build directory.
    Let /pfx be the installation prefix.
    Let pfxexecpath=/pfx/libexec/git-core.
    
    The following is going on when 'git --exec-path=/foo gc' is invoked:
    
    1. git sets PATH=/foo:$PATH0 using the path from --exec-path
    
    2. gc execs 'git repack' (note: no dash).
    
    3. Since there is a git in /foo (it's a build directory), /foo/git is
       taken.
    
    4. No explicit exec-path is set this time, hence, this secondary git sets
       PATH=$pfxexecpath:/foo:$PATH
    
    5. Since 'repack' is not a built-in, execv_dashed_external execs
       'git-repack' (note: dash).
    
    6. There is a $pfxexecpath/git-repack, and it is taken.
    
    7. This git-repack runs 'git pack-objects' (note: no dash).
    
    8. There is no git in $pfxexecpath, but there is one in /foo. Hence,
       /foo/git is run.
    
    9. pack-objects is a builtin, hence, in effect /foo/git-pack-objects
       is run.
    
    As you can see, the way in which we previously set the PATH allowed to
    mix gits of different vintage.  By setting GIT_EXEC_PATH when --exec-path
    was given on the command line, we reduce the confusion.
    
    Signed-off-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 20, 2009
  1. dscho Junio C Hamano

    system_path(): simplify using strip_path_suffix(), and add suffix "git"

    dscho authored gitster committed
    At least for the author of this patch, the logic in system_path() was
    too hard to understand.  Using the function strip_path_suffix() documents
    the idea of the code better.
    
    The real change is to add the suffix "git", so that a runtime prefix will
    be computed correctly even when the executable was called in /git/ as is
    the case in msysGit (Windows insists to search the current directory
    before the PATH when looking for an executable).
    
    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    Acked-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jan 26, 2009
  1. sprohaska Junio C Hamano

    Compute prefix at runtime if RUNTIME_PREFIX is set

    sprohaska authored gitster committed
    This commit adds support for relocatable binaries (called
    RUNTIME_PREFIX).  Such binaries can be moved together with the
    system configuration files to a different directory, as long as the
    relative paths from the binary to the configuration files is
    preserved.  This functionality is essential on Windows where we
    deliver git binaries with an installer that allows to freely choose
    the installation location.
    
    If RUNTIME_PREFIX is unset we use the static prefix.  This will be
    the default on Unix.  Thus, the behavior on Unix will remain
    identical to the old implementation, which used to add the prefix
    in the Makefile.
    
    If RUNTIME_PREFIX is set the prefix is computed from the location
    of the executable.  In this case, system_path() tries to strip
    known directories that executables can be located in from the path
    of the executable.  If the path is successfully stripped it is used
    as the prefix.  For example, if the executable is
    "/msysgit/bin/git" and BINDIR is "bin", then the prefix computed is
    "/msysgit".
    
    If the runtime prefix computation fails, we fall back to the static
    prefix specified in the makefile.  This can be the case if the
    executable is not installed at a known location.  Note that our
    test system sets GIT_CONFIG_NOSYSTEM to tell git to ignore global
    configuration files during testing.  Hence testing does not trigger
    the fall back.
    
    Note that RUNTIME_PREFIX only works on Windows, though adding
    support on Unix should not be too hard.  The implementation
    requires argv0_path to be set to an absolute path.  argv0_path must
    point to the directory of the executable.  We use assert() to
    verify this in debug builds.  On Windows, the wrapper for main()
    (see compat/mingw.h) guarantees that argv0_path is correctly
    initialized.  On Unix, further work is required before
    RUNTIME_PREFIX can be enabled.
    
    Signed-off-by: Steffen Prohaska <prohaska@zib.de>
    Acked-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. sprohaska Junio C Hamano

    Modify setup_path() to only add git_exec_path() to PATH

    sprohaska authored gitster committed
    Searching git programs only in the highest priority location is
    sufficient.  It does not make sense that some of the required
    programs are located at the highest priority location but other
    programs are picked up from a lower priority exec-path.  If
    exec-path is overridden a complete set of commands should be
    provided, otherwise several different versions could get mixed,
    which is likely to cause confusion.
    
    If a user explicitly overrides the default location (by --exec-path
    or GIT_EXEC_PATH), we now expect that all the required programs are
    found there.  Instead of adding the directories "argv_exec_path",
    "getenv(EXEC_PATH_ENVIRONMENT)", and "system_path(GIT_EXEC_PATH)"
    to PATH, we now rely on git_exec_path(), which implements the same
    order, but only returns the highest priority location to search for
    executables.
    
    Accessing only the location with highest priority is also required
    for testing executables built with RUNTIME_PREFIX.  The call to
    system_path() should be avoided if RUNTIME_PREFIX is set and the
    executable is not installed at its final destination.  Because we
    test before installing, we want to avoid calling system_path()
    during tests.  The modifications in this commit avoid calling
    system_path(GIT_EXEC_PATH) if a higher-priority location is
    provided, which is the case when running the tests.
    
    Signed-off-by: Steffen Prohaska <prohaska@zib.de>
    Acked-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. sprohaska Junio C Hamano

    git_extract_argv0_path(): Move check for valid argv0 from caller to c…

    sprohaska authored gitster committed
    …allee
    
    This simplifies the calling code.
    
    Signed-off-by: Steffen Prohaska <prohaska@zib.de>
    Acked-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. Junio C Hamano

    Refactor git_set_argv0_path() to git_extract_argv0_path()

    Steve Haslam authored gitster committed
    This commit moves the code that computes the dirname of argv[0]
    from git.c's main() to git_set_argv0_path() and renames the function
    to git_extract_argv0_path().  This makes the code in git.c's main
    less cluttered, and we can use the dirname computation from other
    main() functions too.
    
    [ spr:
     - split Steve's original commit and wrote new commit message.
     - Integrated Johannes Schindelin's
       cca1704 while rebasing onto master.
    ]
    
    Signed-off-by: Steve Haslam <shaslam@lastminute.com>
    Signed-off-by: Steffen Prohaska <prohaska@zib.de>
    Acked-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  5. sprohaska Junio C Hamano

    Move computation of absolute paths from Makefile to runtime (in prepa…

    sprohaska authored gitster committed
    …ration for RUNTIME_PREFIX)
    
    This commit prepares the Makefile for relocatable binaries (called
    RUNTIME_PREFIX).  Such binaries will be able to be moved together
    with the system configuration files to a different directory,
    requiring to compute the prefix at runtime.
    
    In a first step, we make all paths relative in the Makefile and
    teach system_path() to add the prefix instead.  We used to compute
    absolute paths in the Makefile and passed them to C as defines.  We
    now pass relative paths to C and call system_path() to add the
    prefix at runtime.
    
    Signed-off-by: Steffen Prohaska <prohaska@zib.de>
    Acked-by: Johannes Sixt <j6t@kdbg.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 12, 2008
  1. Shawn O. Pearce

    Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializer

    Brandon Casey authored spearce committed
    Many call sites use strbuf_init(&foo, 0) to initialize local
    strbuf variable "foo" which has not been accessed since its
    declaration. These can be replaced with a static initialization
    using the STRBUF_INIT macro which is just as readable, saves a
    function call, and takes up fewer lines.
    
    Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
    Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Commits on Jul 29, 2008
  1. sprohaska Junio C Hamano

    Refactor, adding prepare_git_cmd(const char **argv)

    sprohaska authored gitster committed
    prepare_git_cmd(const char **argv) adds a first entry "git" to
    the array argv.  The new array is allocated on the heap.  It's
    the caller's responsibility to release it with free().  The code
    was already present in execv_git_cmd() but could not be used from
    outside.  Now it can also be called for preparing the command list
    in the MinGW codepath in run-command.c.
    
    Signed-off-by: Steffen Prohaska <prohaska@zib.de>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 26, 2008
  1. Junio C Hamano

    Allow add_path() to add non-existent directories to the path

    Johannes Sixt authored gitster committed
    This function had used make_absolute_path(); but this function dies if
    the directory that contains the entry whose relative path was supplied in
    the argument does not exist. This is a problem if the argument is, for
    example, "../libexec/git-core", and that "../libexec" does not exist.
    
    Since the resolution of symbolic links is not required for elements in
    PATH, we can fall back to using make_nonrelative_path(), which simply
    prepends $PWD to the path.
    
    We have to move make_nonrelative_path() alongside make_absolute_path() in
    abspath.c so that git-shell can be linked. See 5b8e6f8.
    
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. Junio C Hamano

    Allow the built-in exec path to be relative to the command invocation…

    Johannes Sixt authored gitster committed
    … path
    
    If GIT_EXEC_PATH (the macro that is defined in the Makefile) is relative,
    it is interpreted relative to the command's invocation path, which usually
    is $(bindir).
    
    The Makefile rules were written with the assumption that $(gitexecdir) is
    an absolute path. We introduce a separate variable that names the
    (absolute) installation directory.
    
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  3. Junio C Hamano

    Fix relative built-in paths to be relative to the command invocation

    Johannes Sixt authored gitster committed
    $(gitexecdir) (as defined in the Makefile) has gained another path
    component, but the relative paths in the MINGW section of the Makefile,
    which are interpreted relative to it, do not account for it.
    
    Instead of adding another ../ in front of the path, we change the code that
    constructs the absolute paths to do it relative to the command's directory,
    which is essentially $(bindir). We do it this way because we will also
    allow a relative $(gitexecdir) later.
    
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  4. Junio C Hamano

    Record the command invocation path early

    Johannes Sixt authored gitster committed
    We will need the command invocation path in system_path(). This path was
    passed to setup_path(), but  system_path() can be called earlier, for
    example via:
    
        main
          commit_pager_choice
            setup_pager
              git_config
                git_etc_gitconfig
                  system_path
    
    Therefore, we introduce git_set_argv0_path() and call it as soon as
    possible.
    
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 13, 2008
  1. sprohaska Junio C Hamano

    Move code interpreting path relative to exec-dir to new function syst…

    sprohaska authored gitster committed
    …em_path()
    
    Expanding system paths relative to git_exec_path can be used for
    creating an installation that can be moved to a different directory
    without re-compiling.  We use this approach for template_dir and the
    system wide gitconfig.  The Windows installer (msysgit) is an example
    for such a setup.
    
    This commit moves common code to a new function system_path().  System
    paths that are to be interpreted relative to git_exec_path are passed to
    system_path() and the return value is used instead of the original path.
    system_path() prefixes a relative path with git_exec_path and leaves
    absolute paths unmodified.  For example, we now write
    
        template_dir = system_path(DEFAULT_GIT_TEMPLATE_DIR);
    
    [j6t: moved from path.c to exec_cmd.c]
    
    Signed-off-by: Steffen Prohaska <prohaska@zib.de>
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jul 3, 2008
  1. Junio C Hamano

    Merge branch 'j6t/mingw'

    gitster authored
    * j6t/mingw: (38 commits)
      compat/pread.c: Add a forward declaration to fix a warning
      Windows: Fix ntohl() related warnings about printf formatting
      Windows: TMP and TEMP environment variables specify a temporary directory.
      Windows: Make 'git help -a' work.
      Windows: Work around an oddity when a pipe with no reader is written to.
      Windows: Make the pager work.
      When installing, be prepared that template_dir may be relative.
      Windows: Use a relative default template_dir and ETC_GITCONFIG
      Windows: Compute the fallback for exec_path from the program invocation.
      Turn builtin_exec_path into a function.
      Windows: Use a customized struct stat that also has the st_blocks member.
      Windows: Add a custom implementation for utime().
      Windows: Add a new lstat and fstat implementation based on Win32 API.
      Windows: Implement a custom spawnve().
      Windows: Implement wrappers for gethostbyname(), socket(), and connect().
      Windows: Work around incompatible sort and find.
      Windows: Implement asynchronous functions as threads.
      Windows: Disambiguate DOS style paths from SSH URLs.
      Windows: A rudimentary poll() emulation.
      Windows: Implement start_command().
      ...
Commits on Jun 26, 2008
  1. Windows: Compute the fallback for exec_path from the program invocation.

    Johannes Sixt authored
    Since on Windows the user is fairly free where to install programs, we
    cannot rely on a hard-coded path. We use the program name to derive the
    installation directory and use that as exec_path.
    
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
  2. Turn builtin_exec_path into a function.

    Johannes Sixt authored
    builtin_exec_path returns the hard-coded installation path, which is used
    as the ultimate fallback to look for git commands. Making it into a function
    enables us in a follow-up patch to return a computed value instead of just
    a constant string.
    
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Commits on Jun 24, 2008
  1. Junio C Hamano

    Prepare execv_git_cmd() for removal of builtins from the filesystem

    gitster authored
    Currently, execv_git_cmd() always try running the dashed form, which
    means we cannot easily remove the git-foo hardlinks for built-in
    commands.  This updates the function to always exec "git foo" form, and
    makes sure "git" potty does not infinitely recurse to itself.
    
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Jun 22, 2008
  1. Windows: Use the Windows style PATH separator ';'.

    Johannes Sixt authored
    Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Commits on Dec 4, 2007
  1. Christian Couder Junio C Hamano

    Trace and quote with argv: get rid of unneeded count argument.

    chriscool authored gitster committed
    Now that str_buf takes care of all the allocations, there is
    no more gain to pass an argument count.
    
    So this patch removes the "count" argument from:
    	- "sq_quote_argv"
    	- "trace_argv_printf"
    and all the callers.
    
    Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Oct 30, 2007
  1. Scott R. Parish Junio C Hamano

    use only the $PATH for exec'ing git commands

    srp authored gitster committed
    We need to correctly set up $PATH for non-c based git commands.
    Since we already do this, we can just use that $PATH and execvp,
    instead of looping over the paths with execve.
    
    This patch adds a setup_path() function to exec_cmd.c, which sets
    the $PATH order correctly for our search order. execv_git_cmd() is
    stripped down to setting up argv and calling execvp(). git.c's
    main() only only needs to call setup_path().
    
    Signed-off-by: Scott R Parish <srp@srparish.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
  2. Scott R. Parish Junio C Hamano

    "current_exec_path" is a misleading name, use "argv_exec_path"

    srp authored gitster committed
    Signed-off-by: Scott R Parish <srp@srparish.net>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
Commits on Feb 21, 2007
  1. Mechanical conversion to use prefixcmp()

    Junio C Hamano authored
    This mechanically converts strncmp() to use prefixcmp(), but only when
    the parameters match specific patterns, so that they can be verified
    easily.  Leftover from this will be fixed in a separate step, including
    idiotic conversions like
    
        if (!strncmp("foo", arg, 3))
    
      =>
    
        if (!(-prefixcmp(arg, "foo")))
    
    This was done by using this script in px.perl
    
       #!/usr/bin/perl -i.bak -p
       if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) {
               s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|;
       }
       if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) {
               s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|;
       }
    
    and running:
    
       $ git grep -l strncmp -- '*.c' | xargs perl px.perl
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Dec 19, 2006
  1. Use preprocessor constants for environment variable names.

    Junio C Hamano authored
    We broke the discipline Linus set up to allow compiler help us
    avoid typos in environment names in the early days of git over
    time.  This defines a handful preprocessor constants for
    environment variable names used in relatively core parts of the
    system.
    
    I've left out variable names specific to subsystems such as HTTP
    and SSL as I do not think they are big problems.
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Aug 31, 2006
  1. Christian Couder

    Trace into open fd and refactor tracing code.

    chriscool authored Junio C Hamano committed
    Now if GIT_TRACE is set to an integer value greater than 1
    and lower than 10, we interpret this as an open fd value
    and we trace into it. Note that this behavior is not
    compatible with the previous one.
    
    We also trace whole messages using one write(2) call to
    make sure messages from processes do net get mixed up in
    the middle.
    
    It's now possible to run the tests like this:
    
    	GIT_TRACE=9 make test 9>/var/tmp/trace.log
    
    Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Aug 16, 2006
  1. remove unnecessary initializations

    David Rientjes authored Junio C Hamano committed
    [jc: I needed to hand merge the changes to the updated codebase,
     so the result needs to be checked.]
    
    Signed-off-by: David Rientjes <rientjes@google.com>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Jul 9, 2006
  1. tihirvon

    GIT_TRACE: fix a mixed declarations and code warning

    tihirvon authored Junio C Hamano committed
    Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
  2. Matthias Lederhofer

    GIT_TRACE: show which built-in/external commands are executed

    matled authored Junio C Hamano committed
    With the environment variable GIT_TRACE set git will show
     - alias expansion
     - built-in command execution
     - external command execution
    on stderr.
    
    Signed-off-by: Matthias Lederhofer <matled@gmx.net>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on May 31, 2006
  1. git_exec_path, execv_git_cmd: ignore empty environment variables

    Dmitry V. Levin authored Junio C Hamano committed
    Ignoring empty environment variables is good common practice.
    Ignoring --exec-path with empty argument won't harm, too:
    if user means current directory, there is a "--exec-path=."
    
    Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
  2. execv_git_cmd: Fix stack buffer overflow.

    Dmitry V. Levin authored Junio C Hamano committed
    Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Apr 17, 2006
  1. cleanups: remove unused variable from exec_cmd.c

    Serge E. Hallyn authored Junio C Hamano committed
    Not sure whether it should be removed, or whether
    execv_git_cmd() should return it rather than -1 at bottom.
    
    Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Mar 9, 2006
  1. Use #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))

    Junio C Hamano authored
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Mar 5, 2006
  1. Const tightening.

    Junio C Hamano authored
    Mark Wooding noticed there was a type mismatch warning in git.c; this
    patch does things slightly differently (mostly tightening const) and
    was what I was holding onto, waiting for the setup-revisions change
    to be merged into the master branch.
    
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Commits on Feb 26, 2006
  1. tihirvon

    Use setenv(), fix warnings

    tihirvon authored Junio C Hamano committed
      - Fix -Wundef -Wold-style-definition warnings
      - Make pll_free() static
    
    [jc: original patch by Timo had another unrelated bits:
    
      - Use setenv() instead of putenv()
    
     I'm postponing that part for now.]
    
    Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
    Signed-off-by: Junio C Hamano <junkio@cox.net>
Something went wrong with that request. Please try again.