1. 16 Apr, 2019 5 commits
    • util: introduce GIT_CONTAINER_OF macro · b5f40441
      In some parts of our code, we make rather heavy use of casting
      structures to their respective specialized implementation. One
      example is the configuration code with the general
      `git_config_backend` and the specialized `diskfile_header`
      structures. At some occasions, it can get confusing though with
      regards to the correct inheritance structure, which led to the
      recent bug fixed in 2424e64c (config: harden our use of the
      backend objects a bit, 2018-02-28).
      
      Object-oriented programming in C is hard, but we can at least try
      to have some checks when it comes to casting around stuff. Thus,
      this commit introduces a `GIT_CONTAINER_OF` macro, which accepts
      as parameters the pointer that is to be casted, the pointer it
      should be cast to as well as the member inside of the target
      structure that is the containing structure. This macro then tries
      hard to detect mis-casts:
      
      - It checks whether the source and target pointers are of the
        same type. This requires support by the compiler, as it makes
        use of the builtin `__builtin_types_compatible_p`.
      
      - It checks whether the embedded member of the target structure
        is the first member. In order to make this a compile-time
        constant, the compiler-provided `__builtin_offsetof` is being
        used for this.
      
      - It ties these two checks together by the compiler-builtin
        `__builtin_choose_expr`. Based on whether the previous two
        checks evaluate to `true`, the compiler will either compile in
        the correct cast, or it will output `(void)0`. The second case
        results in a compiler error, resulting in a compile-time check
        for wrong casts.
      
      The only downside to this is that it relies heavily on
      compiler-specific extensions. As both GCC and Clang support these
      features, only define this macro like explained above in case
      `__GNUC__` is set (Clang also defines `__GNUC__`). If the
      compiler is not Clang or GCC, just go with a simple cast without
      any additional checks.
      Patrick Steinhardt committed
    • Merge pull request #5027 from ddevault/master · ed959ca2
      patch_parse.c: Handle CRLF in parse_header_start
      Patrick Steinhardt committed
  2. 07 Apr, 2019 4 commits
  3. 06 Apr, 2019 1 commit
  4. 05 Apr, 2019 1 commit
    • ignore: treat paths with trailing "/" as directories · 9d117e20
      The function `git_ignore_path_is_ignored` is there to test the
      ignore status of paths that need not necessarily exist inside of
      a repository. This has the implication that for a given path, we
      cannot always decide whether it references a directory or a file,
      and we need to distinguish those cases because ignore rules may
      treat those differently. E.g. given the following gitignore file:
      
          *
          !/**/
      
      we'd only want to unignore directories, while keeping files
      ignored. But still, calling `git_ignore_path_is_ignored("dir/")`
      will say that this directory is ignored because it treats "dir/"
      as a file path.
      
      As said, the `is_ignored` function cannot always decide whether
      the given path is a file or directory, and thus it may produce
      wrong results in some cases. While this is unfixable in the
      general case, we can do better when we are being passed a path
      name with a trailing path separator (e.g. "dir/") and always
      treat them as directories.
      Patrick Steinhardt committed
  5. 04 Apr, 2019 6 commits
  6. 29 Mar, 2019 11 commits
  7. 25 Mar, 2019 2 commits
  8. 23 Mar, 2019 1 commit
  9. 20 Mar, 2019 2 commits
  10. 15 Mar, 2019 1 commit
  11. 14 Mar, 2019 2 commits
  12. 06 Mar, 2019 1 commit
  13. 05 Mar, 2019 1 commit
  14. 02 Mar, 2019 2 commits