Commit graph

25803 commits

Author SHA1 Message Date
Junio C Hamano a1ee40f3a2 Merge branch 'jc/checkout-reflog-fix' into maint
* jc/checkout-reflog-fix:
  checkout: do not write bogus reflog entry out
2011-08-16 12:41:12 -07:00
Junio C Hamano 7aa50897dd Merge branch 'jc/maint-reset-unmerged-path' into maint
* jc/maint-reset-unmerged-path:
  reset [<commit>] paths...: do not mishandle unmerged paths
2011-08-16 11:41:28 -07:00
Junio C Hamano b5e104a0e6 Merge branch 'mz/doc-rebase-abort' into maint
* mz/doc-rebase-abort:
  rebase: clarify "restore the original branch"
2011-08-16 11:41:28 -07:00
Junio C Hamano 22d9b79370 Merge branch 'bw/log-all-ref-updates-doc' into maint
* bw/log-all-ref-updates-doc:
  Documentation: clearly specify what refs are honored by core.logAllRefUpdates
2011-08-16 11:41:28 -07:00
Junio C Hamano cd145e72f3 Merge branch 'js/maint-add-path-stat-pwd' into maint
* js/maint-add-path-stat-pwd:
  get_pwd_cwd(): Do not trust st_dev/st_ino blindly
2011-08-16 11:41:27 -07:00
Junio C Hamano 8516c1c231 Merge branch 'ms/help-unknown' into maint
* ms/help-unknown:
  help_unknown_cmd: do not propose an "unknown" cmd
2011-08-16 11:41:27 -07:00
Junio C Hamano 412403eb45 Merge branch 'mz/doc-synopsis-verse' into maint
* mz/doc-synopsis-verse:
  Documentation: use [verse] for SYNOPSIS sections
