1. 05 1月, 2016 1 次提交
  2. 20 11月, 2015 1 次提交
  3. 06 11月, 2015 1 次提交
    • L
      hideRefs: add support for matching full refs · 78a766ab
      Lukas Fleischer 提交于
      In addition to matching stripped refs, one can now add hideRefs
      patterns that the full (unstripped) ref is matched against. To
      distinguish between stripped and full matches, those new patterns
      must be prefixed with a circumflex (^).
      
      This commit also removes support for the undocumented and unintended
      hideRefs settings ".have" (suppressing all "have" lines) and
      "capabilities^{}" (suppressing the capabilities line).
      Signed-off-by: NLukas Fleischer <lfleischer@lfos.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      78a766ab
  4. 06 10月, 2015 2 次提交
    • J
      receive-pack: simplify keep_arg computation · b26cb7c7
      Jeff King 提交于
      To generate "--keep=receive-pack $pid on $host", we write
      progressively into a single buffer, which requires keeping
      track of how much we've written so far. But since the result
      is destined to go into our argv array, we can simply use
      argv_array_pushf.
      
      Unfortunately we still have to have a fixed-size buffer for
      the gethostname() call, but at least it now doesn't involve
      any extra size computation. And as a bonus, we drop an
      sprintf and a strcpy call.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b26cb7c7
    • J
      use sha1_to_hex_r() instead of strcpy · d59f765a
      Jeff King 提交于
      Before sha1_to_hex_r() existed, a simple way to get hex
      sha1 into a buffer was with:
      
        strcpy(buf, sha1_to_hex(sha1));
      
      This isn't wrong (assuming the buf is 41 characters), but it
      makes auditing the code base for bad strcpy() calls harder,
      as these become false positives.
      
      Let's convert them to sha1_to_hex_r(), and likewise for
      some calls to find_unique_abbrev(). While we're here, we'll
      double-check that all of the buffers are correctly sized,
      and use the more obvious GIT_SHA1_HEXSZ constant.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d59f765a
  5. 26 9月, 2015 1 次提交
    • J
      receive-pack: convert strncpy to xsnprintf · b7115a35
      Jeff King 提交于
      This strncpy is pointless; we pass the strlen() of the src
      string, meaning that it works just like a memcpy. Worse,
      though, is that the size has no relation to the destination
      buffer, meaning it is a potential overflow.  In practice,
      it's not. We pass only short constant strings like
      "warning: " and "error: ", which are much smaller than the
      destination buffer.
      
      We can make this much simpler by just using xsnprintf, which
      will check for overflow and return the size for our next
      vsnprintf, without us having to run a separate strlen().
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b7115a35
  6. 23 7月, 2015 1 次提交
    • J
      receive-pack: crash when checking with non-exist HEAD · b112b14d
      Jiang Xin 提交于
      If HEAD of a repository points to a conflict reference, such as:
      
      * There exist a reference named 'refs/heads/jx/feature1', but HEAD
        points to 'refs/heads/jx', or
      
      * There exist a reference named 'refs/heads/feature', but HEAD points
        to 'refs/heads/feature/bad'.
      
      When we push to delete a reference for this repo, such as:
      
              git push /path/to/bad-head-repo.git :some/good/reference
      
      The git-receive-pack process will crash.
      
      This is because if HEAD points to a conflict reference, the function
      `resolve_refdup("HEAD", ...)` does not return a valid reference name,
      but a null buffer.  Later matching the delete reference against the null
      buffer will cause git-receive-pack crash.
      Signed-off-by: NJiang Xin <worldhello.net@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b112b14d
  7. 24 6月, 2015 2 次提交
    • J
      fsck: git receive-pack: support excluding objects from fsck'ing · cd94c6f9
      Johannes Schindelin 提交于
      The optional new config option `receive.fsck.skipList` specifies the path
      to a file listing the names, i.e. SHA-1s, one per line, of objects that
      are to be ignored by `git receive-pack` when `receive.fsckObjects = true`.
      
      This is extremely handy in case of legacy repositories where it would
      cause more pain to change incorrect objects than to live with them
      (e.g. a duplicate 'author' line in an early commit object).
      
      The intended use case is for server administrators to inspect objects
      that are reported by `git push` as being too problematic to enter the
      repository, and to add the objects' SHA-1 to a (preferably sorted) file
      when the objects are legitimate, i.e. when it is determined that those
      problematic objects should be allowed to enter the server.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cd94c6f9
    • J
      fsck (receive-pack): allow demoting errors to warnings · 5d477a33
      Johannes Schindelin 提交于
      For example, missing emails in commit and tag objects can be demoted to
      mere warnings with
      
      	git config receive.fsck.missingemail=warn
      
      The value is actually a comma-separated list.
      
      In case that the same key is listed in multiple receive.fsck.<msg-id>
      lines in the config, the latter configuration wins (this can happen for
      example when both $HOME/.gitconfig and .git/config contain message type
      settings).
      
      As git receive-pack does not actually perform the checks, it hands off
      the setting to index-pack or unpack-objects in the form of an optional
      argument to the --strict option.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5d477a33
  8. 26 5月, 2015 2 次提交
  9. 02 4月, 2015 1 次提交
  10. 18 2月, 2015 2 次提交
  11. 09 1月, 2015 1 次提交
    • J
      receive-pack: support push-to-checkout hook · 08553319
      Junio C Hamano 提交于
      When receive.denyCurrentBranch is set to updateInstead, a push that
      tries to update the branch that is currently checked out is accepted
      only when the index and the working tree exactly matches the
      currently checked out commit, in which case the index and the
      working tree are updated to match the pushed commit.  Otherwise the
      push is refused.
      
      This hook can be used to customize this "push-to-deploy" logic.  The
      hook receives the commit with which the tip of the current branch is
      going to be updated, and can decide what kind of local changes are
      acceptable and how to update the index and the working tree to match
      the updated tip of the current branch.
      
      For example, the hook can simply run `git read-tree -u -m HEAD "$1"`
      in order to emulate 'git fetch' that is run in the reverse direction
      with `git push`, as the two-tree form of `read-tree -u -m` is
      essentially the same as `git checkout` that switches branches while
      keeping the local changes in the working tree that do not interfere
      with the difference between the branches.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      08553319
  12. 08 1月, 2015 6 次提交
  13. 02 12月, 2014 2 次提交
    • J
      receive-pack: refactor updateInstead codepath · 21b138d0
      Junio C Hamano 提交于
      Keep the "there is nothing to update in a bare repository", "when
      the check and update process runs, here are the GIT_DIR and
      GIT_WORK_TREE" logic, which will be common regardless of how the
      decision to update and the actual update are done, in the original
      update_worktree() function, and split out the "working tree and
      the index must match the original HEAD exactly" and "use two-way
      read-tree to update the working tree" into a new push_to_deploy()
      helper function.  This will allow customizing the logic more cleanly
      and easily.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      21b138d0
    • N
      path.c: make get_pathname() call sites return const char * · dcf69262
      Nguyễn Thái Ngọc Duy 提交于
      Before the previous commit, get_pathname returns an array of PATH_MAX
      length. Even if git_path() and similar functions does not use the
      whole array, git_path() caller can, in theory.
      
      After the commit, get_pathname() may return a buffer that has just
      enough room for the returned string and git_path() caller should never
      write beyond that.
      
      Make git_path(), mkpath() and git_path_submodule() return a const
      buffer to make sure callers do not write in it at all.
      
      This could have been part of the previous commit, but the "const"
      conversion is too much distraction from the core changes in path.c.
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dcf69262
  14. 01 12月, 2014 1 次提交
    • J
      receive-pack: add another option for receive.denyCurrentBranch · 1404bcbb
      Johannes Schindelin 提交于
      When synchronizing between working directories, it can be handy to update
      the current branch via 'push' rather than 'pull', e.g. when pushing a fix
      from inside a VM, or when pushing a fix made on a user's machine (where
      the developer is not at liberty to install an ssh daemon let alone know
      the user's password).
      
      The common workaround – pushing into a temporary branch and then merging
      on the other machine – is no longer necessary with this patch.
      
      The new option is:
      
      'updateInstead':
      	Update the working tree accordingly, but refuse to do so if there
      	are any uncommitted changes.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1404bcbb
  15. 26 11月, 2014 1 次提交
  16. 18 11月, 2014 1 次提交
  17. 29 10月, 2014 1 次提交
  18. 20 10月, 2014 1 次提交
  19. 16 10月, 2014 2 次提交
  20. 14 10月, 2014 1 次提交
  21. 02 10月, 2014 1 次提交
  22. 26 9月, 2014 1 次提交
  23. 18 9月, 2014 2 次提交
    • J
      signed push: allow stale nonce in stateless mode · 5732373d
      Junio C Hamano 提交于
      When operating with the stateless RPC mode, we will receive a nonce
      issued by another instance of us that advertised our capability and
      refs some time ago.  Update the logic to check received nonce to
      detect this case, compute how much time has passed since the nonce
      was issued and report the status with a new environment variable
      GIT_PUSH_CERT_NONCE_SLOP to the hooks.
      
      GIT_PUSH_CERT_NONCE_STATUS will report "SLOP" in such a case.  The
      hooks are free to decide how large a slop it is willing to accept.
      
      Strictly speaking, the "nonce" is not really a "nonce" anymore in
      the stateless RPC mode, as it will happily take any "nonce" issued
      by it (which is protected by HMAC and its secret key) as long as it
      is fresh enough.  The degree of this security degradation, relative
      to the native protocol, is about the same as the "we make sure that
      the 'git push' decided to update our refs with new objects based on
      the freshest observation of our refs by making sure the values they
      claim the original value of the refs they ask us to update exactly
      match the current state" security is loosened to accomodate the
      stateless RPC mode in the existing code without this series, so
      there is no need for those who are already using smart HTTP to push
      to their repositories to be alarmed any more than they already are.
      
      In addition, the server operator can set receive.certnonceslop
      configuration variable to specify how stale a nonce can be (in
      seconds).  When this variable is set, and if the nonce received in
      the certificate that passes the HMAC check was less than that many
      seconds old, hooks are given "OK" in GIT_PUSH_CERT_NONCE_STATUS
      (instead of "SLOP") and the received nonce value is given in
      GIT_PUSH_CERT_NONCE, which makes it easier for a simple-minded
      hook to check if the certificate we received is recent enough.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      5732373d
    • J
      signed push: fortify against replay attacks · b89363e4
      Junio C Hamano 提交于
      In order to prevent a valid push certificate for pushing into an
      repository from getting replayed in a different push operation, send
      a nonce string from the receive-pack process and have the signer
      include it in the push certificate.  The receiving end uses an HMAC
      hash of the path to the repository it serves and the current time
      stamp, hashed with a secret seed (the secret seed does not have to
      be per-repository but can be defined in /etc/gitconfig) to generate
      the nonce, in order to ensure that a random third party cannot forge
      a nonce that looks like it originated from it.
      
      The original nonce is exported as GIT_PUSH_CERT_NONCE for the hooks
      to examine and match against the value on the "nonce" header in the
      certificate to notice a replay, but returned "nonce" header in the
      push certificate is examined by receive-pack and the result is
      exported as GIT_PUSH_CERT_NONCE_STATUS, whose value would be "OK"
      if the nonce recorded in the certificate matches what we expect, so
      that the hooks can more easily check.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b89363e4
  24. 17 9月, 2014 1 次提交
    • J
      receive-pack: allow hooks to ignore its standard input stream · ec7dbd14
      Junio C Hamano 提交于
      The pre-receive and post-receive hooks were designed to be an
      improvement over old style update and post-update hooks, which take
      the update information on their command line and are limited by the
      command line length limit.  The same information is fed from the
      standard input to pre/post-receive hooks instead to lift this
      limitation.  It has been mandatory for these new style hooks to
      consume the update information fully from the standard input stream.
      Otherwise, they would risk killing the receive-pack process via
      SIGPIPE.
      
      If a hook does not want to look at all the information, it is easy
      to send its standard input to /dev/null (perhaps a niche use of hook
      might need to know only the fact that a push was made, without
      having to know what objects have been pushed to update which refs),
      and this has already been done by existing hooks that are written
      carefully.
      
      However, because there is no good way to consistently fail hooks
      that do not consume the input fully (a small push may result in a
      short update record that may fit within the pipe buffer, to which
      the receive-pack process may manage to write before the hook has a
      chance to exit without reading anything, which will not result in a
      death-by-SIGPIPE of receive-pack), it can lead to a hard to diagnose
      "once in a blue moon" phantom failure.
      
      Lift this "hooks must consume their input fully" mandate.  A mandate
      that is not enforced strictly is not helping us to catch mistakes in
      hooks.  If a hook has a good reason to decide the outcome of its
      operation without reading the information we feed it, let it do so
      as it pleases.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ec7dbd14
  25. 16 9月, 2014 4 次提交
    • J
      signed push: remove duplicated protocol info · 4adf569d
      Junio C Hamano 提交于
      With the interim protocol, we used to send the update commands even
      though we already send a signed copy of the same information when
      push certificate is in use.  Update the send-pack/receive-pack pair
      not to do so.
      
      The notable thing on the receive-pack side is that it makes sure
      that there is no command sent over the traditional protocol packet
      outside the push certificate.  Otherwise a pusher can claim to be
      pushing one set of ref updates in the signed certificate while
      issuing commands to update unrelated refs, and such an update will
      evade later audits.
      
      Finally, start documenting the protocol.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4adf569d
    • J
      receive-pack: GPG-validate push certificates · d05b9618
      Junio C Hamano 提交于
      Reusing the GPG signature check helpers we already have, verify
      the signature in receive-pack and give the results to the hooks
      via GIT_PUSH_CERT_{SIGNER,KEY,STATUS} environment variables.
      
      Policy decisions, such as accepting or rejecting a good signature by
      a key that is not fully trusted, is left to the hook and kept
      outside of the core.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d05b9618
    • J
      push: the beginning of "git push --signed" · a85b377d
      Junio C Hamano 提交于
      While signed tags and commits assert that the objects thusly signed
      came from you, who signed these objects, there is not a good way to
      assert that you wanted to have a particular object at the tip of a
      particular branch.  My signing v2.0.1 tag only means I want to call
      the version v2.0.1, and it does not mean I want to push it out to my
      'master' branch---it is likely that I only want it in 'maint', so
      the signature on the object alone is insufficient.
      
      The only assurance to you that 'maint' points at what I wanted to
      place there comes from your trust on the hosting site and my
      authentication with it, which cannot easily audited later.
      
      Introduce a mechanism that allows you to sign a "push certificate"
      (for the lack of better name) every time you push, asserting that
      what object you are pushing to update which ref that used to point
      at what other object.  Think of it as a cryptographic protection for
      ref updates, similar to signed tags/commits but working on an
      orthogonal axis.
      
      The basic flow based on this mechanism goes like this:
      
       1. You push out your work with "git push --signed".
      
       2. The sending side learns where the remote refs are as usual,
          together with what protocol extension the receiving end
          supports.  If the receiving end does not advertise the protocol
          extension "push-cert", an attempt to "git push --signed" fails.
      
          Otherwise, a text file, that looks like the following, is
          prepared in core:
      
      	certificate version 0.1
      	pusher Junio C Hamano <gitster@pobox.com> 1315427886 -0700
      
      	7339ca65... 21580ecb... refs/heads/master
      	3793ac56... 12850bec... refs/heads/next
      
          The file begins with a few header lines, which may grow as we
          gain more experience.  The 'pusher' header records the name of
          the signer (the value of user.signingkey configuration variable,
          falling back to GIT_COMMITTER_{NAME|EMAIL}) and the time of the
          certificate generation.  After the header, a blank line follows,
          followed by a copy of the protocol message lines.
      
          Each line shows the old and the new object name at the tip of
          the ref this push tries to update, in the way identical to how
          the underlying "git push" protocol exchange tells the ref
          updates to the receiving end (by recording the "old" object
          name, the push certificate also protects against replaying).  It
          is expected that new command packet types other than the
          old-new-refname kind will be included in push certificate in the
          same way as would appear in the plain vanilla command packets in
          unsigned pushes.
      
          The user then is asked to sign this push certificate using GPG,
          formatted in a way similar to how signed tag objects are signed,
          and the result is sent to the other side (i.e. receive-pack).
      
          In the protocol exchange, this step comes immediately before the
          sender tells what the result of the push should be, which in
          turn comes before it sends the pack data.
      
       3. When the receiving end sees a push certificate, the certificate
          is written out as a blob.  The pre-receive hook can learn about
          the certificate by checking GIT_PUSH_CERT environment variable,
          which, if present, tells the object name of this blob, and make
          the decision to allow or reject this push.  Additionally, the
          post-receive hook can also look at the certificate, which may be
          a good place to log all the received certificates for later
          audits.
      
      Because a push certificate carry the same information as the usual
      command packets in the protocol exchange, we can omit the latter
      when a push certificate is in use and reduce the protocol overhead.
      This however is not included in this patch to make it easier to
      review (in other words, the series at this step should never be
      released without the remainder of the series, as it implements an
      interim protocol that will be incompatible with the final one).
      As such, the documentation update for the protocol is left out of
      this step.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      a85b377d
    • J
      receive-pack: factor out capability string generation · 52d2ae58
      Junio C Hamano 提交于
      Similar to the previous one for send-pack, make it easier and
      cleaner to add to capability advertisement.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      52d2ae58