Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Commits on Jun 19, 2014
  1. @peff @gitster

    use xstrfmt to replace xmalloc + strcpy/strcat

    peff authored gitster committed
    It's easy to get manual allocation calculations wrong, and
    the use of strcpy/strcat raise red flags for people looking
    for buffer overflows (though in this case each site was
    It's also shorter to use xstrfmt, and the printf-format
    tends to be easier for a reader to see what the final string
    will look like.
    Signed-off-by: Jeff King <>
    Signed-off-by: Junio C Hamano <>
Commits on Dec 5, 2013
  1. @chriscool @gitster

    replace {pre,suf}fixcmp() with {starts,ends}_with()

    chriscool authored gitster committed
    Leaving only the function definitions and declarations so that any
    new topic in flight can still make use of the old functions, replace
    existing uses of the prefixcmp() and suffixcmp() with new API
    The change can be recreated by mechanically applying this:
        $ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
          grep -v strbuf\\.c |
          xargs perl -pi -e '
    on the result of preparatory changes in this series.
    Signed-off-by: Christian Couder <>
    Signed-off-by: Junio C Hamano <>
Commits on Jul 22, 2013
  1. @gitster

    Merge branch 'tr/protect-low-3-fds'

    gitster authored
    When "git" is spawned in such a way that any of the low 3 file
    descriptors is closed, our first open() may yield file descriptor 2,
    and writing error message to it would screw things up in a big way.
    * tr/protect-low-3-fds:
      git: ensure 0/1/2 are open in main()
      daemon/shell: refactor redirection of 0/1/2 from /dev/null
Commits on Jul 17, 2013
  1. @gitster

    daemon/shell: refactor redirection of 0/1/2 from /dev/null

    Thomas Rast authored gitster committed
    Both daemon.c and shell.c contain logic to open FDs 0/1/2 from
    /dev/null if they are not already open.  Move the function in daemon.c
    to setup.c and use it in shell.c, too.
    While there, remove a 'not' that inverted the meaning of the comment.
    The point is indeed to *avoid* messing up.
    Signed-off-by: Thomas Rast <>
    Signed-off-by: Junio C Hamano <>
Commits on Mar 10, 2013
  1. @jrn @gitster

    shell: new no-interactive-login command to print a custom message

    jrn authored gitster committed
    If I disable git-shell's interactive mode by removing the
    ~/git-shell-commands directory, attempts to ssh in to the service
    produce a message intended for the administrator:
    	$ ssh git@myserver
    	fatal: Interactive git shell is not enabled.
    	hint: ~/git-shell-commands should exist and have read and execute access.
    That is helpful for the new admin who is wondering "What? Why isn't
    the git-shell I just set up working?", but once the site setup is
    complete, it would be better to give the user a friendly hint that she
    is on the right track, like GitHub does.
    	Hi <username>! You've successfully authenticated, but
    	GitHub does not provide shell access.
    An appropriate greeting might even include more complex dynamic
    information, like gitolite's list of repositories the user has access
    to.  Add support for a ~/git-shell-commands/no-interactive-login
    command that generates an arbitrary greeting.  When the user tries to
    log in:
     * If the file ~/git-shell-commands/no-interactive-login exists,
       run no-interactive-login to let the server say what it likes,
       then hang up.
     * Otherwise, if ~/git-shell-commands/ is present, start an
       interactive read-eval-print loop.
     * Otherwise, print the usual configuration hint and hang up.
    Reported-by: Ethan Reesor <>
    Signed-off-by: Jonathan Nieder <>
    Improved-by: Jeff King <>
    Signed-off-by: Junio C Hamano <>
Commits on Dec 6, 2011
  1. @avar @gitster

    i18n: add infrastructure for translating Git with gettext

    avar authored gitster committed
    Change the skeleton implementation of i18n in Git to one that can show
    localized strings to users for our C, Shell and Perl programs using
    either GNU libintl or the Solaris gettext implementation.
    This new internationalization support is enabled by default. If
    gettext isn't available, or if Git is compiled with
    NO_GETTEXT=YesPlease, Git falls back on its current behavior of
    showing interface messages in English. When using the autoconf script
    we'll auto-detect if the gettext libraries are installed and act
    This change is somewhat large because as well as adding a C, Shell and
    Perl i18n interface we're adding a lot of tests for them, and for
    those tests to work we need a skeleton PO file to actually test
    translations. A minimal Icelandic translation is included for this
    purpose. Icelandic includes multi-byte characters which makes it easy
    to test various edge cases, and it's a language I happen to
    The rest of the commit message goes into detail about various
    sub-parts of this commit.
    = Installation
    Gettext .mo files will be installed and looked for in the standard
    $(prefix)/share/locale path. GIT_TEXTDOMAINDIR can also be set to
    override that, but that's only intended to be used to test Git itself.
    = Perl
    Perl code that's to be localized should use the new Git::I18n
    module. It imports a __ function into the caller's package by default.
    Instead of using the high level Locale::TextDomain interface I've
    opted to use the low-level (equivalent to the C interface)
    Locale::Messages module, which Locale::TextDomain itself uses.
    Locale::TextDomain does a lot of redundant work we don't need, and
    some of it would potentially introduce bugs. It tries to set the
    $TEXTDOMAIN based on package of the caller, and has its own
    hardcoded paths where it'll search for messages.
    I found it easier just to completely avoid it rather than try to
    circumvent its behavior. In any case, this is an issue wholly
    internal Git::I18N. Its guts can be changed later if that's deemed
    See <> for
    a further elaboration on this topic.
    = Shell
    Shell code that's to be localized should use the git-sh-i18n
    library. It's basically just a wrapper for the system's
    If isn't available we'll fall back on gettext(1) if it's
    available. The latter is available without the former on Solaris,
    which has its own non-GNU gettext implementation. We also need to
    emulate eval_gettext() there.
    If neither are present we'll use a dumb printf(1) fall-through
    = About libcharset.h and langinfo.h
    We use libcharset to query the character set of the current locale if
    it's available. I.e. we'll use it instead of nl_langinfo if
    The GNU gettext manual recommends using langinfo.h's
    nl_langinfo(CODESET) to acquire the current character set, but on
    systems that have libcharset.h's locale_charset() using the latter is
    either saner, or the only option on those systems.
    GNU and Solaris have a nl_langinfo(CODESET), FreeBSD can use either,
    but MinGW and some others need to use libcharset.h's locale_charset()
    This patch is based on work by Jeff Epler <> who
    did the initial Makefile / C work, and a lot of comments from the Git
    mailing list, including Jonathan Nieder, Jakub Narebski, Johannes
    Sixt, Erik Faye-Lund, Peter Krefting, Junio C Hamano, Thomas Rast and
    [jc: squashed a small Makefile fix from Ramsay]
    Signed-off-by: Ævar Arnfjörð Bjarmason <>
    Signed-off-by: Ramsay Jones <>
    Signed-off-by: Junio C Hamano <>
Commits on May 5, 2011
  1. @gitster

    shell: add missing initialization of argv0_path

    Dima Sharov authored gitster committed
    According to c6dfb39 (remote-curl: add missing initialization of
    argv0_path, 2009-10-13), stand-alone programs (non-builtins)
    must call git_extract_argv0_path(argv[0]) in order to help builds
    that derive the installation prefix at runtime. Without this call,
    the program segfaults (or raises an assertion failure).
    Signed-off-by: Dima Sharov <>
    Acked-by: Johannes Sixt <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 27, 2010
  1. @gitster

    shell: Display errors from improperly-formatted command lines

    Greg Brockman authored gitster committed
    The interface for split_cmdline has changed such that the caller holds
    responsibility for printing any error messages.  This patch changes
    the git shell to print these error messages as appropriate.
    Signed-off-by: Greg Brockman <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 24, 2010
  1. @artagnon @gitster

    shell: Rewrite documentation and improve error message

    artagnon authored gitster committed
    Update the documentation of 'git shell' to mention the interactive
    mode and COMMAND_DIR. Also provide a hint when interactive mode is not
    available in the shell.
    Signed-off-by: Ramkumar Ramachandra <>
    Reviewed-by: Greg Brockman <gdb@MIT.EDU>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 12, 2010
  1. @gitster

    Add interactive mode to git-shell for user-friendliness

    Greg Brockman authored gitster committed
    Signed-off-by: Greg Brockman <>
    Signed-off-by: Junio C Hamano <>
  2. @gitster

    Allow creation of arbitrary git-shell commands

    Greg Brockman authored gitster committed
    This provides a mechanism for the server to expose custom
    functionality to clients.  My particular use case is that I would like
    a way of discovering all repositories available for cloning.  A
    client that clones via
      git clone
    can invoke a command by
      ssh $command
    Signed-off-by: Greg Brockman <>
    Signed-off-by: Junio C Hamano <>
Commits on Jun 27, 2009
  1. @trast @gitster

    Convert existing die(..., strerror(errno)) to die_errno()

    trast authored gitster committed
    Change calls to die(..., strerror(errno)) to use the new die_errno().
    In the process, also make slight style adjustments: at least state
    _something_ about the function that failed (instead of just printing
    the pathname), and put paths in single quotes.
    Signed-off-by: Thomas Rast <>
    Signed-off-by: Junio C Hamano <>
Commits on Apr 11, 2009
  1. @gitster

    git-shell: Add 'git-upload-archive' to allowed commands.

    Erik Broes authored gitster committed
    This allows for example gitosis to allow use of 'git archive --remote' in a
    controlled environment.
    Signed-off-by: Erik Broes <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 29, 2008
  1. @gitster

    Merge branch 'maint'

    gitster authored
    * maint:
      tutorial: gentler illustration of Alice/Bob workflow using gitk
      pretty=format: respect date format options
      make git-shell paranoid about closed stdin/stdout/stderr
      Document gitk --argscmd flag.
      Fix '--dirstat' with cross-directory renaming
      for-each-ref: Allow a trailing slash in the patterns
  2. @bonzini @gitster

    make git-shell paranoid about closed stdin/stdout/stderr

    bonzini authored gitster committed
    It is in general unsafe to start a program with one or more of file
    descriptors 0/1/2 closed.  Karl Chen for example noticed that stat_command
    does this in order to rename a pipe file descriptor to 0:
        dup2(from, 0);
    ... but if stdin was closed (for example) from == 0, so that
        dup2(0, 0);
    just ends up closing the pipe.  Another extremely rare but nasty problem
    would occur if an "important" file ends up in file descriptor 2, and is
    corrupted by a call to die().
    Fixing this in git was considered to be overkill, so this patch works
    around it only for git-shell.  The fix is simply to open all the "low"
    descriptors to /dev/null in main.
    Signed-off-by: Paolo Bonzini <>
    Acked-by: Stephen R. van den Berg <>
    Signed-off-by: Junio C Hamano <>
Commits on Aug 26, 2008
  1. @gitster

    Revert "Build-in "git-shell""

    gitster authored
    This reverts commit daa0cc9.
    It was a stupid idea to do this; when run as a log-in shell,
    it is spawned with argv[0] set to "-git-shell", so the usual
    name-based dispatch would not work to begin with.
Commits on Aug 20, 2008
  1. @gitster

    Build-in "git-shell"

    gitster authored
    This trivially makes "git-shell" a built-in.  It makes the executable even
    fatter, though.
    And MinGW removed git-shell only because of the funny dependencies; there
    is no reason to do so anymore.
    Signed-off-by: Junio C Hamano <>
    Tested-on-MinGW-by: Johannes Sixt <>
  2. @gitster

    shell: do not play duplicated definition games to shrink the executable

    gitster authored
    Playing with linker games to shrink git-shell did not go well with various
    other platforms and compilers.
    Signed-off-by: Junio C Hamano <>
Commits on Jul 26, 2008
  1. @gitster

    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:
    Therefore, we introduce git_set_argv0_path() and call it as soon as
    Signed-off-by: Johannes Sixt <>
    Signed-off-by: Junio C Hamano <>
Commits on Jun 28, 2008
  1. @dmpot @gitster

    shrink git-shell by avoiding redundant dependencies

    dmpot authored gitster committed
    A lot of modules that have nothing to do with git-shell functionality
    were linked in, bloating git-shell more than 8 times.
    This patch cuts off redundant dependencies by:
    1. providing stubs for three functions that make no sense for git-shell;
    2. moving quote_path_fully from environment.c to quote.c to make the
       later self sufficient;
    3. moving make_absolute_path into a new separate file.
    The following numbers have been received with the default optimization
    settings on master using GCC 4.1.2:
       text    data     bss     dec     hex filename
     143915    1348   93168  238431   3a35f git-shell
       text    data     bss     dec     hex filename
      17670     788    8232   26690    6842 git-shell
    Signed-off-by: Junio C Hamano <>
Commits on Jun 26, 2008
  1. @gitster

    git-shell: accept "git foo" form

    gitster authored
    This is a backport of 0a47dc1
    to 'maint' to be included in so that older server side
    can accept dashless form of request when clients are updated.
    Signed-off-by: Junio C Hamano <>
Commits on Oct 30, 2007
  1. @srp @gitster

    shell should call the new setup_path() to setup $PATH

    srp authored gitster committed
    Shell currently does its own manual thing for setting up the $PATH;
    it can now call setup_path().
    Signed-off-by: Scott R Parish <>
    Signed-off-by: Junio C Hamano <>
Commits on Oct 16, 2007
  1. @dscho @spearce

    Support cvs via git-shell

    dscho authored spearce committed
    This adds cvs support to the git-shell; You can now give new users
    a restricted git-shell and they still can commit via git's cvs
    Note that either the gecos information must be accurate, or you must
    provide a $HOME/.gitconfig with the appropriate user credentials.
    Since the git-shell is too restricted to allow the user to do it
    (on purpose!), it is up to the administrator to take care of that.
    Based on an idea by Jan Wielemaker.
    Signed-off-by: Johannes Schindelin <>
    Signed-off-by: Lars Hjemli <>
    Signed-off-by: Shawn O. Pearce <>
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 <>
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 <>
Commits on Jan 14, 2006
  1. Exec git programs without using PATH.

    Michal Ostrowski authored Junio C Hamano committed
    The git suite may not be in PATH (and thus programs such as
    git-send-pack could not exec git-rev-list).  Thus there is a need for
    logic that will locate these programs.  Modifying PATH is not
    desirable as it result in behavior differing from the user's
    intentions, as we may end up prepending "/usr/bin" to PATH.
    - git C programs will use exec*_git_cmd() APIs to exec sub-commands.
    - exec*_git_cmd() will execute a git program by searching for it in
      the following directories:
    	1. --exec-path (as used by "git")
    	2. The GIT_EXEC_PATH environment variable.
    	3. $(gitexecdir) as set in Makefile (default value $(bindir)).
    - git wrapper will modify PATH as before to enable shell scripts to
      invoke "git-foo" commands.
    Ideally, shell scripts should use the git wrapper to become independent
    of PATH, and then modifying PATH will not be necessary.
    [jc: with minor updates after a brief review.]
    Signed-off-by: Michal Ostrowski <>
    Signed-off-by: Junio C Hamano <>
Commits on Nov 26, 2005
  1. shell.c: complain on insufficient arguments.

    Junio C Hamano authored
    Originally noticed by Tommi Virtanen, but done slightly differently.
    Signed-off-by: Junio C Hamano <>
Commits on Oct 24, 2005
  1. Add git-shell.

    Linus Torvalds authored Junio C Hamano committed
    This adds a very git specific restricted shell, that can be
    added to /etc/shells and set to the pw_shell in the /etc/passwd
    file, to give users ability to push into repositories over ssh
    without giving them full interactive shell acount.
    [jc: I updated Linus' patch to match what the current sq_quote()
    Signed-off-by: Linus Torvalds <>
    Signed-off-by: Junio C Hamano <>
Something went wrong with that request. Please try again.