1. 09 Nov, 2021 1 commit
  2. 17 Oct, 2021 1 commit
    • str: introduce `git_str` for internal, `git_buf` is external · f0e693b1
      libgit2 has two distinct requirements that were previously solved by
      `git_buf`.  We require:
      
      1. A general purpose string class that provides a number of utility APIs
         for manipulating data (eg, concatenating, truncating, etc).
      2. A structure that we can use to return strings to callers that they
         can take ownership of.
      
      By using a single class (`git_buf`) for both of these purposes, we have
      confused the API to the point that refactorings are difficult and
      reasoning about correctness is also difficult.
      
      Move the utility class `git_buf` to be called `git_str`: this represents
      its general purpose, as an internal string buffer class.  The name also
      is an homage to Junio Hamano ("gitstr").
      
      The public API remains `git_buf`, and has a much smaller footprint.  It
      is generally only used as an "out" param with strict requirements that
      follow the documentation.  (Exceptions exist for some legacy APIs to
      avoid breaking callers unnecessarily.)
      
      Utility functions exist to convert a user-specified `git_buf` to a
      `git_str` so that we can call internal functions, then converting it
      back again.
      Edward Thomson committed
  3. 28 Apr, 2021 1 commit
    • repo: validate repository paths · c15ed350
      Ensure that a repository's path (at initialization or open time) is
      valid.  On Windows systems, this means that the longest known path
      beneath the repository will fit within MAX_PATH: this is a lock file for
      a loose object within the repository itself.
      
      Other paths, like a very long loose reference, may fail to be opened
      after the repository is opened.  These variable length paths will be
      checked when they are accessed themselves.  This new functionality is
      done at open to prevent needlessly checking every file in the gitdir
      (eg, `MERGE_HEAD`) for its length when we could instead check once at
      repository open time.
      Edward Thomson committed
  4. 07 Jan, 2021 1 commit
  5. 12 Oct, 2020 1 commit
    • Make the Windows leak detection more robust · 4a0dceeb
      This change:
      
      * Increases MY_ROW_LIMIT to 2M, since it has been failing in #5595's
        tests since it's _super_ close to the limit.
      * Calls `git_repository_free()` on a `git_repository` that was being
        leaked only in Windows.
      * Marks the global `git_repository` on `tests/repo/init.c` as `NULL`
        after being freed to make any accidental access more noisy.
      * Uses `cl_assert_equal_i()` in `test_trace_windows_stacktrace__leaks`
        to make the test failures more actionable.
      * Renames the globals in `tests/repo/init.c` so that they don't start
        with an underscore.
      lhchavez committed
  6. 03 Aug, 2020 1 commit
    • repo: honor the init.defaultBranch setting · e411aae3
      As part of a push towards more inclusive language, git is reconsidering
      using "master" as the default branch name.  As a first step, this
      setting will be configurable with the `init.defaultBranch` configuration
      option.  Honor this during repository initialization.
      
      During initialization, we will create an initial branch:
      
      1. Using the `initial_head` setting, if specified;
      2. Using the `HEAD` configured in a template, if it exists;
      3. Using the `init.defaultBranch` configuration option, if it is set; or
      4. Using `master` in the absence of additional configuration.
      Edward Thomson committed
  7. 20 Jul, 2019 2 commits
    • path: extract function to check whether a path supports symlinks · ded77bb1
      When initializing a repository, we need to check whether its working
      directory supports symlinks to correctly set the initial value of the
      "core.symlinks" config variable. The code to check the filesystem is
      reusable in other parts of our codebase, like for example in our tests
      to determine whether certain tests can be expected to succeed or not.
      
      Extract the code into a new function `git_path_supports_symlinks` to
      avoid duplicate implementations. Remove a duplicate implementation in
      the repo test helper code.
      Patrick Steinhardt committed
    • fileops: rename to "futils.h" to match function signatures · e54343a4
      Our file utils functions all have a "futils" prefix, e.g.
      `git_futils_touch`. One would thus naturally guess that their
      definitions and implementation would live in files "futils.h" and
      "futils.c", respectively, but in fact they live in "fileops.h".
      
      Rename the files to match expectations.
      Patrick Steinhardt committed
  8. 19 Jul, 2019 1 commit
  9. 11 Jul, 2019 1 commit
    • fileops: fix creation of directory in filesystem root · 5ae22a63
      In commit 45f24e78 (git_repository_init: stop traversing at
      windows root, 2019-04-12), we have fixed `git_futils_mkdir` to
      correctly handle the case where we create a directory in
      Windows-style filesystem roots like "C:\repo".
      
      The problem here is an off-by-one: previously, to that commit,
      we've been checking wether the parent directory's length is equal
      to the root directory's length incremented by one. When we call
      the function with "/example", then the parent directory's length
      ("/") is 1, but the root directory offset is 0 as the path is
      directly rooted without a drive prefix. This resulted in `1 == 0 +
      1`, which was true. With the change, we've stopped incrementing
      the root directory length, and thus now compare `1 <= 0`, which
      is false.
      
      The previous way of doing it was kind of finicky any non-obvious,
      which is also why the error was introduced. So instead of just
      re-adding the increment, let's explicitly add a condition that
      aborts finding the parent if the current parent path is "/".
      
      Making this change causes Azure Pipelines to fail the testcase
      repo::init::nonexistent_paths on Unix-based systems. This is because we
      have just fixed creating directories in the filesystem root, which
      previously didn't work. As Docker-based tests are running as root user,
      we are thus able to create the non-existing path and will now succeed to
      create the repository that was expected to actually fail.
      
      Let's split this up into three different tests:
      
      - A test to verify that we do not create repos in a non-existing parent
        directoy if the flag `GIT_REPOSITORY_INIT_MKPATH` is not set.
      
      - A test to verify that we fail if the root directory does not exist. As
        there is a common root directory on Unix-based systems that always
        exist, we can only test for this on Windows-based systems.
      
      - A test to verify that we fail if trying to create a repository in an
        unwriteable parent directory. We can only test this if not running
        tests as root user, as CAP_DAC_OVERRIDE will cause us to ignore
        permissions when creating files.
      Patrick Steinhardt committed
  10. 17 Apr, 2019 1 commit
    • git_repository_init: stop traversing at windows root · 45f24e78
      Stop traversing the filesystem at the Windows directory root.  We were
      calculating the filesystem root for the given directory to create, and
      walking up the filesystem hierarchy.  We intended to stop when the
      traversal path length is equal to the root path length (ie, stopping at
      the root, since no path may be shorter than the root path).
      
      However, on Windows, the root path may be specified in two different
      ways, as either `Z:` or `Z:\`, where `Z:` is the current drive letter.
      `git_path_dirname_r` returns the path _without_ a trailing slash, even
      for the Windows root.  As a result, during traversal, we need to test
      that the traversal path is _less than or equal to_ the root path length
      to determine if we've hit the root to ensure that we stop when our
      traversal path is `Z:` and our calculated root path was `Z:\`.
      Edward Thomson committed
  11. 17 Jan, 2019 1 commit
  12. 20 Oct, 2018 4 commits
  13. 10 Jun, 2018 1 commit
  14. 12 Nov, 2017 1 commit
  15. 17 Jun, 2017 1 commit
  16. 27 Dec, 2015 3 commits
  17. 17 Sep, 2015 1 commit
    • git_futils_mkdir_*: make a relative-to-base mkdir · ac2fba0e
      Untangle git_futils_mkdir from git_futils_mkdir_ext - the latter
      assumes that we own everything beneath the base, as if it were
      being called with a base of the repository or working directory,
      and is tailored towards checkout and ensuring that there is no
      bogosity beneath the base that must be cleaned up.
      
      This is (at best) slow and (at worst) unsafe in the larger context
      of a filesystem where we do not own things and cannot do things like
      unlink symlinks that are in our way.
      Edward Thomson committed
  18. 02 Jul, 2015 1 commit
  19. 03 Mar, 2015 1 commit
    • config: borrow refcounted references · 9a97f49e
      This changes the get_entry() method to return a refcounted version of
      the config entry, which you have to free when you're done.
      
      This allows us to avoid freeing the memory in which the entry is stored
      on a refresh, which may happen at any time for a live config.
      
      For this reason, get_string() has been forbidden on live configs and a
      new function get_string_buf() has been added, which stores the string in
      a git_buf which the user then owns.
      
      The functions which parse the string value takea advantage of the
      borrowing to parse safely and then release the entry.
      Carlos Martín Nieto committed
  20. 19 Feb, 2015 1 commit
  21. 05 Feb, 2015 1 commit
    • repo: ensure we can create repo at filesystem root · 865baaf9
      Test to ensure that we can create a repository at the filesystem
      root.  Introduces a new test environment variable,
      `GITTEST_INVASIVE_FILESYSTEM` for tests that do terrible things like
      escaping the clar sandbox and writing to the root directory.  It is
      expected that the CI builds will enable this but that normal people
      would not want this.
      Edward Thomson committed
  22. 08 Jan, 2015 1 commit
  23. 08 Nov, 2014 1 commit
  24. 17 Sep, 2014 1 commit
  25. 03 Sep, 2014 1 commit
  26. 14 Nov, 2013 1 commit
  27. 01 Nov, 2013 1 commit
  28. 03 Oct, 2013 3 commits
    • More cleanups to remove WIN assumptions · b8f9059d
      This cleans up more of the test suite to check actual filesystem
      behavior instead of relying on Windows vs. Mac vs. Linux to test.
      Russell Belfer committed
    • Update repo init with fewer platform assumptions · 840fb4fc
      The repo init code was assuming Windows == no filemode, and
      Mac or Windows == no case sensitivity.  Those assumptions are not
      consistently true depending on the mounted file system.  This is a
      first step to removing those assumptions.  It focuses on the repo
      init code and the tests of that code.  There are still many other
      tests that are broken when those assumptions don't hold true, but
      this clears up one area of the code.
      
      Also, this moves the core.precomposeunicode logic to be closer to
      the current logic in core Git where it will be set to true on any
      filesystem where composed unicode is decomposed when read back.
      Russell Belfer committed
    • Add check if we need to precompose unicode on Mac · 6b7991e2
      This adds initialization of core.precomposeunicode to repo init
      on Mac.  This is necessary because when a Mac accesses a repo on
      a VFAT or SAMBA file system, it will return directory entries in
      decomposed unicode even if the filesystem entry is precomposed.
      
      This also removes caching of a number of repo properties from the
      repo init pipeline because these are properties of the specific
      filesystem on which the repo is created, not of the system as a
      whole.
      Russell Belfer committed
  29. 24 Sep, 2013 1 commit
  30. 17 Sep, 2013 1 commit
  31. 05 Sep, 2013 2 commits