Skip to content
Snippets Groups Projects
  1. Sep 27, 2018
    • Junio C Hamano's avatar
    • Jeff King's avatar
      fsck: detect submodule paths starting with dash · 1a7fd1fb
      Jeff King authored
      
      As with urls, submodule paths with dashes are ignored by
      git, but may end up confusing older versions. Detecting them
      via fsck lets us prevent modern versions of git from being a
      vector to spread broken .gitmodules to older versions.
      
      Compared to blocking leading-dash urls, though, this
      detection may be less of a good idea:
      
        1. While such paths provide confusing and broken results,
           they don't seem to actually work as option injections
           against anything except "cd". In particular, the
           submodule code seems to canonicalize to an absolute
           path before running "git clone" (so it passes
           /your/clone/-sub).
      
        2. It's more likely that we may one day make such names
           actually work correctly. Even after we revert this fsck
           check, it will continue to be a hassle until hosting
           servers are all updated.
      
      On the other hand, it's not entirely clear that the behavior
      in older versions is safe. And if we do want to eventually
      allow this, we may end up doing so with a special syntax
      anyway (e.g., writing "./-sub" in the .gitmodules file, and
      teaching the submodule code to canonicalize it when
      comparing).
      
      So on balance, this is probably a good protection.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      1a7fd1fb
    • Jeff King's avatar
      fsck: detect submodule urls starting with dash · a124133e
      Jeff King authored
      
      Urls with leading dashes can cause mischief on older
      versions of Git. We should detect them so that they can be
      rejected by receive.fsckObjects, preventing modern versions
      of git from being a vector by which attacks can spread.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      a124133e
    • Junio C Hamano's avatar
      Sync with 2.16.5 · e43aab77
      Junio C Hamano authored
      * maint-2.16:
        Git 2.16.5
        Git 2.15.3
        Git 2.14.5
        submodule-config: ban submodule paths that start with a dash
        submodule-config: ban submodule urls that start with dash
        submodule--helper: use "--" to signal end of clone options
      e43aab77
    • Junio C Hamano's avatar
    • Junio C Hamano's avatar
      Sync with 2.15.3 · 424aac65
      Junio C Hamano authored
      * maint-2.15:
        Git 2.15.3
        Git 2.14.5
        submodule-config: ban submodule paths that start with a dash
        submodule-config: ban submodule urls that start with dash
        submodule--helper: use "--" to signal end of clone options
      424aac65
    • Junio C Hamano's avatar
    • Junio C Hamano's avatar
      Sync with Git 2.14.4 · 902df9f5
      Junio C Hamano authored
      * maint-2.14:
        Git 2.14.5
        submodule-config: ban submodule paths that start with a dash
        submodule-config: ban submodule urls that start with dash
        submodule--helper: use "--" to signal end of clone options
      902df9f5
    • Junio C Hamano's avatar
    • Jeff King's avatar
      submodule-config: ban submodule paths that start with a dash · 273c6149
      Jeff King authored
      
      We recently banned submodule urls that look like
      command-line options. This is the matching change to ban
      leading-dash paths.
      
      As with the urls, this should not break any use cases that
      currently work. Even with our "--" separator passed to
      git-clone, git-submodule.sh gets confused. Without the code
      portion of this patch, the clone of "-sub" added in t7417
      would yield results like:
      
          /path/to/git-submodule: 410: cd: Illegal option -s
          /path/to/git-submodule: 417: cd: Illegal option -s
          /path/to/git-submodule: 410: cd: Illegal option -s
          /path/to/git-submodule: 417: cd: Illegal option -s
          Fetched in submodule path '-sub', but it did not contain b56243f8f4eb91b2f1f8109452e659f14dd3fbe4. Direct fetching of that commit failed.
      
      Moreover, naively adding such a submodule doesn't work:
      
        $ git submodule add $url -sub
        The following path is ignored by one of your .gitignore files:
        -sub
      
      even though there is no such ignore pattern (the test script
      hacks around this with a well-placed "git mv").
      
      Unlike leading-dash urls, though, it's possible that such a
      path _could_ be useful if we eventually made it work. So
      this commit should be seen not as recommending a particular
      policy, but rather temporarily closing off a broken and
      possibly dangerous code-path. We may revisit this decision
      later.
      
      There are two minor differences to the tests in t7416 (that
      covered urls):
      
        1. We don't have a "./-sub" escape hatch to make this
           work, since the submodule code expects to be able to
           match canonical index names to the path field (so you
           are free to add submodule config with that path, but we
           would never actually use it, since an index entry would
           never start with "./").
      
        2. After this patch, cloning actually succeeds. Since we
           ignore the submodule.*.path value, we fail to find a
           config stanza for our submodule at all, and simply
           treat it as inactive. We still check for the "ignoring"
           message.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      273c6149
    • Jeff King's avatar
      submodule-config: ban submodule urls that start with dash · f6adec4e
      Jeff King authored
      
      The previous commit taught the submodule code to invoke our
      "git clone $url $path" with a "--" separator so that we
      aren't confused by urls or paths that start with dashes.
      
      However, that's just one code path. It's not clear if there
      are others, and it would be an easy mistake to add one in
      the future. Moreover, even with the fix in the previous
      commit, it's quite hard to actually do anything useful with
      such an entry. Any url starting with a dash must fall into
      one of three categories:
      
       - it's meant as a file url, like "-path". But then any
         clone is not going to have the matching path, since it's
         by definition relative inside the newly created clone. If
         you spell it as "./-path", the submodule code sees the
         "/" and translates this to an absolute path, so it at
         least works (assuming the receiver has the same
         filesystem layout as you). But that trick does not apply
         for a bare "-path".
      
       - it's meant as an ssh url, like "-host:path". But this
         already doesn't work, as we explicitly disallow ssh
         hostnames that begin with a dash (to avoid option
         injection against ssh).
      
       - it's a remote-helper scheme, like "-scheme::data". This
         _could_ work if the receiver bends over backwards and
         creates a funny-named helper like "git-remote--scheme".
         But normally there would not be any helper that matches.
      
      Since such a url does not work today and is not likely to do
      anything useful in the future, let's simply disallow them
      entirely. That protects the existing "git clone" path (in a
      belt-and-suspenders way), along with any others that might
      exist.
      
      Our tests cover two cases:
      
        1. A file url with "./" continues to work, showing that
           there's an escape hatch for people with truly silly
           repo names.
      
        2. A url starting with "-" is rejected.
      
      Note that we expect case (2) to fail, but it would have done
      so even without this commit, for the reasons given above.
      So instead of just expecting failure, let's also check for
      the magic word "ignoring" on stderr. That lets us know that
      we failed for the right reason.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      f6adec4e
    • Jeff King's avatar
      submodule--helper: use "--" to signal end of clone options · 98afac7a
      Jeff King authored
      
      When we clone a submodule, we call "git clone $url $path".
      But there's nothing to say that those components can't begin
      with a dash themselves, confusing git-clone into thinking
      they're options. Let's pass "--" to make it clear what we
      expect.
      
      There's no test here, because it's actually quite hard to
      make these names work, even with "git clone" parsing them
      correctly. And we're going to restrict these cases even
      further in future commits. So we'll leave off testing until
      then; this is just the minimal fix to prevent us from doing
      something stupid with a badly formed entry.
      
      Reported-by: default avatarjoernchen <joernchen@phenoelit.de>
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      98afac7a
  2. May 22, 2018
    • Junio C Hamano's avatar
    • Junio C Hamano's avatar
      Merge branch 'jk/submodule-fsck-loose' into maint · 9e84a6d7
      Junio C Hamano authored
      * jk/submodule-fsck-loose:
        fsck: complain when .gitmodules is a symlink
        index-pack: check .gitmodules files with --strict
        unpack-objects: call fsck_finish() after fscking objects
        fsck: call fsck_finish() after fscking objects
        fsck: check .gitmodules content
        fsck: handle promisor objects in .gitmodules check
        fsck: detect gitmodules files
        fsck: actually fsck blob data
        fsck: simplify ".git" check
        index-pack: make fsck error message more specific
      9e84a6d7
    • Junio C Hamano's avatar
      Sync with Git 2.16.4 · 68f95b26
      Junio C Hamano authored
      * maint-2.16:
        Git 2.16.4
        Git 2.15.2
        Git 2.14.4
        Git 2.13.7
        verify_path: disallow symlinks in .gitmodules
        update-index: stat updated files earlier
        verify_dotfile: mention case-insensitivity in comment
        verify_path: drop clever fallthrough
        skip_prefix: add case-insensitive variant
        is_{hfs,ntfs}_dotgitmodules: add tests
        is_ntfs_dotgit: match other .git files
        is_hfs_dotgit: match other .git files
        is_ntfs_dotgit: use a size_t for traversing string
        submodule-config: verify submodule names as paths
      68f95b26
    • Junio C Hamano's avatar
    • Junio C Hamano's avatar
      Sync with Git 2.15.2 · 02302040
      Junio C Hamano authored
      * maint-2.15:
        Git 2.15.2
        Git 2.14.4
        Git 2.13.7
        verify_path: disallow symlinks in .gitmodules
        update-index: stat updated files earlier
        verify_dotfile: mention case-insensitivity in comment
        verify_path: drop clever fallthrough
        skip_prefix: add case-insensitive variant
        is_{hfs,ntfs}_dotgitmodules: add tests
        is_ntfs_dotgit: match other .git files
        is_hfs_dotgit: match other .git files
        is_ntfs_dotgit: use a size_t for traversing string
        submodule-config: verify submodule names as paths
      02302040
    • Junio C Hamano's avatar
    • Junio C Hamano's avatar
      Sync with Git 2.14.4 · 9e0f06d5
      Junio C Hamano authored
      * maint-2.14:
        Git 2.14.4
        Git 2.13.7
        verify_path: disallow symlinks in .gitmodules
        update-index: stat updated files earlier
        verify_dotfile: mention case-insensitivity in comment
        verify_path: drop clever fallthrough
        skip_prefix: add case-insensitive variant
        is_{hfs,ntfs}_dotgitmodules: add tests
        is_ntfs_dotgit: match other .git files
        is_hfs_dotgit: match other .git files
        is_ntfs_dotgit: use a size_t for traversing string
        submodule-config: verify submodule names as paths
      9e0f06d5
    • Junio C Hamano's avatar
    • Junio C Hamano's avatar
      Sync with Git 2.13.7 · 7b01c71b
      Junio C Hamano authored
      * maint-2.13:
        Git 2.13.7
        verify_path: disallow symlinks in .gitmodules
        update-index: stat updated files earlier
        verify_dotfile: mention case-insensitivity in comment
        verify_path: drop clever fallthrough
        skip_prefix: add case-insensitive variant
        is_{hfs,ntfs}_dotgitmodules: add tests
        is_ntfs_dotgit: match other .git files
        is_hfs_dotgit: match other .git files
        is_ntfs_dotgit: use a size_t for traversing string
        submodule-config: verify submodule names as paths
      7b01c71b
    • Junio C Hamano's avatar
    • Junio C Hamano's avatar
      Merge branch 'jk/submodule-fix-loose' into maint-2.13 · 8528c31d
      Junio C Hamano authored
      * jk/submodule-fix-loose:
        verify_path: disallow symlinks in .gitmodules
        update-index: stat updated files earlier
        verify_dotfile: mention case-insensitivity in comment
        verify_path: drop clever fallthrough
        skip_prefix: add case-insensitive variant
        is_{hfs,ntfs}_dotgitmodules: add tests
        is_ntfs_dotgit: match other .git files
        is_hfs_dotgit: match other .git files
        is_ntfs_dotgit: use a size_t for traversing string
        submodule-config: verify submodule names as paths
      8528c31d
    • Jeff King's avatar
      fsck: complain when .gitmodules is a symlink · b7b1fca1
      Jeff King authored
      
      We've recently forbidden .gitmodules to be a symlink in
      verify_path(). And it's an easy way to circumvent our fsck
      checks for .gitmodules content. So let's complain when we
      see it.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      b7b1fca1
    • Jeff King's avatar
      index-pack: check .gitmodules files with --strict · 73c3f0f7
      Jeff King authored
      
      Now that the internal fsck code has all of the plumbing we
      need, we can start checking incoming .gitmodules files.
      Naively, it seems like we would just need to add a call to
      fsck_finish() after we've processed all of the objects. And
      that would be enough to cover the initial test included
      here. But there are two extra bits:
      
        1. We currently don't bother calling fsck_object() at all
           for blobs, since it has traditionally been a noop. We'd
           actually catch these blobs in fsck_finish() at the end,
           but it's more efficient to check them when we already
           have the object loaded in memory.
      
        2. The second pass done by fsck_finish() needs to access
           the objects, but we're actually indexing the pack in
           this process. In theory we could give the fsck code a
           special callback for accessing the in-pack data, but
           it's actually quite tricky:
      
             a. We don't have an internal efficient index mapping
      	  oids to packfile offsets. We only generate it on
      	  the fly as part of writing out the .idx file.
      
             b. We'd still have to reconstruct deltas, which means
                we'd basically have to replicate all of the
      	  reading logic in packfile.c.
      
           Instead, let's avoid running fsck_finish() until after
           we've written out the .idx file, and then just add it
           to our internal packed_git list.
      
           This does mean that the objects are "in the repository"
           before we finish our fsck checks. But unpack-objects
           already exhibits this same behavior, and it's an
           acceptable tradeoff here for the same reason: the
           quarantine mechanism means that pushes will be
           fully protected.
      
      In addition to a basic push test in t7415, we add a sneaky
      pack that reverses the usual object order in the pack,
      requiring that index-pack access the tree and blob during
      the "finish" step.
      
      This already works for unpack-objects (since it will have
      written out loose objects), but we'll check it with this
      sneaky pack for good measure.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      73c3f0f7
    • Jeff King's avatar
      unpack-objects: call fsck_finish() after fscking objects · 6e328d6c
      Jeff King authored
      
      As with the previous commit, we must call fsck's "finish"
      function in order to catch any queued objects for
      .gitmodules checks.
      
      This second pass will be able to access any incoming
      objects, because we will have exploded them to loose objects
      by now.
      
      This isn't quite ideal, because it means that bad objects
      may have been written to the object database (and a
      subsequent operation could then reference them, even if the
      other side doesn't send the objects again). However, this is
      sufficient when used with receive.fsckObjects, since those
      loose objects will all be placed in a temporary quarantine
      area that will get wiped if we find any problems.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      6e328d6c
    • Jeff King's avatar
      fsck: call fsck_finish() after fscking objects · 1995b5e0
      Jeff King authored
      
      Now that the internal fsck code is capable of checking
      .gitmodules files, we just need to teach its callers to use
      the "finish" function to check any queued objects.
      
      With this, we can now catch the malicious case in t7415 with
      git-fsck.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      1995b5e0
    • Jeff King's avatar
      fsck: check .gitmodules content · ed8b10f6
      Jeff King authored
      
      This patch detects and blocks submodule names which do not
      match the policy set forth in submodule-config. These should
      already be caught by the submodule code itself, but putting
      the check here means that newer versions of Git can protect
      older ones from malicious entries (e.g., a server with
      receive.fsckObjects will block the objects, protecting
      clients which fetch from it).
      
      As a side effect, this means fsck will also complain about
      .gitmodules files that cannot be parsed (or were larger than
      core.bigFileThreshold).
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      ed8b10f6
    • Jeff King's avatar
      fsck: handle promisor objects in .gitmodules check · 27387444
      Jeff King authored
      
      If we have a tree that points to a .gitmodules blob but
      don't have that blob, we can't check its contents. This
      produces an fsck error when we encounter it.
      
      But in the case of a promisor object, this absence is
      expected, and we must not complain.  Note that this can
      technically circumvent our transfer.fsckObjects check.
      Imagine a client fetches a tree, but not the matching
      .gitmodules blob. An fsck of the incoming objects will show
      that we don't have enough information. Later, we do fetch
      the actual blob. But we have no idea that it's a .gitmodules
      file.
      
      The only ways to get around this would be to re-scan all of
      the existing trees whenever new ones enter (which is
      expensive), or to somehow persist the gitmodules_found set
      between fsck runs (which is complicated).
      
      In practice, it's probably OK to ignore the problem. Any
      repository which has all of the objects (including the one
      serving the promisor packs) can perform the checks. Since
      promisor packs are inherently about a hierarchical topology
      in which clients rely on upstream repositories, those
      upstream repositories can protect all of their downstream
      clients from broken objects.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      27387444
    • Jeff King's avatar
      fsck: detect gitmodules files · 159e7b08
      Jeff King authored
      
      In preparation for performing fsck checks on .gitmodules
      files, this commit plumbs in the actual detection of the
      files. Note that unlike most other fsck checks, this cannot
      be a property of a single object: we must know that the
      object is found at a ".gitmodules" path at the root tree of
      a commit.
      
      Since the fsck code only sees one object at a time, we have
      to mark the related objects to fit the puzzle together. When
      we see a commit we mark its tree as a root tree, and when
      we see a root tree with a .gitmodules file, we mark the
      corresponding blob to be checked.
      
      In an ideal world, we'd check the objects in topological
      order: commits followed by trees followed by blobs. In that
      case we can avoid ever loading an object twice, since all
      markings would be complete by the time we get to the marked
      objects. And indeed, if we are checking a single packfile,
      this is the order in which Git will generally write the
      objects. But we can't count on that:
      
        1. git-fsck may show us the objects in arbitrary order
           (loose objects are fed in sha1 order, but we may also
           have multiple packs, and we process each pack fully in
           sequence).
      
        2. The type ordering is just what git-pack-objects happens
           to write now. The pack format does not require a
           specific order, and it's possible that future versions
           of Git (or a custom version trying to fool official
           Git's fsck checks!) may order it differently.
      
        3. We may not even be fscking all of the relevant objects
           at once. Consider pushing with transfer.fsckObjects,
           where one push adds a blob at path "foo", and then a
           second push adds the same blob at path ".gitmodules".
           The blob is not part of the second push at all, but we
           need to mark and check it.
      
      So in the general case, we need to make up to three passes
      over the objects: once to make sure we've seen all commits,
      then once to cover any trees we might have missed, and then
      a final pass to cover any .gitmodules blobs we found in the
      second pass.
      
      We can simplify things a bit by loosening the requirement
      that we find .gitmodules only at root trees. Technically
      a file like "subdir/.gitmodules" is not parsed by Git, but
      it's not unreasonable for us to declare that Git is aware of
      all ".gitmodules" files and make them eligible for checking.
      That lets us drop the root-tree requirement, which
      eliminates one pass entirely. And it makes our worst case
      much better: instead of potentially queueing every root tree
      to be re-examined, the worst case is that we queue each
      unique .gitmodules blob for a second look.
      
      This patch just adds the boilerplate to find .gitmodules
      files. The actual content checks will come in a subsequent
      commit.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      159e7b08
    • Jeff King's avatar
      fsck: actually fsck blob data · 7ac4f3a0
      Jeff King authored
      
      Because fscking a blob has always been a noop, we didn't
      bother passing around the blob data. In preparation for
      content-level checks, let's fix up a few things:
      
        1. The fsck_object() function just returns success for any
           blob. Let's a noop fsck_blob(), which we can fill in
           with actual logic later.
      
        2. The fsck_loose() function in builtin/fsck.c
           just threw away blob content after loading it. Let's
           hold onto it until after we've called fsck_object().
      
           The easiest way to do this is to just drop the
           parse_loose_object() helper entirely. Incidentally,
           this also fixes a memory leak: if we successfully
           loaded the object data but did not parse it, we would
           have left the function without freeing it.
      
        3. When fsck_loose() loads the object data, it
           does so with a custom read_loose_object() helper. This
           function streams any blobs, regardless of size, under
           the assumption that we're only checking the sha1.
      
           Instead, let's actually load blobs smaller than
           big_file_threshold, as the normal object-reading
           code-paths would do. This lets us fsck small files, and
           a NULL return is an indication that the blob was so big
           that it needed to be streamed, and we can pass that
           information along to fsck_blob().
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      7ac4f3a0
    • Jeff King's avatar
      fsck: simplify ".git" check · ed9c3220
      Jeff King authored
      
      There's no need for us to manually check for ".git"; it's a
      subset of the other filesystem-specific tests. Dropping it
      makes our code slightly shorter. More importantly, the
      existing code may make a reader wonder why ".GIT" is not
      covered here, and whether that is a bug (it isn't, as it's
      also covered in the filesystem-specific tests).
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      ed9c3220
    • Jeff King's avatar
      index-pack: make fsck error message more specific · db5a58c1
      Jeff King authored
      
      If fsck reports an error, we say only "Error in object".
      This isn't quite as bad as it might seem, since the fsck
      code would have dumped some errors to stderr already. But it
      might help to give a little more context. The earlier output
      would not have even mentioned "fsck", and that may be a clue
      that the "fsck.*" or "*.fsckObjects" config may be relevant.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      db5a58c1
    • Jeff King's avatar
      Merge branch 'jk/submodule-name-verify-fix' into jk/submodule-name-verify-fsck · eedd5949
      Jeff King authored
      * jk/submodule-name-verify-fix:
        verify_path: disallow symlinks in .gitmodules
        update-index: stat updated files earlier
        verify_path: drop clever fallthrough
        skip_prefix: add icase-insensitive variant
        is_{hfs,ntfs}_dotgitmodules: add tests
        path: match NTFS short names for more .git files
        is_hfs_dotgit: match other .git files
        is_ntfs_dotgit: use a size_t for traversing string
        submodule-config: verify submodule names as paths
      
      Note that this includes two bits of evil-merge:
      
       - there's a new call to verify_path() that doesn't actually
         have a mode available. It should be OK to pass "0" here,
         since we're just manipulating the untracked cache, not an
         actual index entry.
      
       - the lstat() in builtin/update-index.c:update_one() needs
         to be updated to handle the fsmonitor case (without this
         it still behaves correctly, but does an unnecessary
         lstat).
      eedd5949
    • Jeff King's avatar
      verify_path: disallow symlinks in .gitmodules · 10ecfa76
      Jeff King authored
      
      There are a few reasons it's not a good idea to make
      .gitmodules a symlink, including:
      
        1. It won't be portable to systems without symlinks.
      
        2. It may behave inconsistently, since Git may look at
           this file in the index or a tree without bothering to
           resolve any symbolic links. We don't do this _yet_, but
           the config infrastructure is there and it's planned for
           the future.
      
      With some clever code, we could make (2) work. And some
      people may not care about (1) if they only work on one
      platform. But there are a few security reasons to simply
      disallow it:
      
        a. A symlinked .gitmodules file may circumvent any fsck
           checks of the content.
      
        b. Git may read and write from the on-disk file without
           sanity checking the symlink target. So for example, if
           you link ".gitmodules" to "../oops" and run "git
           submodule add", we'll write to the file "oops" outside
           the repository.
      
      Again, both of those are problems that _could_ be solved
      with sufficient code, but given the complications in (1) and
      (2), we're better off just outlawing it explicitly.
      
      Note the slightly tricky call to verify_path() in
      update-index's update_one(). There we may not have a mode if
      we're not updating from the filesystem (e.g., we might just
      be removing the file). Passing "0" as the mode there works
      fine; since it's not a symlink, we'll just skip the extra
      checks.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      10ecfa76
    • Jeff King's avatar
      update-index: stat updated files earlier · eb12dd0c
      Jeff King authored
      
      In the update_one(), we check verify_path() on the proposed
      path before doing anything else. In preparation for having
      verify_path() look at the file mode, let's stat the file
      earlier, so we can check the mode accurately.
      
      This is made a bit trickier by the fact that this function
      only does an lstat in a few code paths (the ones that flow
      down through process_path()). So we can speculatively do the
      lstat() here and pass the results down, and just use a dummy
      mode for cases where we won't actually be updating the index
      from the filesystem.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      eb12dd0c
    • Jeff King's avatar
      verify_dotfile: mention case-insensitivity in comment · 641084b6
      Jeff King authored
      
      We're more restrictive than we need to be in matching ".GIT"
      on case-sensitive filesystems; let's make a note that this
      is intentional.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      641084b6
    • Jeff King's avatar
      verify_path: drop clever fallthrough · e19e5e66
      Jeff King authored
      
      We check ".git" and ".." in the same switch statement, and
      fall through the cases to share the end-of-component check.
      While this saves us a line or two, it makes modifying the
      function much harder. Let's just write it out.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      e19e5e66
    • Jeff King's avatar
      skip_prefix: add case-insensitive variant · 41a80924
      Jeff King authored
      
      We have the convenient skip_prefix() helper, but if you want
      to do case-insensitive matching, you're stuck doing it by
      hand. We could add an extra parameter to the function to
      let callers ask for this, but the function is small and
      somewhat performance-critical. Let's just re-implement it
      for the case-insensitive version.
      
      Signed-off-by: default avatarJeff King <peff@peff.net>
      41a80924
    • Johannes Schindelin's avatar
      is_{hfs,ntfs}_dotgitmodules: add tests · dc2d9ba3
      Johannes Schindelin authored
      
      This tests primarily for NTFS issues, but also adds one example of an
      HFS+ issue.
      
      Thanks go to Congyi Wu for coming up with the list of examples where
      NTFS would possibly equate the filename with `.gitmodules`.
      
      Signed-off-by: default avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: default avatarJeff King <peff@peff.net>
      dc2d9ba3
Loading