git/builtin
Jeff King 56baa61d01 archive: move file extension format-guessing lower
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: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-22 11:12:35 -07:00
..
add.c Merge branch 'ci/commit--interactive-atomic' 2011-05-16 16:47:10 -07:00
annotate.c
apply.c Merge branch 'jc/maint-add-p-overlapping-hunks' into maint 2011-05-16 16:36:46 -07:00
archive.c archive: move file extension format-guessing lower 2011-06-22 11:12:35 -07:00
bisect--helper.c
blame.c blame: add --line-porcelain output format 2011-05-09 15:27:50 -07:00
branch.c Merge branch 'jk/format-patch-am' 2011-05-31 12:19:11 -07:00
bundle.c i18n: git-bundle basic messages 2011-03-09 23:52:57 -08:00
cat-file.c
check-attr.c
check-ref-format.c
checkout-index.c Merge branch 'jn/git-cmd-h-bypass-setup' 2010-12-12 21:49:50 -08:00
checkout.c Merge branch 'jk/format-patch-am' 2011-05-31 12:19:11 -07:00
clean.c i18n: git-clean clean.requireForce messages 2011-03-09 23:52:57 -08:00
clone.c Merge branch 'ab/i18n-fixup' into maint 2011-05-31 12:00:27 -07:00
commit-tree.c
commit.c Merge branch 'bc/maint-status-z-to-use-porcelain' 2011-06-06 11:40:08 -07:00
config.c config: Give error message when not changing a multivar 2011-05-17 21:01:29 -07:00
count-objects.c
describe.c Merge branch 'lt/default-abbrev' into maint 2011-04-03 12:32:51 -07:00
diff-files.c Convert struct diff_options to use struct pathspec 2011-02-03 12:28:15 -08:00
diff-index.c
diff-tree.c diffcore-rename: fall back to -C when -C -C busts the rename limit 2011-03-22 14:29:07 -07:00
diff.c Merge branch 'jc/rename-degrade-cc-to-c' into maint 2011-05-31 12:00:02 -07:00
fast-export.c Merge branch 'mg/placeholders-are-lowercase' 2011-02-27 21:58:30 -08:00
fetch-pack.c Merge branch 'jk/haves-from-alternate-odb' 2011-05-29 23:51:22 -07:00
fetch.c fetch: do not leak a refspec 2011-06-08 17:21:08 -07:00
fmt-merge-msg.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
for-each-ref.c
fsck.c Remove unused variables 2011-03-22 11:43:27 -07:00
gc.c i18n: git-gc "Auto packing the repository" message 2011-03-09 23:52:57 -08:00
grep.c Merge branch 'mk/grep-pcre' 2011-05-30 00:00:07 -07:00
hash-object.c index_fd(): turn write_object and format_check arguments into one flag 2011-05-09 11:58:19 -07:00
help.c
index-pack.c sparse: Fix an "symbol 'cmd_index_pack' not declared" warning 2011-04-11 10:35:25 -07:00
init-db.c Merge branch 'ab/i18n-fixup' into maint 2011-05-31 12:00:27 -07:00
log.c Merge branch 'jk/format-patch-am' 2011-05-31 12:19:11 -07:00
ls-files.c pathspec: rename per-item field has_wildcard to use_wildcard 2011-04-05 09:30:36 -07:00
ls-remote.c ls-remote: the --exit-code option reports "no matching refs" 2011-05-18 14:37:46 -07:00
ls-tree.c pathspec: rename per-item field has_wildcard to use_wildcard 2011-04-05 09:30:36 -07:00
mailinfo.c mailinfo: always clean up rfc822 header folding 2011-05-26 14:13:38 -07:00
mailsplit.c
merge-base.c Documentation: update to git-merge-base --octopus 2011-04-15 10:13:52 -07:00
merge-file.c
merge-index.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
merge-ours.c
merge-recursive.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
merge-tree.c sparse: Fix an "symbol 'merge_file' not decared" warning 2011-04-11 10:35:25 -07:00
merge.c Merge branch 'jk/format-patch-am' 2011-05-31 12:19:11 -07:00
mktag.c read_sha1_file(): get rid of read_sha1_file_repl() madness 2011-05-15 15:23:33 -07:00
mktree.c
mv.c i18n: git-mv "bad" messages 2011-03-09 23:52:56 -08:00
name-rev.c
notes.c notes remove: --stdin reads from the standard input 2011-05-19 10:54:16 -07:00
pack-objects.c Teach core.bigfilethreashold to pack-objects 2011-04-05 20:25:49 -07:00
pack-redundant.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
pack-refs.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
patch-id.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
prune-packed.c
prune.c
push.c Merge branch 'ab/i18n-st' 2011-04-01 17:55:55 -07:00
read-tree.c Teach read-tree the -n|--dry-run option 2011-05-25 15:04:25 -07:00
receive-pack.c receive-pack: eliminate duplicate .have refs 2011-05-19 20:02:31 -07:00
reflog.c
remote-ext.c Remove unused variables 2011-03-22 11:43:27 -07:00
remote-fd.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
remote.c Merge branch 'jk/maint-remote-mirror-safer' 2011-05-31 12:08:52 -07:00
replace.c
rerere.c rerere: libify rerere_clear() and rerere_gc() 2011-05-08 12:55:34 -07:00
reset.c Merge branch 'ab/i18n-st' 2011-04-01 17:55:55 -07:00
rev-list.c Merge branch 'jk/format-patch-am' 2011-05-31 12:19:11 -07:00
rev-parse.c show: --ignore-missing 2011-05-19 10:55:54 -07:00
revert.c revert: allow reverting a root commit 2011-05-16 13:01:45 -07:00
rm.c i18n: git-rm basic messages 2011-03-09 23:52:56 -08:00
send-pack.c Merge branch 'jk/git-connection-deadlock-fix' into maint 2011-05-26 09:33:25 -07:00
shortlog.c Merge branch 'jk/format-patch-am' 2011-05-31 12:19:11 -07:00
show-branch.c Merge branch 'jk/format-patch-am' 2011-05-31 12:19:11 -07:00
show-ref.c
stripspace.c
symbolic-ref.c
tag.c tag: disallow '-' as tag name 2011-05-10 08:45:37 -07:00
tar-tree.c
unpack-file.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
unpack-objects.c
update-index.c index_fd(): turn write_object and format_check arguments into one flag 2011-05-09 11:58:19 -07:00
update-ref.c
update-server-info.c
upload-archive.c archive: move file extension format-guessing lower 2011-06-22 11:12:35 -07:00
var.c Fix sparse warnings 2011-03-22 10:16:54 -07:00
verify-pack.c
verify-tag.c Merge branch 'mg/maint-tag-rfc1991' 2010-12-08 11:24:13 -08:00
write-tree.c