1. 15 1月, 2015 1 次提交
  2. 02 12月, 2014 1 次提交
  3. 23 9月, 2014 1 次提交
    • N
      archive: support filtering paths with glob · ed22b417
      Nguyễn Thái Ngọc Duy 提交于
      This patch fixes two problems with using :(glob) (or even "*.c"
      without ":(glob)").
      
      The first one is we forgot to turn on the 'recursive' flag in struct
      pathspec. Without that, tree_entry_interesting() will not mark
      potential directories "interesting" so that it can confirm whether
      those directories have anything matching the pathspec.
      
      The marking directories interesting has a side effect that we need to
      walk inside a directory to realize that there's nothing interested in
      there. By that time, 'archive' code has already written the (empty)
      directory down. That means lots of empty directories in the result
      archive.
      
      This problem is fixed by lazily writing directories down when we know
      they are actually needed. There is a theoretical bug in this
      implementation: we can't write empty trees/directories that match that
      pathspec.
      
      path_exists() is also made stricter in order to detect non-matching
      pathspec because when this 'recursive' flag is on, we most likely
      match some directories. The easiest way is not consider any
      directories "matched".
      Noticed-by: NPeter Wu <peter@lekensteyn.nl>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ed22b417
  4. 08 8月, 2014 1 次提交
  5. 10 3月, 2014 1 次提交
  6. 01 3月, 2014 1 次提交
    • S
      add uploadarchive.allowUnreachable option · 7671b632
      Scott J. Goldman 提交于
      In commit ee27ca4a, we started restricting remote git-archive
      invocations to only accessing reachable commits. This
      matches what upload-pack allows, but does restrict some
      useful cases (e.g., HEAD:foo). We loosened this in 0f544ee8,
      which allows `foo:bar` as long as `foo` is a ref tip.
      However, that still doesn't allow many useful things, like:
      
        1. Commits accessible from a ref, like `foo^:bar`, which
           are reachable
      
        2. Arbitrary sha1s, even if they are reachable.
      
      We can do a full object-reachability check for these cases,
      but it can be quite expensive if the client has sent us the
      sha1 of a tree; we have to visit every sub-tree of every
      commit in the worst case.
      
      Let's instead give site admins an escape hatch, in case they
      prefer the more liberal behavior.  For many sites, the full
      object database is public anyway (e.g., if you allow dumb
      walker access), or the site admin may simply decide the
      security/convenience tradeoff is not worth it.
      
      This patch adds a new config option to disable the
      restrictions added in ee27ca4a. It defaults to off, meaning
      there is no change in behavior by default.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7671b632
  7. 17 10月, 2013 1 次提交
  8. 16 7月, 2013 2 次提交
  9. 11 3月, 2013 1 次提交
    • J
      archive: handle commits with an empty tree · bd54cf17
      Jeff King 提交于
      git-archive relies on get_pathspec to convert its argv into
      a list of pathspecs. When get_pathspec is given an empty
      argv list, it returns a single pathspec, the empty string,
      to indicate that everything matches. When we feed this to
      our path_exists function, we typically see that the pathspec
      turns up at least one item in the tree, and we are happy.
      
      But when our tree is empty, we erroneously think it is
      because the pathspec is too limited, when in fact it is
      simply that there is nothing to be found in the tree. This
      is a weird corner case, but the correct behavior is almost
      certainly to produce an empty archive, not to exit with an
      error.
      
      This patch teaches git-archive to create empty archives when
      there is no pathspec given (we continue to complain if a
      pathspec is given, since it obviously is not matched). It
      also confirms that the tar and zip writers produce sane
      output in this instance.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bd54cf17
  10. 18 12月, 2012 1 次提交
  11. 23 8月, 2012 1 次提交
  12. 21 8月, 2012 1 次提交
  13. 19 5月, 2012 1 次提交
  14. 04 5月, 2012 1 次提交
  15. 12 1月, 2012 1 次提交
  16. 22 11月, 2011 1 次提交
    • J
      archive: don't let remote clients get unreachable commits · ee27ca4a
      Jeff King 提交于
      Usually git is careful not to allow clients to fetch
      arbitrary objects from the database; for example, objects
      received via upload-pack must be reachable from a ref.
      Upload-archive breaks this by feeding the client's tree-ish
      directly to get_sha1, which will accept arbitrary hex sha1s,
      reflogs, etc.
      
      This is not a problem if all of your objects are publicly
      reachable anyway (or at least public to anybody who can run
      upload-archive). Or if you are making the repo available by
      dumb protocols like http or rsync (in which case the client
      can read your whole object db directly).
      
      But for sites which allow access only through smart
      protocols, clients may be able to fetch trees from commits
      that exist in the server's object database but are not
      referenced (e.g., because history was rewound).
      
      This patch tightens upload-archive's lookup to use dwim_ref
      rather than get_sha1. This means a remote client can only
      fetch the tip of a named ref, not an arbitrary sha1 or
      reflog entry.
      
      This also restricts some legitimate requests, too:
      
        1. Reachable non-tip commits, like:
      
              git archive --remote=$url v1.0~5
      
        2. Sub-trees of reachable commits, like:
      
              git archive --remote=$url v1.7.7:Documentation
      
      Local requests continue to use get_sha1, and are not
      restricted at all.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ee27ca4a
  17. 28 9月, 2011 1 次提交
    • J
      archive.c: use OPT_BOOL() · f858c646
      Junio C Hamano 提交于
      The list variable (which is OPT_BOOLEAN) is initialized to 0 and only
      checked against 0 in the code, so it is safe to use OPT_BOOL().
      
      The worktree_attributes variable (which is OPT_BOOLEAN) is initialized to
      0 and later assigned to a field with the same name in struct archive_args,
      which is a bitfield of width 1. It is safe and even more correct to use
      OPT_BOOL() here; the new test in 5001 demonstrates why using OPT_COUNTUP
      is wrong.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f858c646
  18. 05 8月, 2011 1 次提交
  19. 23 6月, 2011 5 次提交
    • J
      upload-archive: allow user to turn off filters · 7b97730b
      Jeff King 提交于
      Some tar filters may be very expensive to run, so sites do
      not want to expose them via upload-archive. This patch lets
      users configure tar.<filter>.remote to turn them off.
      
      By default, gzip filters are left on, as they are about as
      expensive as creating zip archives.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7b97730b
    • J
      archive: refactor file extension format-guessing · 08716b3c
      Jeff King 提交于
      Git-archive will guess a format from the output filename if
      no format is explicitly given.  The current function just
      hardcodes "zip" to the zip format, and leaves everything
      else NULL (which will default to tar). Since we are about
      to add user-specified formats, we need to be more flexible.
      The new rule is "if a filename ends with a dot and the name
      of a format, it matches that format". For the existing "tar"
      and "zip" formats, this is identical to the current
      behavior. For new user-specified formats, this will do what
      the user expects if they name their formats appropriately.
      
      Because we will eventually start matching arbitrary
      user-specified extensions that may include dots, the strrchr
      search for the final dot is not sufficient. We need to do an
      actual suffix match with each extension.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      08716b3c
    • J
      archive: move file extension format-guessing lower · 56baa61d
      Jeff King 提交于
      The process for guessing an archive output format based on
      the filename is something like this:
      
        a. parse --output in cmd_archive; check the filename
           against a static set of mapping heuristics (right now
           it just matches ".zip" for zip files).
      
        b. if found, stick a fake "--format=zip" at the beginning
           of the arguments list (if the user did specify a
           --format manually, the later option will override our
           fake one)
      
        c. if it's a remote call, ship the arguments to the remote
           (including the fake), which will call write_archive on
           their end
      
        d. if it's local, ship the arguments to write_archive
           locally
      
      There are two problems:
      
        1. The set of mappings is static and at too high a level.
           The write_archive level is going to check config for
           user-defined formats, some of which will specify
           extensions. We need to delay lookup until those are
           parsed, so we can match against them.
      
        2. For a remote archive call, our set of mappings (or
           formats) may not match the remote side's. This is OK in
           practice right now, because all versions of git
           understand "zip" and "tar". But as new formats are
           added, there is going to be a mismatch between what the
           client can do and what the remote server can do.
      
      To fix (1), this patch refactors the location guessing to
      happen at the write_archive level, instead of the
      cmd_archive level. So instead of sticking a fake --format
      field in the argv list, we actually pass a "name hint" down
      the callchain; this hint is used at the appropriate time to
      guess the format (if one hasn't been given already).
      
      This patch leaves (2) unfixed. The name_hint is converted to
      a "--format" option as before, and passed to the remote.
      This means the local side's idea of how extensions map to
      formats will take precedence.
      
      Another option would be to pass the name hint to the remote
      side and let the remote choose. This isn't a good idea for
      two reasons:
      
        1. There's no room in the protocol for passing that
           information. We can pass a new argument, but older
           versions of git on the server will choke on it.
      
        2. Letting the remote side decide creates a silent
           inconsistency in user experience. Consider the case
           that the locally installed git knows about the "tar.gz"
           format, but a remote server doesn't.
      
           Running "git archive -o foo.tar.gz" will use the tar.gz
           format. If we use --remote, and the local side chooses
           the format, then we send "--format=tar.gz" to the
           remote, which will complain about the unknown format.
           But if we let the remote side choose the format, then
           it will realize that it doesn't know about "tar.gz" and
           output uncompressed tar without even issuing a warning.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      56baa61d
    • J
      archive: pass archiver struct to write_archive callback · 4d7c9898
      Jeff King 提交于
      The current archivers are very static; when you are in the
      write_tar_archive function, you know you are writing a tar.
      However, to facilitate runtime-configurable archivers
      that will share a common write function we need to tell the
      function which archiver was used.
      
      As a convenience, we also provide an opaque data pointer in
      the archiver struct so that individual archivers can put
      something useful there when they register themselves.
      Technically they could just use the "name" field to look in
      an internal map of names to data, but this is much simpler.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4d7c9898
    • J
      archive: refactor list of archive formats · 13e0f88d
      Jeff King 提交于
      Most of the tar and zip code was nicely split out into two
      abstracted files which knew only about their specific
      formats. The entry point to this code was a single "write
      archive" function.
      
      However, as these basic formats grow more complex (e.g., by
      handling multiple file extensions and format names), a
      static list of the entry point functions won't be enough.
      Instead, let's provide a way for the tar and zip code to
      tell the main archive code what they support by registering
      archiver names and functions.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      13e0f88d
  20. 16 6月, 2011 1 次提交
    • J
      archive: reorder option parsing and config reading · 23212862
      Jeff King 提交于
      The archive command does three things during its
      initialization phase:
      
        1. parse command-line options
      
        2. setup the git directory
      
        3. read config
      
      During phase (1), if we see any options that do not require
      a git directory (like "--list"), we handle them immediately
      and exit, making it safe to abort step (2) if we are not in
      a git directory.
      
      Step (3) must come after step (2), since the git directory
      may influence configuration.  However, this leaves no
      possibility of configuration from step (3) impacting the
      command-line options in step (1) (which is useful, for
      example, for supporting user-configurable output formats).
      
      Instead, let's reorder this to:
      
        1. setup the git directory, if it exists
      
        2. read config
      
        3. parse command-line options
      
        4. if we are not in a git repository, die
      
      This should have the same external behavior, but puts
      configuration before command-line parsing.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      23212862
  21. 26 3月, 2011 1 次提交
  22. 16 11月, 2010 2 次提交
  23. 09 10月, 2010 1 次提交
  24. 28 7月, 2010 1 次提交
  25. 17 1月, 2010 1 次提交
  26. 30 12月, 2009 1 次提交
  27. 20 10月, 2009 1 次提交
    • T
      Refactor pretty_print_commit arguments into a struct · dd2e794a
      Thomas Rast 提交于
      pretty_print_commit() has a bunch of rarely-used arguments, and
      introducing more of them requires yet another update of all the call
      sites.  Refactor most of them into a struct to make future extensions
      easier.
      
      The ones that stay "plain" arguments were chosen on the grounds that
      all callers put real arguments there, whereas some callers have 0/NULL
      for all arguments that were factored into the struct.
      
      We declare the struct 'const' to ensure none of the callers are bitten
      by the changed (no longer call-by-value) semantics.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      dd2e794a
  28. 09 10月, 2009 1 次提交
  29. 14 9月, 2009 1 次提交
  30. 25 5月, 2009 1 次提交
  31. 18 4月, 2009 1 次提交
  32. 09 3月, 2009 1 次提交
    • R
      archive: use parseopt for local-only options · 52e77876
      René Scharfe 提交于
      Replace the hand-rolled parsers that find and remove --remote and --exec
      by a parseopt parser that also handles --output.
      
      All three options only have a meaning if no remote server is used or on
      the local side.  They must be rejected by upload-archive and should not
      be sent to the server by archive.
      
      We can't use a single parser for both remote and local side because the
      remote end possibly understands a different set of options than the
      local side.  A local parser would then wrongly accuse options valid on
      the other side as being incorrect.
      
      This patch implements a very forgiving parser that understands only the
      three options mentioned above.  All others are passed to the normal,
      complete parser in archive.c (running either locally in archive, or
      remotely in upload-archive).  This normal parser definition contains
      dummy entries for the three options, in order for them to appear in the
      help screen.
      
      The parseopt parser allows multiple occurrences of --remote and --exec
      unlike the previous one; the one specified last wins.  This looseness
      is acceptable, I think.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      52e77876
  33. 04 3月, 2009 1 次提交
  34. 08 2月, 2009 1 次提交
    • L
      tree.c: allow read_tree_recursive() to traverse gitlink entries · d3bee161
      Lars Hjemli 提交于
      When the callback function invoked from read_tree_recursive() returns
      the value `READ_TREE_RECURSIVE` for a gitlink entry, the traversal will
      now continue into the tree connected to the gitlinked commit. This
      functionality can be used to allow inter-repository operations, but
      since the current users of read_tree_recursive() does not yet support
      such operations, they have been modified where necessary to make sure
      that they never return READ_TREE_RECURSIVE for gitlink entries (hence
      no change in behaviour should be introduces by this patch alone).
      Signed-off-by: NLars Hjemli <hjemli@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d3bee161