2011-08-16 11:41:26 -07:00
Junio C Hamano 5329c99795 Merge branch 'jn/mime-type-with-params' into maint
* jn/mime-type-with-params:
  gitweb: Serve */*+xml 'blob_plain' as text/plain with $prevent_xss
  gitweb: Serve text/* 'blob_plain' as text/plain with $prevent_xss
2011-08-16 11:41:26 -07:00
Junio C Hamano 4a5a8008fd Merge branch 'jc/submodule-sync-no-auto-vivify' into maint
* jc/submodule-sync-no-auto-vivify:
  submodule add: always initialize .git/config entry
  submodule sync: do not auto-vivify uninteresting submodule
2011-08-16 11:41:26 -07:00
Junio C Hamano a35d78c0f4 Merge branch 'jc/zlib-wrap' into maint
* jc/zlib-wrap:
  zlib: allow feeding more than 4GB in one go
  zlib: zlib can only process 4GB at a time
  zlib: wrap deflateBound() too
  zlib: wrap deflate side of the API
  zlib: wrap inflateInit2 used to accept only for gzip format
  zlib: wrap remaining calls to direct inflate/inflateEnd
  zlib wrapper: refactor error message formatter
2011-08-16 11:23:26 -07:00
Junio C Hamano 184cb4d689 Merge branch 'fk/relink-upon-ldflags-update' into maint
* fk/relink-upon-ldflags-update:
  Makefile: Track changes to LDFLAGS and relink when necessary
2011-08-16 11:23:26 -07:00
Junio C Hamano d5c756e99e Merge branch 'bc/submodule-foreach-stdin-fix-1.7.4' into maint
* bc/submodule-foreach-stdin-fix-1.7.4:
  git-submodule.sh: preserve stdin for the command spawned by foreach
  t/t7407: demonstrate that the command called by 'submodule foreach' loses stdin
2011-08-16 11:23:26 -07:00
Junio C Hamano 824f4a9389 Merge branch 'aw/rebase-i-p' into maint
* aw/rebase-i-p:
  rebase -i -p: include non-first-parent commits in todo list
2011-08-16 11:23:25 -07:00
Junio C Hamano f253376dcb Merge branch 'jc/diff-index-quick-exit-early' into maint
* jc/diff-index-quick-exit-early:
  diff-index --quiet: learn the "stop feeding the backend early" logic

Conflicts:
	unpack-trees.h
2011-08-16 11:23:25 -07:00
Junio C Hamano e10e476fb1 Merge branch 'jk/combine-diff-binary-etc' into maint
* jk/combine-diff-binary-etc:
  combine-diff: respect textconv attributes
  refactor get_textconv to not require diff_filespec
  combine-diff: handle binary files as binary
  combine-diff: calculate mode_differs earlier
  combine-diff: split header printing into its own function
2011-08-16 11:23:24 -07:00
Jeff King 2a6f08ac1f am: refresh the index at start and --resolved
If a file is unchanged but stat-dirty, we may erroneously
fail to apply patches, thinking that they conflict with a
dirty working tree.

This patch adds a call to "update-index --refresh". It comes
as late as possible, so that we don't bother with it for
thinks like "git rebase --abort", or when mbox-splitting
fails. However, it does come before we actually start
applying patches, meaning we will only call it once when we
start applying patches (or any time we return to "am" after
having resolved conflicts), and not once per patch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-16 11:15:41 -07:00
Michael Witten 0906f6e14e filter-branch: Export variable `workdir' for --commit-filter
According to `git help filter-branch':

       --commit-filter <command>
           ...
           You can use the _map_ convenience function in this filter,
           and other convenience functions, too...
           ...

However, it turns out that `map' hasn't been usable because it depends
on the variable `workdir', which is not propogated to the environment
of the shell that runs the commit-filter <command> because the
shell is created via a simple-command rather than a compound-command
subshell:

 @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
                 $(git write-tree) $parentstr < ../message > ../map/$commit ||
                         die "could not write rewritten commit"

One solution is simply to export `workdir'. However, it seems rather
heavy-handed to export `workdir' to the environments of all commands,
so instead this commit exports `workdir' for only the duration of the
shell command in question:

 workdir=$workdir @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
                 $(git write-tree) $parentstr < ../message > ../map/$commit ||
                         die "could not write rewritten commit"

Signed-off-by: Michael Witten <mfwitten@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-08 12:09:38 -07:00
Emilio G. Cota ae8044a2f5 Documentation/Makefile: add *.pdf to `clean' target
user-manual.pdf is not removed by `make clean'; fix it.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-08 09:30:14 -07:00
Emilio G. Cota 070648e9b7 Documentation: ignore *.pdf files
user-manual.pdf is generated by the build and therefore
should be ignored by git.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-08 09:30:12 -07:00
Heiko Voigt e9e0643fe6 add gitignore entry to description about how to write a builtin
If the author forgets the gitignore entry the built result will show up
as new file in the git working directory.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-03 11:44:23 -07:00
Michael Haggerty 0922570c76 gitattributes: Reword "attribute macro" to "macro attribute"
The new wording makes it clearer that such a beast is an attribute in
addition to being a macro (as opposed to being only a macro that is
used for attributes).

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-03 10:32:54 -07:00
Michael Haggerty 98e8406632 gitattributes: Clarify discussion of attribute macros
In particular, make it clear that attribute macros are themselves
recorded as attributes in addition to setting other attributes.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-03 10:32:02 -07:00
Junio C Hamano 3503b8d0da Merge branch 'nk/ref-doc' into maint
* nk/ref-doc:
  glossary: clarify description of HEAD
  glossary: update description of head and ref
  glossary: update description of "tag"
  git.txt: de-emphasize the implementation detail of a ref
  check-ref-format doc: de-emphasize the implementation detail of a ref
  git-remote.txt: avoid sounding as if loose refs are the only ones in the world
  git-remote.txt: fix wrong remote refspec
2011-08-01 14:44:24 -07:00
Junio C Hamano 62607e4813 Merge branch 'jl/maint-fetch-recursive-fix' into maint
* jl/maint-fetch-recursive-fix:
  fetch: Also fetch submodules in subdirectories in on-demand mode
2011-08-01 14:44:17 -07:00
Junio C Hamano 6124690d5f Merge branch 'jc/maint-cygwin-trust-executable-bit-default' into maint
* jc/maint-cygwin-trust-executable-bit-default:
  cygwin: trust executable bit by default
2011-08-01 14:44:13 -07:00
Junio C Hamano d48929e1c3 Merge branch 'jc/legacy-loose-object' into maint
* jc/legacy-loose-object:
  sha1_file.c: "legacy" is really the current format
2011-08-01 14:43:58 -07:00
Junio C Hamano 3e8cd966e0 Merge branch 'an/shallow-doc' into maint
* an/shallow-doc:
  Document the underlying protocol used by shallow repositories and --depth commands.
  Fix documentation of fetch-pack that implies that the client can disconnect after sending wants.
2011-08-01 14:43:53 -07:00
Junio C Hamano 055f2c5d34 Merge branch 'jc/maint-1.7.3-checkout-describe' into maint
* jc/maint-1.7.3-checkout-describe:
  checkout -b <name>: correctly detect existing branch
2011-08-01 14:43:18 -07:00
Erik Faye-Lund e08afecd7f connect: correctly number ipv6 network adapter
In ba50532, the variable 'cnt' was added to both the IPv6 and the
IPv4 version of git_tcp_connect_sock, intended to identify which
network adapter the connection failed on. But in the IPv6 version,
the variable was never increased, leaving it constantly at zero.

This behaviour isn't very useful, so let's fix it by increasing
the variable at every loop-iteration.

Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-01 10:47:36 -07:00
Nguyễn Thái Ngọc Duy d5b6629904 Break down no-lstat() condition checks in verify_uptodate()
Make it easier to grok under what conditions we can skip lstat().

While at there, shorten ie_match_stat() line for the sake of my eyes.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-31 18:42:38 -07:00
Jeff King dd008b3b11 t7400: fix bogus test failure with symlinked trash
One of the tests in t7400 fails if the trash directory has a
symlink anywhere in its path. E.g.:

  $ mkdir /tmp/git-test
  $ mkdir /tmp/git-test/real
  $ ln -s real /tmp/git-test/link

  $ ./t7400-submodule-basic --root=/tmp/git-test/real
  ...
  # passed all 44 test(s)

  $ ./t7400-submodule-basic --root=/tmp/git-test/link
  ...
  not ok - 41 use superproject as upstream when path is relative and no url is set there

The failing test does:

  git submodule add ../repo relative &&
  ...
  git submodule sync relative &&
  test "$(git config submodule.relative.url)" = "$submodurl/repo"

where $submodurl comes from the $TRASH_DIRECTORY the user
gave us. However, git will resolve symlinks when converting
the relative path into an absolute one, leading them to be
textually different (even though they point to the same
directory).

Fix this by asking pwd to canonicalize the name of the trash
directory for us.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-31 18:40:34 -07:00
Carlos Martín Nieto e44b6df90c Documentation: clarify the invalidated tree entry format
When the entry_count is -1, the tree is invalidated and therefore has
not associated hash (or object name). Explicitly state that the next
entry starts after the newline.

Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-31 18:23:49 -07:00
Jens Lehmann 2579e1d293 tests: print failed test numbers at the end of the test run
On modern multi-core processors "make test" is often run in multiple jobs.
If one of them fails the test run does stop, but the concurrently running
tests finish their run. It is rather easy to find out which test failed by
doing a "ls -d t/trash*". But that only works when you don't use the "-i"
option to "make test" because you want to get an overview of all failing
tests. In that case all thrash directories are deleted end and the
information which tests failed is lost.

If one or more tests failed, print a list of them before the test summary:

failed test(s): t1000 t6500

fixed   0
success 7638
failed  3
broken  49
total   7723

This makes it possible to just run the test suite with -i and collect all
failed test scripts at the end for further examination.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-24 11:55:14 -07:00
Dmitry Ivankov b421812b48 doc/fast-import: clarify notemodify command
The "notemodify" fast-import command was introduced in commit a8dd2e7
(fast-import: Add support for importing commit notes, 2009-10-09)
The commit log has slightly different description than the added
documentation. The latter is somewhat confusing. "notemodify" is a
subcommand of "commit" command used to add a note for some commit.
Does this note annotate the commit produced by the "commit" command
or a commit given by it's committish parameter? Which notes tree
does it write notes to?

The exact meaning could be deduced with old description and some
notes machinery knowledge. But let's make it more obvious. This
command is used in a context like "commit refs/notes/test" to
add or rewrite an annotation for a committish parameter. So the
advised way to add notes in a fast-import stream is:
1) import some commits (optional)
2) prepare a "commit" to the notes tree:
2.1) choose notes ref, committer, log message, etc.
2.2) create annotations with "notemodify", where each can refer to
a commit being annotated via a branch name, import mark reference,
sha1 and other expressions specified in the Documentation.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-22 13:58:35 -07:00
Jack Nagel df6b0cad5f Documentation: minor grammatical fix in rev-list-options.txt
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-22 10:38:59 -07:00
Peter Collingbourne 0dc310e860 Documentation: git-filter-branch honors replacement refs
Make it clear that git-filter-branch will honor and make permanent
replacement refs as well as grafts.

Signed-off-by: Peter Collingbourne <peter@pcc.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-21 12:54:55 -07:00
Julian Phillips 6e8e67f307 remote-curl: Add a format check to parsing of info/refs
When parsing info/refs, no checks were applied that the file was in
the requried format.  Since the file is read from a remote webserver,
this isn't guarenteed to be true.  Add a check that the file at least
only contains lines that consist of 40 characters followed by a tab
and then the ref name.

Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-20 15:51:55 -07:00
Pavan Kumar Sunkara 8b5900751a git-config: Remove extra whitespaces
Remove extra whitespaces introduced by commits
01ebb9dc and fc1905bb

Signed-off-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-19 13:43:34 -07:00
Martin von Zweigbergk 5960bc9d63 rebase: clarify "restore the original branch"
The description for 'git rebase --abort' currently says:

    Restore the original branch and abort the rebase operation.

The "restore" can be misinterpreted to imply that the original branch
was somehow in a broken state during the rebase operation. It is also
not completely clear what "the original branch" is --- is it the
branch that was checked out before the rebase operation was called or
is the the branch that is being rebased (it is the latter)? Although
both issues are made clear in the DESCRIPTION section, let us also
make the entry in the OPTIONS secion more clear.

Also remove the term "rebasing process" from the usage text, since the
user already knows that the text is about "git rebase".

Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-13 22:03:12 -07:00
Junio C Hamano ff00b682f2 reset [<commit>] paths...: do not mishandle unmerged paths
Because "diff --cached HEAD" showed an incorrect blob object name on the
LHS of the diff, we ended up updating the index entry with bogus value,
not what we read from the tree.

Noticed by John Nowak.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-13 21:39:18 -07:00
Bert Wesarg cd8e3711bf Documentation: clearly specify what refs are honored by core.logAllRefUpdates
The documentation for logging updates in git-update-ref, doesn't make it
clear that only a specific subset of refs are honored by this variable.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-12 09:11:14 -07:00
Johannes Schindelin 7d092adc8f get_pwd_cwd(): Do not trust st_dev/st_ino blindly
10c4c88 (Allow add_path() to add non-existent directories to the path,
2008-07-21) introduced get_pwd_cwd() function in order to favor $PWD when
getenv("PWD") and getcwd() refer to the same directory but are different
strings (e.g. the former gives a nicer looking name via a symbolic link to
an uglier looking automounted path). The function tried to determine if
two directories are the same by running stat(2) on both and comparing
ino/dev fields.

Unfortunately, stat() does not fill any ino or dev fields in msysgit.  But
there is a telltale: both ino and dev are 0 when they are not filled
correctly, so let's be extra cautious.

This happens to fix a bug in "get-receive-pack working_directory/" when
the GIT_DIR would not be set correctly due to absolute_path(".")
returning the wrong value.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-11 10:52:38 -07:00
Michael Schubert 823e0ded8a help_unknown_cmd: do not propose an "unknown" cmd
When executing an external shell script like `git foo` with a bad
shebang, e.g. "#!/usr/bin/not/existing", execvp returns 127 (ENOENT).

Since help_unknown_cmd proposes the use of all external commands similar
to the name of the "unknown" command, it suggests the just failed command
again. Stop it and give some advice to the user.

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Michael Schubert <mschub@elegosoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-08 08:59:44 -07:00
Junio C Hamano 25d33546d4 Merge commit 'v1.7.6' into jc/checkout-reflog-fix
* commit 'v1.7.6': (3211 commits)
  Git 1.7.6
  completion: replace core.abbrevguard to core.abbrev
  Git 1.7.6-rc3
  Documentation: git diff --check respects core.whitespace
  gitweb: 'pickaxe' and 'grep' features requires 'search' to be enabled
  t7810: avoid unportable use of "echo"
  plug a few coverity-spotted leaks
  builtin/gc.c: add missing newline in message
  tests: link shell libraries into valgrind directory
  t/Makefile: pass test opts to valgrind target properly
  sh-i18n--envsubst.c: do not #include getopt.h
  Fix typo: existant->existent
  Git 1.7.6-rc2
  gitweb: do not misparse nonnumeric content tag files that contain a digit
  Git 1.7.6-rc1
  fetch: do not leak a refspec
  t3703: skip more tests using colons in file names on Windows
  gitweb: Fix usability of $prevent_xss
  gitweb: Move "Requirements" up in gitweb/INSTALL
  gitweb: Describe CSSMIN and JSMIN in gitweb/INSTALL
  ...
2011-07-06 15:38:28 -07:00
Junio C Hamano 71ee7fd154 Merge commit 'v1.7.0' into jc/checkout-reflog-fix
* commit 'v1.7.0': (4188 commits)
  Git 1.7.0
  Fix typo in 1.6.6.2 release notes
  Re-fix check-ref-format documentation mark-up
  archive documentation: attributes are taken from the tree by default
  Documentation: minor fixes to RelNotes-1.7.0
  bash: support 'git am's new '--continue' option
  filter-branch: Fix error message for --prune-empty --commit-filter
  am: switch --resolved to --continue
  Update draft release notes to 1.7.0 one more time
  Git 1.6.6.2
  t8003: check exit code of command and error message separately
  check-ref-format documentation: fix enumeration mark-up
  Documentation: quote braces in {upstream} notation
  t3902: Protect against OS X normalization
  blame: prevent a segv when -L given start > EOF
  git-push: document all the status flags used in the output
  Fix parsing of imap.preformattedHTML and imap.sslverify
  git-add documentation: Fix shell quoting example
  Revert "pack-objects: fix pack generation when using pack_size_limit"
  archive: simplify archive format guessing
  ...
2011-07-06 15:38:18 -07:00
Junio C Hamano 4d9e42f8f1 Merge commit 'v1.6.0' into jc/checkout-reflog-fix
* commit 'v1.6.0': (2063 commits)
  GIT 1.6.0
  git-p4: chdir now properly sets PWD environment variable in msysGit
  Improve error output of git-rebase
  t9300: replace '!' with test_must_fail
  Git.pm: Make File::Spec and File::Temp requirement lazy
  Documentation: document the pager.* configuration setting
  git-stash: improve synopsis in help and manual page
  Makefile: building git in cygwin 1.7.0
  git-am: ignore --binary option
  bash-completion: Add non-command git help files to bash-completion
  Fix t3700 on filesystems which do not support question marks in names
  Utilise our new p4_read_pipe and p4_write_pipe wrappers
  Add p4 read_pipe and write_pipe wrappers
  bash completion: Add '--merge' long option for 'git log'
  bash completion: Add completion for 'git mergetool'
  git format-patch documentation: clarify what --cover-letter does
  bash completion: 'git apply' should use 'fix' not 'strip'
  t5304-prune: adjust file mtime based on system time rather than file mtime
  test-parse-options: use appropriate cast in length_callback
  Fix escaping of glob special characters in pathspecs
  ...

Conflicts:
	builtin-checkout.c
2011-07-06 15:37:42 -07:00
Junio C Hamano c5bcf1f9f6 checkout: do not write bogus reflog entry out
As resolve_ref() returns a static buffer that is local to the function,
the caller needs to be sure that it will not have any other calls to the
function before it uses the returned value, or store it away with a
strdup().  The code used old.path to record which branch it used to be on,
so that it can say between which branches the switch took place in the
reflog, but sometimes it failed to do so.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-06 15:15:02 -07:00
Martin von Zweigbergk 7791a1d9b9 Documentation: use [verse] for SYNOPSIS sections
The SYNOPSIS sections of most commands that span several lines already
use [verse] to retain line breaks. Most commands that don't span
several lines seem not to use [verse]. In the HTML output, [verse]
does not only preserve line breaks, but also makes the section
indented, which causes a slight inconsistency between commands that
use [verse] and those that don't. Use [verse] in all SYNOPSIS sections
for consistency.

Also remove the blank lines from git-fetch.txt and git-rebase.txt to
align with the other man pages. In the case of git-rebase.txt, which
already uses [verse], the blank line makes the [verse] not apply to
the last line, so removing the blank line also makes the formatting
within the document more consistent.

While at it, add single quotes to 'git cvsimport' for consistency with
other commands.

Signed-off-by: Martin von Zweigbergk <martin.von.zweigbergk@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-06 14:26:26 -07:00
Jeff King d28790dc31 docs: document --textconv diff option
This has been there since textconv existed, but was never
documented. There is some overlap with what's in
gitattributes(5), but it's important to warn in both places
that textconv diffs probably can't be applied.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-06 11:10:11 -07:00
Jakub Narebski e8c3531717 gitweb: Serve */*+xml 'blob_plain' as text/plain with $prevent_xss
Enhance usability of 'blob_plain' view protection against XSS attacks
(enabled by setting $prevent_xss to true) by serving contents inline
as safe 'text/plain' mimetype where possible, instead of serving with
"Content-Disposition: attachment" to make sure they don't run in
gitweb's security domain.

This patch broadens downgrading to 'text/plain' further, to any
*/*+xml mimetype.  This includes:

  application/xhtml+xml    (*.xhtml, *.xht)
  application/atom+xml     (*.atom)
  application/rss+xml      (*.rss)
  application/mathml+xm    (*.mathml)
  application/docbook+xml  (*.docbook)
  image/svg+xml            (*.svg, *.svgz)

Probably most useful is serving XHTML files as text/plain in
'blob_plain' view, directly viewable.

Because file with 'image/svg+xml' mimetype can be compressed SVGZ
file, we have to check if */*+xml really is text file, via '-T $fd'.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-30 11:26:48 -07:00