1. 19 5月, 2012 1 次提交
  2. 12 1月, 2012 1 次提交
  3. 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
  4. 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
  5. 05 8月, 2011 1 次提交
  6. 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
  7. 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
  8. 26 3月, 2011 1 次提交
  9. 16 11月, 2010 2 次提交
  10. 09 10月, 2010 1 次提交
  11. 28 7月, 2010 1 次提交
  12. 17 1月, 2010 1 次提交
  13. 30 12月, 2009 1 次提交
  14. 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
  15. 09 10月, 2009 1 次提交
  16. 14 9月, 2009 1 次提交
  17. 25 5月, 2009 1 次提交
  18. 18 4月, 2009 1 次提交
  19. 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
  20. 04 3月, 2009 1 次提交
  21. 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
  22. 27 10月, 2008 1 次提交
  23. 13 10月, 2008 1 次提交
  24. 03 10月, 2008 1 次提交
  25. 29 8月, 2008 1 次提交
  26. 30 7月, 2008 1 次提交
    • R
      archive: allow --exec and --remote without equal sign · 4fac1d3a
      Rene Scharfe 提交于
      Convert git archive to parse_options().  The parameters --remote and --exec
      are still handled by their special parser.  Define them anyway in order for
      them to show up in the usage notice.
      
      Note: in a command like "git archive --prefix --remote=a/ HEAD", the string
      "--remote=a/" will be interpreted as a remote option, not a prefix, because
      that special parser sees it first.  If one needs such a strange prefix, it
      needs to be specified like this: "git archive --prefix=--remote=a/ HEAD"
      (with an equal sign).
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4fac1d3a
  27. 26 7月, 2008 3 次提交
  28. 15 7月, 2008 2 次提交
    • R
      archive: unify file attribute handling · 1d11d5bb
      René Scharfe 提交于
      Now that all file attribute handling for git archive has moved to archive.c,
      we can unexport sha1_file_to_archive() and is_archive_path_ignored() even
      disappears.
      
      Add setup_archive_check(), modelled after similar functions used in the code
      of other commands that support multiple file attributes.
      
      Also remove convert_to_archive(), as it's only remaining function with
      attribute handling gone was to call format_subst() if commit was not NULL,
      which is now checked in sha1_file_to_archive().
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1d11d5bb
    • R
      archive: centralize archive entry writing · 562e25ab
      René Scharfe 提交于
      Add the exported function write_archive_entries() to archive.c, which uses
      the new ability of read_tree_recursive() to pass a context pointer to its
      callback in order to centralize previously duplicated code.
      
      The new callback function write_archive_entry() does the work that every
      archiver backend needs to do: loading file contents, entering subdirectories,
      handling file attributes, constructing the full path of the entry.  All that
      done, it calls the backend specific write_archive_entry_fn_t function.
      Signed-off-by: NRene Scharfe <rene.scharfe@lsrfire.ath.cx>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      562e25ab
  29. 10 6月, 2008 1 次提交
  30. 23 4月, 2008 1 次提交
  31. 19 1月, 2008 1 次提交
    • L
      Move sha1_file_to_archive into libgit · 18125644
      Lars Hjemli 提交于
      When the specfile (export-subst) attribute was introduced, it added a
      dependency from archive-{tar|zip}.c to builtin-archive.c. This broke the
      support for archive-operations in libgit.a since builtin-archive.o doesn't
      belong in libgit.a.
      
      This patch moves the functions required by libgit.a from builtin-archive.c
      to the new file archive.c (which becomes part of libgit.a).
      Signed-off-by: NLars Hjemli <hjemli@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      18125644