1. 23 6月, 2020 2 次提交
  2. 11 6月, 2020 6 次提交
    • E
      worktree: make "move" refuse to move atop missing registered worktree · 810382ed
      Eric Sunshine 提交于
      "git worktree add" takes special care to avoid creating a new worktree
      at a location already registered to an existing worktree even if that
      worktree is missing (which can happen, for instance, if the worktree
      resides on removable media). "git worktree move", however, is not so
      careful when validating the destination location and will happily move
      the source worktree atop the location of a missing worktree. This leads
      to the anomalous situation of multiple worktrees being associated with
      the same path, which is expressly forbidden by design. For example:
      
          $ git clone foo.git
          $ cd foo
          $ git worktree add ../bar
          $ git worktree add ../baz
          $ rm -rf ../bar
          $ git worktree move ../baz ../bar
          $ git worktree list
          .../foo beefd00f [master]
          .../bar beefd00f [bar]
          .../bar beefd00f [baz]
          $ git worktree remove ../bar
          fatal: validation failed, cannot remove working tree:
              '.../bar' does not point back to '.git/worktrees/bar'
      
      Fix this shortcoming by enhancing "git worktree move" to perform the
      same additional validation of the destination directory as done by "git
      worktree add".
      
      While at it, add a test to verify that "git worktree move" won't move a
      worktree atop an existing (non-worktree) path -- a restriction which has
      always been in place but was never tested.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      810382ed
    • E
      worktree: generalize candidate worktree path validation · d179af67
      Eric Sunshine 提交于
      "git worktree add" checks that the specified path is a valid location
      for a new worktree by ensuring that the path does not already exist and
      is not already registered to another worktree (a path can be registered
      but missing, for instance, if it resides on removable media). Since "git
      worktree add" is not the only command which should perform such
      validation ("git worktree move" ought to also), generalize the the
      validation function for use by other callers, as well.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d179af67
    • E
      worktree: prune linked worktree referencing main worktree path · 916133ef
      Eric Sunshine 提交于
      "git worktree prune" detects when multiple entries are associated with
      the same path and prunes the duplicates, however, it does not detect
      when a linked worktree points at the path of the main worktree.
      Although "git worktree add" disallows creating a new worktree with the
      same path as the main worktree, such a case can arise outside the
      control of Git even without the user mucking with .git/worktree/<id>/
      administrative files. For instance:
      
          $ git clone foo.git
          $ git -C foo worktree add ../bar
          $ rm -rf bar
          $ mv foo bar
          $ git -C bar worktree list
          .../bar deadfeeb [master]
          .../bar deadfeeb [bar]
      
      Help the user recover from such corruption by extending "git worktree
      prune" to also detect when a linked worktree is associated with the path
      of the main worktree.
      Reported-by: NJonathan Müller <jonathanmueller.dev@gmail.com>
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      916133ef
    • E
      worktree: prune duplicate entries referencing same worktree path · 4a3ce479
      Eric Sunshine 提交于
      A fundamental restriction of linked working trees is that there must
      only ever be a single worktree associated with a particular path, thus
      "git worktree add" explicitly disallows creation of a new worktree at
      the same location as an existing registered worktree. Nevertheless,
      users can still "shoot themselves in the foot" by mucking with
      administrative files in .git/worktree/<id>/. Worse, "git worktree move"
      is careless[1] and allows a worktree to be moved atop a registered but
      missing worktree (which can happen, for instance, if the worktree is on
      removable media). For instance:
      
          $ git clone foo.git
          $ cd foo
          $ git worktree add ../bar
          $ git worktree add ../baz
          $ rm -rf ../bar
          $ git worktree move ../baz ../bar
          $ git worktree list
          .../foo beefd00f [master]
          .../bar beefd00f [bar]
          .../bar beefd00f [baz]
      
      Help users recover from this form of corruption by teaching "git
      worktree prune" to detect when multiple worktrees are associated with
      the same path.
      
      [1]: A subsequent commit will fix "git worktree move" validation to be
           more strict.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4a3ce479
    • E
      worktree: make high-level pruning re-usable · dd9609a1
      Eric Sunshine 提交于
      The low-level logic for removing a worktree is well encapsulated in
      delete_git_dir(). However, high-level details related to pruning a
      worktree -- such as dealing with verbosity and dry-run mode -- are not
      encapsulated. Factor out this high-level logic into its own function so
      it can be re-used as new worktree corruption detectors are added.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dd9609a1
    • E
      worktree: give "should be pruned?" function more meaningful name · 1b14d40b
      Eric Sunshine 提交于
      Readers of the name prune_worktree() are likely to expect the function
      to actually prune a worktree, however, it only answers the question
      "should this worktree be pruned?". Give it a name more reflective of its
      true purpose to avoid such confusion.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1b14d40b
  3. 09 6月, 2020 1 次提交
    • E
      worktree: factor out repeated string literal · c9b77f2c
      Eric Sunshine 提交于
      For each worktree removed by "git worktree prune", it reports the reason
      for the removal. All reasons share the common prefix "Removing
      worktrees/%s:". As new removal reasons are added, this prefix needs to
      be duplicated, which is error-prone and potentially cumbersome.
      Therefore, factor out the common prefix.
      
      Although this change seems to increase the "sentence lego quotient", it
      should be reasonably safe, as the reason for removal is a distinct
      clause, not strictly related to the prefix. Moreover, the "worktrees" in
      "Removing worktrees/%s:" is a path literal which ought not be localized,
      so by factoring it out, we can more easily avoid exposing that path
      fragment to translators.
      Signed-off-by: NEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c9b77f2c
  4. 20 4月, 2020 19 次提交
    • J
      Git 2.26.2 · af6b65d4
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      af6b65d4
    • J
      Git 2.25.4 · 7397ca33
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      7397ca33
    • J
      Git 2.24.3 · b86a4be2
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      b86a4be2
    • J
      Git 2.23.3 · f2771efd
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      f2771efd
    • J
      Git 2.22.4 · c9808fa0
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      c9808fa0
    • J
      Git 2.21.3 · 9206d27e
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      9206d27e
    • J
      Git 2.20.4 · 041bc659
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      041bc659
    • J
      Git 2.19.5 · 76b54ee9
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      76b54ee9
    • J
      Git 2.18.4 · ba6f0905
      Jonathan Nieder 提交于
      This merges up the security fix from v2.17.5.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      ba6f0905
    • J
      Git 2.17.5 · df5be6dc
      Jeff King 提交于
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      df5be6dc
    • J
      fsck: reject URL with empty host in .gitmodules · 1a3609e4
      Jonathan Nieder 提交于
      Git's URL parser interprets
      
      	https:///example.com/repo.git
      
      to have no host and a path of "example.com/repo.git".  Curl, on the
      other hand, internally redirects it to https://example.com/repo.git.  As
      a result, until "credential: parse URL without host as empty host, not
      unset", tricking a user into fetching from such a URL would cause Git to
      send credentials for another host to example.com.
      
      Teach fsck to block and detect .gitmodules files using such a URL to
      prevent sharing them with Git versions that are not yet protected.
      
      A relative URL in a .gitmodules file could also be used to trigger this.
      The relative URL resolver used for .gitmodules does not normalize
      sequences of slashes and can follow ".." components out of the path part
      and to the host part of a URL, meaning that such a relative URL can be
      used to traverse from a https://foo.example.com/innocent superproject to
      a https:///attacker.example.com/exploit submodule. Fortunately,
      redundant extra slashes in .gitmodules are rare, so we can catch this by
      detecting one after a leading sequence of "./" and "../" components.
      Helped-by: NJeff King <peff@peff.net>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Reviewed-by: NJeff King <peff@peff.net>
      1a3609e4
    • J
      credential: treat URL with empty scheme as invalid · e7fab62b
      Jonathan Nieder 提交于
      Until "credential: refuse to operate when missing host or protocol",
      Git's credential handling code interpreted URLs with empty scheme to
      mean "give me credentials matching this host for any protocol".
      
      Luckily libcurl does not recognize such URLs (it tries to look for a
      protocol named "" and fails). Just in case that changes, let's reject
      them within Git as well. This way, credential_from_url is guaranteed to
      always produce a "struct credential" with protocol and host set.
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      e7fab62b
    • J
      credential: treat URL without scheme as invalid · c44088ec
      Jonathan Nieder 提交于
      libcurl permits making requests without a URL scheme specified.  In
      this case, it guesses the URL from the hostname, so I can run
      
      	git ls-remote http::ftp.example.com/path/to/repo
      
      and it would make an FTP request.
      
      Any user intentionally using such a URL is likely to have made a typo.
      Unfortunately, credential_from_url is not able to determine the host and
      protocol in order to determine appropriate credentials to send, and
      until "credential: refuse to operate when missing host or protocol",
      this resulted in another host's credentials being leaked to the named
      host.
      
      Teach credential_from_url_gently to consider such a URL to be invalid
      so that fsck can detect and block gitmodules files with such URLs,
      allowing server operators to avoid serving them to downstream users
      running older versions of Git.
      
      This also means that when such URLs are passed on the command line, Git
      will print a clearer error so affected users can switch to the simpler
      URL that explicitly specifies the host and protocol they intend.
      
      One subtlety: .gitmodules files can contain relative URLs, representing
      a URL relative to the URL they were cloned from.  The relative URL
      resolver used for .gitmodules can follow ".." components out of the path
      part and past the host part of a URL, meaning that such a relative URL
      can be used to traverse from a https://foo.example.com/innocent
      superproject to a https::attacker.example.com/exploit submodule.
      Fortunately a leading ':' in the first path component after a series of
      leading './' and '../' components is unlikely to show up in other
      contexts, so we can catch this by detecting that pattern.
      Reported-by: NJeff King <peff@peff.net>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Reviewed-by: NJeff King <peff@peff.net>
      c44088ec
    • J
      credential: die() when parsing invalid urls · fe29a9b7
      Jeff King 提交于
      When we try to initialize credential loading by URL and find that the
      URL is invalid, we set all fields to NULL in order to avoid acting on
      malicious input. Later when we request credentials, we diagonse the
      erroneous input:
      
      	fatal: refusing to work with credential missing host field
      
      This is problematic in two ways:
      
      - The message doesn't tell the user *why* we are missing the host
        field, so they can't tell from this message alone how to recover.
        There can be intervening messages after the original warning of
        bad input, so the user may not have the context to put two and two
        together.
      
      - The error only occurs when we actually need to get a credential.  If
        the URL permits anonymous access, the only encouragement the user gets
        to correct their bogus URL is a quiet warning.
      
        This is inconsistent with the check we perform in fsck, where any use
        of such a URL as a submodule is an error.
      
      When we see such a bogus URL, let's not try to be nice and continue
      without helpers. Instead, die() immediately. This is simpler and
      obviously safe. And there's very little chance of disrupting a normal
      workflow.
      
      It's _possible_ that somebody has a legitimate URL with a raw newline in
      it. It already wouldn't work with credential helpers, so this patch
      steps that up from an inconvenience to "we will refuse to work with it
      at all". If such a case does exist, we should figure out a way to work
      with it (especially if the newline is only in the path component, which
      we normally don't even pass to helpers). But until we see a real report,
      we're better off being defensive.
      Reported-by: NCarlo Arenas <carenas@gmail.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      fe29a9b7
    • J
      fsck: convert gitmodules url to URL passed to curl · a2b26ffb
      Jonathan Nieder 提交于
      In 07259e74 (fsck: detect gitmodules URLs with embedded newlines,
      2020-03-11), git fsck learned to check whether URLs in .gitmodules could
      be understood by the credential machinery when they are handled by
      git-remote-curl.
      
      However, the check is overbroad: it checks all URLs instead of only
      URLs that would be passed to git-remote-curl. In principle a git:// or
      file:/// URL does not need to follow the same conventions as an http://
      URL; in particular, git:// and file:// protocols are not succeptible to
      issues in the credential API because they do not support attaching
      credentials.
      
      In the HTTP case, the URL in .gitmodules does not always match the URL
      that would be passed to git-remote-curl and the credential machinery:
      Git's URL syntax allows specifying a remote helper followed by a "::"
      delimiter and a URL to be passed to it, so that
      
      	git ls-remote http::https://example.com/repo.git
      
      invokes git-remote-http with https://example.com/repo.git as its URL
      argument. With today's checks, that distinction does not make a
      difference, but for a check we are about to introduce (for empty URL
      schemes) it will matter.
      
      .gitmodules files also support relative URLs. To ensure coverage for the
      https based embedded-newline attack, urldecode and check them directly
      for embedded newlines.
      Helped-by: NJeff King <peff@peff.net>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Reviewed-by: NJeff King <peff@peff.net>
      a2b26ffb
    • J
      credential: refuse to operate when missing host or protocol · 8ba8ed56
      Jeff King 提交于
      The credential helper protocol was designed to be very flexible: the
      fields it takes as input are treated as a pattern, and any missing
      fields are taken as wildcards. This allows unusual things like:
      
        echo protocol=https | git credential reject
      
      to delete all stored https credentials (assuming the helpers themselves
      treat the input that way). But when helpers are invoked automatically by
      Git, this flexibility works against us. If for whatever reason we don't
      have a "host" field, then we'd match _any_ host. When you're filling a
      credential to send to a remote server, this is almost certainly not what
      you want.
      
      Prevent this at the layer that writes to the credential helper. Add a
      check to the credential API that the host and protocol are always passed
      in, and add an assertion to the credential_write function that speaks
      credential helper protocol to be doubly sure.
      
      There are a few ways this can be triggered in practice:
      
        - the "git credential" command passes along arbitrary credential
          parameters it reads from stdin.
      
        - until the previous patch, when the host field of a URL is empty, we
          would leave it unset (rather than setting it to the empty string)
      
        - a URL like "example.com/foo.git" is treated by curl as if "http://"
          was present, but our parser sees it as a non-URL and leaves all
          fields unset
      
        - the recent fix for URLs with embedded newlines blanks the URL but
          otherwise continues. Rather than having the desired effect of
          looking up no credential at all, many helpers will return _any_
          credential
      
      Our earlier test for an embedded newline didn't catch this because it
      only checked that the credential was cleared, but didn't configure an
      actual helper. Configuring the "verbatim" helper in the test would show
      that it is invoked (it's obviously a silly helper which doesn't look at
      its input, but the point is that it shouldn't be run at all). Since
      we're switching this case to die(), we don't need to bother with a
      helper. We can see the new behavior just by checking that the operation
      fails.
      
      We'll add new tests covering partial input as well (these can be
      triggered through various means with url-parsing, but it's simpler to
      just check them directly, as we know we are covered even if the url
      parser changes behavior in the future).
      
      [jn: changed to die() instead of logging and showing a manual
       username/password prompt]
      Reported-by: NCarlo Arenas <carenas@gmail.com>
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      8ba8ed56
    • J
      credential: parse URL without host as empty host, not unset · 24036686
      Jeff King 提交于
      We may feed a URL like "cert:///path/to/cert.pem" into the credential
      machinery to get the key for a client-side certificate. That
      credential has no hostname field, which is about to be disallowed (to
      avoid confusion with protocols where a helper _would_ expect a
      hostname).
      
      This means as of the next patch, credential helpers won't work for
      unlocking certs. Let's fix that by doing two things:
      
        - when we parse a url with an empty host, set the host field to the
          empty string (asking only to match stored entries with an empty
          host) rather than NULL (asking to match _any_ host).
      
        - when we build a cert:// credential by hand, similarly assign an
          empty string
      
      It's the latter that is more likely to impact real users in practice,
      since it's what's used for http connections. But we don't have good
      infrastructure to test it.
      
      The url-parsing version will help anybody using git-credential in a
      script, and is easy to test.
      Signed-off-by: NJeff King <peff@peff.net>
      Reviewed-by: NTaylor Blau <me@ttaylorr.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      24036686
    • J
      t0300: use more realistic inputs · 73aafe9b
      Jeff King 提交于
      Many of the tests in t0300 give partial inputs to git-credential,
      omitting a protocol or hostname. We're checking only high-level things
      like whether and how helpers are invoked at all, and we don't care about
      specific hosts. However, in preparation for tightening up the rules
      about when we're willing to run a helper, let's start using input that's
      a bit more realistic: pretend as if http://example.com is being
      examined.
      
      This shouldn't change the point of any of the tests, but do note we have
      to adjust the expected output to accommodate this (filling a credential
      will repeat back the protocol/host fields to stdout, and the helper
      debug messages and askpass prompt will change on stderr).
      Signed-off-by: NJeff King <peff@peff.net>
      Reviewed-by: NTaylor Blau <me@ttaylorr.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      73aafe9b
    • J
      t0300: make "quit" helper more realistic · a88dbd2f
      Jeff King 提交于
      We test a toy credential helper that writes "quit=1" and confirms that
      we stop running other helpers. However, that helper is unrealistic in
      that it does not bother to read its stdin at all.
      
      For now we don't send any input to it, because we feed git-credential a
      blank credential. But that will change in the next patch, which will
      cause this test to racily fail, as git-credential will get SIGPIPE
      writing to the helper rather than exiting because it was asked to.
      
      Let's make this one-off helper more like our other sample helpers, and
      have it source the "dump" script. That will read stdin, fixing the
      SIGPIPE problem. But it will also write what it sees to stderr. We can
      make the test more robust by checking that output, which confirms that
      we do run the quit helper, don't run any other helpers, and exit for the
      reason we expected.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      a88dbd2f
  5. 26 3月, 2020 1 次提交
  6. 23 3月, 2020 1 次提交
  7. 22 3月, 2020 2 次提交
    • J
      Merge branch 'en/rebase-backend' · 55a75686
      Junio C Hamano 提交于
      Test fix.
      
      * en/rebase-backend:
        t3419: prevent failure when run with EXPENSIVE
      55a75686
    • J
      Merge tag 'l10n-2.26.0-rnd2.1' of git://github.com/git-l10n/git-po.git · c452dfa3
      Junio C Hamano 提交于
      l10n-2.26.0-rnd2.1
      
      * tag 'l10n-2.26.0-rnd2.1' of https://github.com/git-l10n/git-po: (28 commits)
        l10n: tr.po: change file mode to 644
        l10n: de.po: Update German translation for Git 2.26.0
        l10n: de.po: add missing space
        l10n: tr: Fix a couple of ambiguities
        l10n: Update Catalan translation
        l10n: sv.po: Update Swedish translation (4839t0f0u)
        l10n: zh_CN: Revise v2.26.0 translation
        l10n: zh_CN: for git v2.26.0 l10n round 1 and 2
        l10n: vi(4839t): Updated Vietnamese translation for v2.26.0
        l10n: vi: fix translation + grammar
        l10n: zh_TW.po: v2.26.0 round 2 (0 untranslated)
        l10n: zh_TW.po: v2.26.0 round 1 (11 untranslated)
        l10n: it.po: update the Italian translation for Git 2.26.0 round 2
        l10n: es: 2.26.0 round#2
        l10n: bg.po: Updated Bulgarian translation (4839t)
        l10n: tr: v2.26.0 round 2
        l10n: fr : v2.26.0 rnd 2
        l10n: git.pot: v2.26.0 round 2 (7 new, 2 removed)
        l10n: tr: Add glossary for Turkish translations
        l10n: sv.po: Update Swedish translation (4835t0f0u)
        ...
      c452dfa3
  8. 21 3月, 2020 2 次提交
  9. 20 3月, 2020 4 次提交
  10. 19 3月, 2020 2 次提交