1. 22 9月, 2016 1 次提交
    • J
      regex: add regexec_buf() that can work on a non NUL-terminated string · 2f895225
      Johannes Schindelin 提交于
      We just introduced a test that demonstrates that our sloppy use of
      regexec() on a mmap()ed area can result in incorrect results or even
      hard crashes.
      
      So what we need to fix this is a function that calls regexec() on a
      length-delimited, rather than a NUL-terminated, string.
      
      Happily, there is an extension to regexec() introduced by the NetBSD
      project and present in all major regex implementation including
      Linux', MacOSX' and the one Git includes in compat/regex/: by using
      the (non-POSIX) REG_STARTEND flag, it is possible to tell the
      regexec() function that it should only look at the offsets between
      pmatch[0].rm_so and pmatch[0].rm_eo.
      
      That is exactly what we need.
      
      Since support for REG_STARTEND is so widespread by now, let's just
      introduce a helper function that always uses it, and tell people
      on a platform whose regex library does not support it to use the
      one from our compat/regex/ directory.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2f895225
  2. 20 4月, 2016 1 次提交
  3. 09 4月, 2016 1 次提交
  4. 05 4月, 2016 1 次提交
    • J
      Makefile: fix misdirected redirections · d55de70a
      Junio C Hamano 提交于
      In general "echo 2>&1 $msg" to redirect a possible error message
      that comes from 'echo' itself into the same standard output stream
      $msg is getting written to does not make any sense; it is not like
      we are expecting to see any errors out of 'echo' in these statements,
      and even if it were the case, there is no reason to prevent the
      error messages from being sent to the standard error stream.
      
      These are clearly meant to send the argument given to echo to the
      standard error stream as error messages.  Correctly redirect by
      saying "send what is written to the standard output to the standard
      error", i.e. "1>&2" aka ">&2".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d55de70a
  5. 11 3月, 2016 1 次提交
    • J
      sane_grep: pass "-a" if grep accepts it · 71b40103
      Junio C Hamano 提交于
      Newer versions of GNU grep is reported to be pickier when we feed a
      non-ASCII input and break some Porcelain scripts.  As we know we do
      not feed random binary file to our own sane_grep wrapper, allow us
      to always pass "-a" by setting SANE_TEXT_GREP=-a Makefile variable
      to work it around.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      71b40103
  6. 26 2月, 2016 1 次提交
  7. 28 1月, 2016 1 次提交
    • J
      mingw: fix t5601-clone.sh · 3064d5a3
      Johannes Schindelin 提交于
      Since baaf2337 (connect: improve check for plink to reduce false
      positives, 2015-04-26), t5601 writes out a `plink.exe` for testing that
      is actually a shell script. So the assumption that the `.exe` extension
      implies that the file is *not* a shell script is now wrong.
      
      Since there was no love for the idea of allowing `.exe` files to be
      shell scripts on Windows, let's go the other way round: *make*
      `plink.exe` a real `.exe`.
      
      This fixes t5601-clone.sh in Git for Windows' SDK.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3064d5a3
  8. 17 12月, 2015 1 次提交
  9. 20 11月, 2015 1 次提交
    • M
      refs: split filesystem-based refs code into a new file · 7bd9bcf3
      Michael Haggerty 提交于
      As another step in the move to pluggable reference backends, move the
      code that is specific to the filesystem-based reference backend (i.e.,
      the current system of storing references as loose and packed files) into
      a separate file, refs/files-backend.c.
      
      Aside from a tiny bit of file header boilerplate, this commit only moves
      a subset of the code verbatim from refs.c to the new file, as can easily
      be verified using patience diff:
      
          git diff --patience $commit^:refs.c $commit:refs.c
          git diff --patience $commit^:refs.c $commit:refs/files-backend.c
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJeff King <peff@peff.net>
      7bd9bcf3
  10. 06 11月, 2015 1 次提交
  11. 22 10月, 2015 3 次提交
  12. 06 10月, 2015 1 次提交
  13. 03 10月, 2015 1 次提交
  14. 11 9月, 2015 3 次提交
  15. 04 9月, 2015 1 次提交
    • S
      submodule: rewrite `module_list` shell function in C · 74703a1e
      Stefan Beller 提交于
      Most of the submodule operations work on a set of submodules.
      Calculating and using this set is usually done via:
      
             module_list "$@" | {
                 while read mode sha1 stage sm_path
                 do
                      # the actual operation
                 done
             }
      
      Currently the function `module_list` is implemented in the
      git-submodule.sh as a shell script wrapping a perl script.
      The rewrite is in C, such that it is faster and can later be
      easily adapted when other functions are rewritten in C.
      
      git-submodule.sh, similar to the builtin commands, will navigate
      to the top-most directory of the repository and keep the
      subdirectory as a variable. As the helper is called from
      within the git-submodule.sh script, we are already navigated
      to the root level, but the path arguments are still relative
      to the subdirectory we were in when calling git-submodule.sh.
      That's why there is a `--prefix` option pointing to an alternative
      path which to anchor relative path arguments.
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      74703a1e
  16. 26 8月, 2015 1 次提交
    • E
      generate-cmdlist: re-implement as shell script · 82aec45b
      Eric Sunshine 提交于
      527ec398 (generate-cmdlist: parse common group commands, 2015-05-21)
      replaced generate-cmdlist.sh with a more functional Perl version,
      generate-cmdlist.perl. The Perl version gleans named tags from a new
      "common groups" section in command-list.txt and recognizes those
      tags in "command list" section entries in place of the old 'common'
      tag. This allows git-help to, not only recognize, but also group
      common commands.
      
      Although the tests require Perl, 527ec398 creates an unconditional
      dependence upon Perl in the build system itself, which can not be
      overridden with NO_PERL. Such a dependency may be undesirable; for
      instance, the 'git-lite' package in the FreeBSD ports tree is
      intended as a minimal Git installation (which may, for example, be
      useful on servers needing only local clone and update capability),
      which, historically, has not depended upon Perl[1].
      
      Therefore, revive generate-cmdlist.sh and extend it to recognize
      "common groups" and its named tags. Retire generate-cmdlist.perl.
      
      [1]: http://thread.gmane.org/gmane.comp.version-control.git/275905/focus=276132Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      82aec45b
  17. 20 8月, 2015 1 次提交
    • H
      submodule: implement a config API for lookup of .gitmodules values · 959b5455
      Heiko Voigt 提交于
      In a superproject some commands need to interact with submodules. They
      need to query values from the .gitmodules file either from the worktree
      of from certain revisions. At the moment this is quite hard since a
      caller would need to read the .gitmodules file from the history and then
      parse the values. We want to provide an API for this so we have one
      place to get values from .gitmodules from any revision (including the
      worktree).
      
      The API is realized as a cache which allows us to lazily read
      .gitmodules configurations by commit into a runtime cache which can then
      be used to easily lookup values from it. Currently only the values for
      path or name are stored but it can be extended for any value needed.
      
      It is expected that .gitmodules files do not change often between
      commits. Thats why we lookup the .gitmodules sha1 from a commit and then
      either lookup an already parsed configuration or parse and cache an
      unknown one for each sha1. The cache is lazily build on demand for each
      requested commit.
      
      This cache can be used for all purposes which need knowledge about
      submodule configurations. Example use cases are:
      
       * Recursive submodule checkout needs to lookup a submodule name from
         its path when a submodule first appears. This needs be done before
         this configuration exists in the worktree.
      
       * The implementation of submodule support for 'git archive' needs to
         lookup the submodule name to generate the archive when given a
         revision that is not checked out.
      
       * 'git fetch' when given the --recurse-submodules=on-demand option (or
         configuration) needs to lookup submodule names by path from the
         database rather than reading from the worktree. For new submodule it
         needs to lookup the name from its path to allow cloning new
         submodules into the .git folder so they can be checked out without
         any network interaction when the user does a checkout of that
         revision.
      Signed-off-by: NHeiko Voigt <hvoigt@hvoigt.net>
      Signed-off-by: NStefan Beller <sbeller@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      959b5455
  18. 11 8月, 2015 1 次提交
  19. 05 8月, 2015 2 次提交
    • P
      builtin-am: remove redirection to git-am.sh · 783d7e86
      Paul Tan 提交于
      At the beginning of the rewrite of git-am.sh to C, in order to not break
      existing test scripts that depended on a functional git-am, a
      redirection to git-am.sh was introduced that would activate if the
      environment variable _GIT_USE_BUILTIN_AM was not defined.
      
      Now that all of git-am.sh's functionality has been re-implemented in
      builtin/am.c, remove this redirection, and retire git-am.sh into
      contrib/examples/.
      Signed-off-by: NPaul Tan <pyokagan@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      783d7e86
    • P
      builtin-am: implement skeletal builtin am · 73c2779f
      Paul Tan 提交于
      For the purpose of rewriting git-am.sh into a C builtin, implement a
      skeletal builtin/am.c that redirects to $GIT_EXEC_PATH/git-am if the
      environment variable _GIT_USE_BUILTIN_AM is not defined. Since in the
      Makefile git-am.sh takes precedence over builtin/am.c,
      $GIT_EXEC_PATH/git-am will contain the shell script git-am.sh, and thus
      this allows us to fall back on the functional git-am.sh when running the
      test suite for tests that depend on a working git-am implementation.
      
      Since git-am.sh cannot handle any environment modifications by
      setup_git_directory(), "am" is declared with no setup flags in git.c. On
      the other hand, to re-implement git-am.sh in builtin/am.c, we need to
      run all the git dir and work tree setup logic that git.c typically does
      for us. As such, we work around this temporarily by copying the logic in
      git.c's run_builtin(), which is roughly:
      
      	prefix = setup_git_directory();
      	trace_repo_setup(prefix);
      	setup_work_tree();
      
      This redirection should be removed when all the features of git-am.sh
      have been re-implemented in builtin/am.c.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NPaul Tan <pyokagan@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      73c2779f
  20. 04 8月, 2015 1 次提交
  21. 02 7月, 2015 1 次提交
  22. 29 6月, 2015 1 次提交
  23. 19 6月, 2015 1 次提交
    • P
      pull: remove redirection to git-pull.sh · b1456605
      Paul Tan 提交于
      At the beginning of the rewrite of git-pull.sh to C, we introduced a
      redirection to git-pull.sh if the environment variable
      _GIT_USE_BUILTIN_PULL was not defined in order to not break test scripts
      that relied on a functional git-pull.
      
      Now that all of git-pull's functionality has been re-implemented in
      builtin/pull.c, remove this redirection, and retire the old git-pull.sh
      into contrib/examples/.
      Signed-off-by: NPaul Tan <pyokagan@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b1456605
  24. 16 6月, 2015 1 次提交
    • P
      pull: implement skeletal builtin pull · 1e1ea69f
      Paul Tan 提交于
      For the purpose of rewriting git-pull.sh into a C builtin, implement a
      skeletal builtin/pull.c that redirects to $GIT_EXEC_PATH/git-pull.sh if
      the environment variable _GIT_USE_BUILTIN_PULL is not defined. This
      allows us to fall back on the functional git-pull.sh when running the
      test suite for tests that depend on a working git-pull implementation.
      
      This redirection should be removed when all the features of git-pull.sh
      have been re-implemented in builtin/pull.c.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NPaul Tan <pyokagan@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1e1ea69f
  25. 30 5月, 2015 3 次提交
    • J
      Makefile: silence perl/PM.stamp recipe · 7c37a5dc
      Jeff King 提交于
      Every time we run "make", we update perl/PM.stamp, which
      contains a list of all of the perl module files (if it's
      updated, we need to rebuild perl/perl.mak, since the
      Makefile will not otherwise know about the new files).
      
      This means that every time "make" is run, we see:
      
            GEN perl/PM.stamp
      
      in the output, even though it is not likely to have changed.
      Let's make this recipe completely silent, as we do for other
      auto-generated dependency files (e.g., GIT-CFLAGS).
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7c37a5dc
    • J
      Makefile: avoid timestamp updates to GIT-BUILD-OPTIONS · a2d25ef0
      Jeff King 提交于
      We force the GIT-BUILD-OPTIONS recipe to run every time
      "make" is invoked. We must do this to catch new options
      which may have come from the command-line or environment.
      
      However, we actually update the file's timestamp each time
      the recipe is run, whether anything changed or not. As a
      result, any files which depend on it (for example, all of
      the perl scripts, which need to know whether NO_PERL was
      set) will be re-built every time.
      
      Let's do our usual trick of writing to a tempfile, then
      doing a "cmp || mv" to update the file only when something
      changed.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a2d25ef0
    • J
      Makefile: drop dependency between git-instaweb and gitweb · e25c7cc1
      Jeff King 提交于
      The rule for "git-instaweb" depends on "gitweb". This makes
      no sense, because:
      
        1. git-instaweb has no build-time dependency on gitweb; it
           is a run-time dependency
      
        2. gitweb is a directory that we want to recursively make
           in. As a result, its recipe is marked .PHONY, which
           causes "make" to rebuild git-instaweb every time it is
           run.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      e25c7cc1
  26. 22 5月, 2015 2 次提交
  27. 08 5月, 2015 1 次提交
  28. 16 4月, 2015 1 次提交
    • J
      strbuf_getwholeline: use getdelim if it is available · 0cc30e0e
      Jeff King 提交于
      We spend a lot of time in strbuf_getwholeline in a tight
      loop reading characters from a stdio handle into a buffer.
      The libc getdelim() function can do this for us with less
      overhead. It's in POSIX.1-2008, and was a GNU extension
      before that. Therefore we can't rely on it, but can fall
      back to the existing getc loop when it is not available.
      
      The HAVE_GETDELIM knob is turned on automatically for Linux,
      where we have glibc. We don't need to set any new
      feature-test macros, because we already define _GNU_SOURCE.
      Other systems that implement getdelim may need to other
      macros (probably _POSIX_C_SOURCE >= 200809L), but we can
      address that along with setting the Makefile knob after
      testing the feature on those systems.
      
      Running "git rev-parse refs/heads/does-not-exist" on a repo
      with an extremely large (1.6GB) packed-refs file went from
      (best-of-5):
      
        real    0m8.601s
        user    0m8.084s
        sys     0m0.524s
      
      to:
      
        real    0m6.768s
        user    0m6.340s
        sys     0m0.432s
      
      for a wall-clock speedup of 21%.
      
      Based on a patch from Rasmus Villemoes <rv@rasmusvillemoes.dk>.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      0cc30e0e
  29. 13 3月, 2015 1 次提交
  30. 11 3月, 2015 1 次提交
  31. 04 2月, 2015 1 次提交
  32. 13 1月, 2015 1 次提交
    • K
      gettext.h: add parentheses around N_ expansion if supported · 290c8e7a
      Kyle J. McKay 提交于
      The gettext N_ macro is used to mark strings for translation
      without actually translating them.  At runtime the string is
      expected to be passed to the gettext API for translation.
      
      If two N_ macro invocations appear next to each other with only
      whitespace (or nothing at all) between them, the two separate
      strings will be marked for translation, but the preprocessor
      will then silently combine the strings into one and at runtime
      the string passed to gettext will not match the strings that
      were translated so no translation will actually occur.
      
      Avoid this by adding parentheses around the expansion of the
      N_ macro so that instead of ending up with two adjacent strings
      that are then combined by the preprocessor, two adjacent strings
      surrounded by parentheses result instead which causes a compile
      error so the mistake can be quickly found and corrected.
      
      However, since these string literals are typically assigned to
      static variables and not all compilers support parenthesized
      string literal assignments, allow this to be controlled by the
      Makefile with the default only enabled when the compiler is
      known to support the syntax.
      
      For now only __GNUC__ enables this by default which covers both
      gcc and clang which should result in early detection of any
      adjacent N_ macros.
      
      Although the necessary tests make the affected files a bit less
      elegant, the benefit of avoiding propagation of a translation-
      marking error to all the translation teams thus creating extra
      work for them when the error is eventually detected and fixed
      would seem to outweigh the minor inelegance the additional
      configuration tests introduce.
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NKyle J. McKay <mackyle@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      290c8e7a