1. 19 9月, 2014 1 次提交
  2. 27 8月, 2014 1 次提交
  3. 14 7月, 2014 1 次提交
    • K
      git: add performance tracing for git's main() function to debug scripts · 578da039
      Karsten Blees 提交于
      Use trace_performance to measure and print execution time and command line
      arguments of the entire main() function. In constrast to the shell's 'time'
      utility, which measures total time of the parent process, this logs all
      involved git commands recursively. This is particularly useful to debug
      performance issues of scripted commands (i.e. which git commands were
      called with which parameters, and how long did they execute).
      
      Due to git's deliberate use of exit(), the implementation uses an atexit
      routine rather than just adding trace_performance_since() at the end of
      main().
      
      Usage example: > GIT_TRACE_PERFORMANCE=~/git-trace.log git stash list
      
      Creates a log file like this:
      23:57:38.638765 trace.c:405 performance: 0.000310107 s: git command: 'git' 'rev-parse' '--git-dir'
      23:57:38.644387 trace.c:405 performance: 0.000261759 s: git command: 'git' 'rev-parse' '--show-toplevel'
      23:57:38.646207 trace.c:405 performance: 0.000304468 s: git command: 'git' 'config' '--get-colorbool' 'color.interactive'
      23:57:38.648491 trace.c:405 performance: 0.000241667 s: git command: 'git' 'config' '--get-color' 'color.interactive.help' 'red bold'
      23:57:38.650465 trace.c:405 performance: 0.000243063 s: git command: 'git' 'config' '--get-color' '' 'reset'
      23:57:38.654850 trace.c:405 performance: 0.025126313 s: git command: 'git' 'stash' 'list'
      Signed-off-by: NKarsten Blees <blees@dcon.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      578da039
  4. 24 6月, 2014 1 次提交
  5. 21 6月, 2014 2 次提交
    • J
      git: avoid magic number with skip_prefix · 6d877803
      Jeff King 提交于
      After handling options, any leftover arguments should be
      commands. However, we pass through "--help" and "--version",
      so that we convert them into "git help" and "git version"
      respectively.
      
      This is a straightforward use of skip_prefix to avoid a
      magic number, but while we are there, it is worth adding a
      comment to explain this otherwise confusing behavior.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6d877803
    • J
      use skip_prefix to avoid magic numbers · ae021d87
      Jeff King 提交于
      It's a common idiom to match a prefix and then skip past it
      with a magic number, like:
      
        if (starts_with(foo, "bar"))
      	  foo += 3;
      
      This is easy to get wrong, since you have to count the
      prefix string yourself, and there's no compiler check if the
      string changes.  We can use skip_prefix to avoid the magic
      numbers here.
      
      Note that some of these conversions could be much shorter.
      For example:
      
        if (starts_with(arg, "--foo=")) {
      	  bar = arg + 6;
      	  continue;
        }
      
      could become:
      
        if (skip_prefix(arg, "--foo=", &bar))
      	  continue;
      
      However, I have left it as:
      
        if (skip_prefix(arg, "--foo=", &v)) {
      	  bar = v;
      	  continue;
        }
      
      to visually match nearby cases which need to actually
      process the string. Like:
      
        if (skip_prefix(arg, "--foo=", &v)) {
      	  bar = atoi(v);
      	  continue;
        }
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ae021d87
  6. 11 6月, 2014 1 次提交
  7. 23 4月, 2014 1 次提交
  8. 21 2月, 2014 1 次提交
  9. 07 1月, 2014 2 次提交
  10. 11 12月, 2013 1 次提交
  11. 06 12月, 2013 1 次提交
    • C
      replace {pre,suf}fixcmp() with {starts,ends}_with() · 59556548
      Christian Couder 提交于
      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
      functions.
      
      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 '
              s|!prefixcmp\(|starts_with\(|g;
              s|prefixcmp\(|!starts_with\(|g;
              s|!suffixcmp\(|ends_with\(|g;
              s|suffixcmp\(|!ends_with\(|g;
            '
      
      on the result of preparatory changes in this series.
      Signed-off-by: NChristian Couder <chriscool@tuxfamily.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      59556548
  12. 13 11月, 2013 3 次提交
  13. 18 9月, 2013 1 次提交
    • S
      repack: rewrite the shell script in C · a1bbc6c0
      Stefan Beller 提交于
      The motivation of this patch is to get closer to a goal of being
      able to have a core subset of git functionality built in to git.
      That would mean
      
       * people on Windows could get a copy of at least the core parts
         of Git without having to install a Unix-style shell
      
       * people using git in on servers with chrooted environments
         do not need to worry about standard tools lacking for shell
         scripts.
      
      This patch is meant to be mostly a literal translation of the
      git-repack script; the intent is that later patches would start using
      more library facilities, but this patch is meant to be as close to a
      no-op as possible so it doesn't do that kind of thing.
      Signed-off-by: NStefan Beller <stefanbeller@googlemail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a1bbc6c0
  14. 10 9月, 2013 1 次提交
    • N
      git: run in a directory given with -C option · 44e1e4d6
      Nazri Ramliy 提交于
      This is similar in spirit to "make -C dir ..." and "tar -C dir ...".
      
      It takes more keypresses to invoke git command in a different
      directory without leaving the current directory:
      
          1. (cd ~/foo && git status)
             git --git-dir=~/foo/.git --work-dir=~/foo status
             GIT_DIR=~/foo/.git GIT_WORK_TREE=~/foo git status
          2. (cd ../..; git grep foo)
          3. for d in d1 d2 d3; do (cd $d && git svn rebase); done
      
      The methods shown above are acceptable for scripting but are too
      cumbersome for quick command line invocations.
      
      With this new option, the above can be done with fewer keystrokes:
      
          1. git -C ~/foo status
          2. git -C ../.. grep foo
          3. for d in d1 d2 d3; do git -C $d svn rebase; done
      
      A new test script is added to verify the behavior of this option with
      other path-related options like --git-dir and --work-tree.
      Signed-off-by: NNazri Ramliy <ayiehere@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      44e1e4d6
  15. 18 7月, 2013 1 次提交
    • T
      git: ensure 0/1/2 are open in main() · a11c3964
      Thomas Rast 提交于
      Not having an open FD in the 0--2 range can lead to strange results,
      for example, a subsequent open() may return 2 (stderr) and then a
      die() would clobber this file.
      
      git-daemon and git-shell already guarded against this, but apparently
      users also manage to trip over it in other git commands.  So we call
      sanitize_stdfds() during main git startup.
      
      Since these FDs are inherited, this covers all use of 'git foo ...',
      and all internal C commands when called directly.  It does not fix
      shell/perl commands called directly.
      Signed-off-by: NThomas Rast <trast@inf.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a11c3964
  16. 16 7月, 2013 2 次提交
  17. 14 7月, 2013 1 次提交
    • E
      builtin: add git-check-mailmap command · 226ad348
      Eric Sunshine 提交于
      Introduce command check-mailmap, similar to check-attr and check-ignore,
      which allows direct testing of .mailmap configuration.
      
      As plumbing accessible to scripts and other porcelain, check-mailmap
      publishes the stable, well-tested .mailmap functionality employed by
      built-in Git commands.  Consequently, script authors need not
      re-implement .mailmap functionality manually, thus avoiding potential
      quirks and behavioral differences.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      226ad348
  18. 28 5月, 2013 1 次提交
  19. 29 4月, 2013 1 次提交
    • R
      sparse: Fix mingw_main() argument number/type errors · 84d32bf7
      Ramsay Jones 提交于
      Sparse issues 68 errors (two errors for each main() function) such
      as the following:
      
            SP git.c
        git.c:510:5: error: too many arguments for function mingw_main
        git.c:510:5: error: symbol 'mingw_main' redeclared with different type \
          (originally declared at git.c:510) - different argument counts
      
      The errors are caused by the 'main' macro used by the MinGW build
      to provide a replacement main() function. The original main function
      is effectively renamed to 'mingw_main' and is called from the new
      main function. The replacement main is used to execute certain actions
      common to all git programs on MinGW (e.g. ensure the standard I/O
      streams are in binary mode).
      
      In order to suppress the errors, we change the macro to include the
      parameters in the declaration of the mingw_main function.
      
      Unfortunately, this change provokes both sparse and gcc to complain
      about 9 calls to mingw_main(), such as the following:
      
            CC git.o
        git.c: In function 'main':
        git.c:510: warning: passing argument 2 of 'mingw_main' from \
          incompatible pointer type
        git.c:510: note: expected 'const char **' but argument is of \
          type 'char **'
      
      In order to suppress these warnings, since both of the main
      functions need to be declared with the same prototype, we
      change the declaration of the 9 main functions, thus:
      
          int main(int argc, char **argv)
      Signed-off-by: NRamsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      84d32bf7
  20. 03 4月, 2013 1 次提交
  21. 12 3月, 2013 1 次提交
  22. 11 3月, 2013 1 次提交
  23. 09 3月, 2013 1 次提交
    • J
      setup: suppress implicit "." work-tree for bare repos · 2cd83d10
      Jeff King 提交于
      If an explicit GIT_DIR is given without a working tree, we
      implicitly assume that the current working directory should
      be used as the working tree. E.g.,:
      
        GIT_DIR=/some/repo.git git status
      
      would compare against the cwd.
      
      Unfortunately, we fool this rule for sub-invocations of git
      by setting GIT_DIR internally ourselves. For example:
      
        git init foo
        cd foo/.git
        git status ;# fails, as we expect
        git config alias.st status
        git status ;# does not fail, but should
      
      What happens is that we run setup_git_directory when doing
      alias lookup (since we need to see the config), set GIT_DIR
      as a result, and then leave GIT_WORK_TREE blank (because we
      do not have one). Then when we actually run the status
      command, we do setup_git_directory again, which sees our
      explicit GIT_DIR and uses the cwd as an implicit worktree.
      
      It's tempting to argue that we should be suppressing that
      second invocation of setup_git_directory, as it could use
      the values we already found in memory. However, the problem
      still exists for sub-processes (e.g., if "git status" were
      an external command).
      
      You can see another example with the "--bare" option, which
      sets GIT_DIR explicitly. For example:
      
        git init foo
        cd foo/.git
        git status ;# fails
        git --bare status ;# does NOT fail
      
      We need some way of telling sub-processes "even though
      GIT_DIR is set, do not use cwd as an implicit working tree".
      We could do it by putting a special token into
      GIT_WORK_TREE, but the obvious choice (an empty string) has
      some portability problems.
      
      Instead, we add a new boolean variable, GIT_IMPLICIT_WORK_TREE,
      which suppresses the use of cwd as a working tree when
      GIT_DIR is set. We trigger the new variable when we know we
      are in a bare setting.
      
      The variable is left intentionally undocumented, as this is
      an internal detail (for now, anyway). If somebody comes up
      with a good alternate use for it, and once we are confident
      we have shaken any bugs out of it, we can consider promoting
      it further.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2cd83d10
  24. 07 1月, 2013 1 次提交
  25. 20 12月, 2012 1 次提交
    • J
      add global --literal-pathspecs option · 823ab40f
      Jeff King 提交于
      Git takes pathspec arguments in many places to limit the
      scope of an operation. These pathspecs are treated not as
      literal paths, but as glob patterns that can be fed to
      fnmatch. When a user is giving a specific pattern, this is a
      nice feature.
      
      However, when programatically providing pathspecs, it can be
      a nuisance. For example, to find the latest revision which
      modified "$foo", one can use "git rev-list -- $foo". But if
      "$foo" contains glob characters (e.g., "f*"), it will
      erroneously match more entries than desired. The caller
      needs to quote the characters in $foo, and even then, the
      results may not be exactly the same as with a literal
      pathspec. For instance, the depth checks in
      match_pathspec_depth do not kick in if we match via fnmatch.
      
      This patch introduces a global command-line option (i.e.,
      one for "git" itself, not for specific commands) to turn
      this behavior off. It also has a matching environment
      variable, which can make it easier if you are a script or
      porcelain interface that is going to issue many such
      commands.
      
      This option cannot turn off globbing for particular
      pathspecs. That could eventually be done with a ":(noglob)"
      magic pathspec prefix. However, that level of granularity is
      more cumbersome to use for many cases, and doing ":(noglob)"
      right would mean converting the whole codebase to use
      "struct pathspec", as the usual "const char **pathspec"
      cannot represent extra per-item flags.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      823ab40f
  26. 29 10月, 2012 1 次提交
  27. 26 6月, 2012 1 次提交
  28. 04 6月, 2012 1 次提交
  29. 28 4月, 2012 1 次提交
    • N
      Add column layout skeleton and git-column · 7e29b825
      Nguyễn Thái Ngọc Duy 提交于
      A column option string consists of many token separated by either
      a space or a  comma. A token belongs to one of three groups:
      
       - enabling: always, never and auto
       - layout mode: currently plain (which does not layout at all)
       - other future tuning flags
      
      git-column can be used to pipe output to from a command that wants
      column layout, but not to mess with its own output code. Simpler output
      code can be changed to use column layout code directly.
      
      Thanks-to: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7e29b825
  30. 25 4月, 2012 1 次提交
  31. 09 1月, 2012 1 次提交
  32. 06 12月, 2011 1 次提交
    • Æ
      i18n: add infrastructure for translating Git with gettext · 5e9637c6
      Ævar Arnfjörð Bjarmason 提交于
      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
      appropriately.
      
      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
      understand.
      
      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
      necessary.
      
      See <AANLkTilYD_NyIZMyj9dHtVk-ylVBfvyxpCC7982LWnVd@mail.gmail.com> 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 gettext.sh.
      
      If gettext.sh 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
      wrapper.
      
      = 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
      HAVE_LIBCHARSET_H is set.
      
      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()
      instead.
      
      =Credits
      
      This patch is based on work by Jeff Epler <jepler@unpythonic.net> 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
      others.
      
      [jc: squashed a small Makefile fix from Ramsay]
      Signed-off-by: NÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: NRamsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5e9637c6
  33. 22 11月, 2011 1 次提交
  34. 20 8月, 2011 1 次提交
    • J
      support pager.* for external commands · 92058e4d
      Jeff King 提交于
      Without this patch, any commands that are not builtin would
      not respect pager.* config. For example:
      
        git config pager.stash false
        git stash list
      
      would still use a pager. With this patch, pager.stash now
      has an effect. If it is not specified, we will still fall
      back to pager.log when we invoke "log" from "stash list".
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      92058e4d
  35. 10 8月, 2011 1 次提交