Revision 3ec804490a265f4c418a321428c12f3f18b7eff5 authored by Jeff King on 29 April 2017, 12:36:44 UTC, committed by Junio C Hamano on 05 May 2017, 03:07:27 UTC
When a remote server uses git-shell, the client side will
connect to it like:

  ssh server "git-upload-pack 'foo.git'"

and we literally exec ("git-upload-pack", "foo.git"). In
early versions of upload-pack and receive-pack, we took a
repository argument and nothing else. But over time they
learned to accept dashed options. If the user passes a
repository name that starts with a dash, the results are
confusing at best (we complain of a bogus option instead of
a non-existent repository) and malicious at worst (the user
can start an interactive pager via "--help").

We could pass "--" to the sub-process to make sure the
user's argument is interpreted as a branch name. I.e.:

  git-upload-pack -- -foo.git

But adding "--" automatically would make us inconsistent
with a normal shell (i.e., when git-shell is not in use),
where "-foo.git" would still be an error. For that case, the
client would have to specify the "--", but they can't do so
reliably, as existing versions of git-shell do not allow
more than a single argument.

The simplest thing is to simply disallow "-" at the start of
the repo name argument. This hasn't worked either with or
without git-shell since version 1.0.0, and nobody has
complained.

Note that this patch just applies to do_generic_cmd(), which
runs upload-pack, receive-pack, and upload-archive. There
are two other types of commands that git-shell runs:

  - do_cvs_cmd(), but this already restricts the argument to
    be the literal string "server"

  - admin-provided commands in the git-shell-commands
    directory. We'll pass along arbitrary arguments there,
    so these commands could have similar problems. But these
    commands might actually understand dashed arguments, so
    we cannot just block them here. It's up to the writer of
    the commands to make sure they are safe. With great
    power comes great responsibility.

Reported-by: Timo Schmid <tschmid@ernw.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7654286
Raw File
git-shortlog.txt
git-shortlog(1)
===============

NAME
----
git-shortlog - Summarize 'git log' output

SYNOPSIS
--------
[verse]
git log --pretty=short | 'git shortlog' [<options>]
'git shortlog' [<options>] [<revision range>] [[\--] <path>...]

DESCRIPTION
-----------
Summarizes 'git log' output in a format suitable for inclusion
in release announcements. Each commit will be grouped by author and title.

Additionally, "[PATCH]" will be stripped from the commit description.

If no revisions are passed on the command line and either standard input
is not a terminal or there is no current branch, 'git shortlog' will
output a summary of the log read from standard input, without
reference to the current repository.

OPTIONS
-------

-n::
--numbered::
	Sort output according to the number of commits per author instead
	of author alphabetic order.

-s::
--summary::
	Suppress commit description and provide a commit count summary only.

-e::
--email::
	Show the email address of each author.

--format[=<format>]::
	Instead of the commit subject, use some other information to
	describe each commit.  '<format>' can be any string accepted
	by the `--format` option of 'git log', such as '* [%h] %s'.
	(See the "PRETTY FORMATS" section of linkgit:git-log[1].)

	Each pretty-printed commit will be rewrapped before it is shown.

-w[<width>[,<indent1>[,<indent2>]]]::
	Linewrap the output by wrapping each line at `width`.  The first
	line of each entry is indented by `indent1` spaces, and the second
	and subsequent lines are indented by `indent2` spaces. `width`,
	`indent1`, and `indent2` default to 76, 6 and 9 respectively.
+
If width is `0` (zero) then indent the lines of the output without wrapping
them.

<revision range>::
	Show only commits in the specified revision range.  When no
	<revision range> is specified, it defaults to `HEAD` (i.e. the
	whole history leading to the current commit).  `origin..HEAD`
	specifies all the commits reachable from the current commit
	(i.e. `HEAD`), but not from `origin`. For a complete list of
	ways to spell <revision range>, see the "Specifying Ranges"
	section of linkgit:gitrevisions[7].

[\--] <path>...::
	Consider only commits that are enough to explain how the files
	that match the specified paths came to be.
+
Paths may need to be prefixed with "\-- " to separate them from
options or the revision range, when confusion arises.

MAPPING AUTHORS
---------------

The `.mailmap` feature is used to coalesce together commits by the same
person in the shortlog, where their name and/or email address was
spelled differently.

include::mailmap.txt[]

GIT
---
Part of the linkgit:git[1] suite
back to top