git
10 years agogitweb: Add a feature for adding more branch refs
Krzesimir Nowak [Wed, 11 Dec 2013 11:54:43 +0000 (12:54 +0100)] 
gitweb: Add a feature for adding more branch refs

Allow extra-branch-refs feature to tell gitweb to show refs from
additional hierarchies in addition to branches in the list-of-branches
view.

Signed-off-by: Krzesimir Nowak <krzesimir@endocode.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogitweb: Return 1 on validation success instead of passed input
Krzesimir Nowak [Wed, 11 Dec 2013 11:54:42 +0000 (12:54 +0100)] 
gitweb: Return 1 on validation success instead of passed input

Users of validate_* passing "0" might get failures on correct name
because of coercion of "0" to false in code like:
die_error(500, "invalid ref") unless (check_ref_format ("0"));

Also, the validate_foo subs are renamed to is_valid_foo.

Signed-off-by: Krzesimir Nowak <krzesimir@endocode.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogitweb: Move check-ref-format code into separate function
Krzesimir Nowak [Wed, 11 Dec 2013 11:54:41 +0000 (12:54 +0100)] 
gitweb: Move check-ref-format code into separate function

This check will be used in more than one place later.

Signed-off-by: Krzesimir Nowak <krzesimir@endocode.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agodiff: don't read index when --no-index is given
Thomas Gummerer [Wed, 11 Dec 2013 09:58:43 +0000 (10:58 +0100)] 
diff: don't read index when --no-index is given

git diff --no-index ... currently reads the index, during setup, when
calling gitmodules_config().  This results in worse performance when the
index is not actually needed.  This patch avoids calling
gitmodules_config() when the --no-index option is given.  The times for
executing "git diff --no-index" in the WebKit repository are improved as
follows:

Test                      HEAD~3            HEAD
------------------------------------------------------------------
4001.1: diff --no-index   0.24(0.15+0.09)   0.01(0.00+0.00) -95.8%

An additional improvement of this patch is that "git diff --no-index" no
longer breaks when the index file is corrupt, which makes it possible to
use it for investigating the broken repository.

To improve the possible usage as investigation tool for broken
repositories, setup_git_directory_gently() is also not called when the
--no-index option is given.

Also add a test to guard against future breakages, and a performance
test to show the improvements.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agodiff: move no-index detection to builtin/diff.c
Thomas Gummerer [Wed, 11 Dec 2013 09:58:42 +0000 (10:58 +0100)] 
diff: move no-index detection to builtin/diff.c

Currently the --no-index option is parsed in diff_no_index().  Move the
detection if a no-index diff should be executed to builtin/diff.c, where
we can use it for executing diff_no_index() conditionally.  This will
also allow us to execute other operations conditionally, which will be
done in the next patch.

There are no functional changes.

Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoDocumentation/git-replace: describe --format option
Christian Couder [Wed, 11 Dec 2013 07:46:13 +0000 (08:46 +0100)] 
Documentation/git-replace: describe --format option

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agobuiltin/replace: unset read_replace_refs
Christian Couder [Wed, 11 Dec 2013 07:46:12 +0000 (08:46 +0100)] 
builtin/replace: unset read_replace_refs

When checking to see if some objects are of the same type
and when displaying the type of objects, git replace uses
the sha1_object_info() function.

Unfortunately this function by default respects replace
refs, so instead of the type of a replaced object, it
gives the type of the replacement object which might
be different.

To fix this bug, and because git replace should work at a
level before replacement takes place, let's unset the
read_replace_refs global variable at the beginning of
cmd_replace().

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agot6050: add tests for listing with --format
Christian Couder [Wed, 11 Dec 2013 07:46:11 +0000 (08:46 +0100)] 
t6050: add tests for listing with --format

This patch adds tests for "git replace -l --format=<fmt>".

'short', 'medium' and 'full' are the only allowed values
for <fmt>.

'short' is the same as with no --format option.
Tests for 'medium' and 'full' are the most needed.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agobuiltin/replace: teach listing using short, medium or full formats
Christian Couder [Wed, 11 Dec 2013 07:46:10 +0000 (08:46 +0100)] 
builtin/replace: teach listing using short, medium or full formats

By default when listing replace refs, only the sha1 of the
replaced objects are shown.

In many cases, it is much nicer to be able to list all the
sha1 of the replaced objects along with the sha1 of the
replacment objects.

And in other cases it might be interesting to also show the
types of the replaced and replacement objects.

This patch introduce a new --format=<fmt> option where
<fmt> can be any of the following:

'short': this is the same as when no --format
option is used, that is only the sha1 of
the replaced objects are shown
'medium': this also lists the sha1 of the
replacement objects
'full': this shows the sha1 and the type of both
the replaced and the replacement objects

Some documentation and some tests will follow.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agosha1_file: perform object replacement in sha1_object_info_extended()
Christian Couder [Wed, 11 Dec 2013 07:46:09 +0000 (08:46 +0100)] 
sha1_file: perform object replacement in sha1_object_info_extended()

sha1_object_info_extended() should perform object replacement
if it is needed.

The simplest way to do that is to make it call
lookup_replace_object_extended().

And now its "unsigned flags" parameter is used as it is passed
to lookup_replace_object_extended().

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agot6050: show that git cat-file --batch fails with replace objects
Christian Couder [Wed, 11 Dec 2013 07:46:08 +0000 (08:46 +0100)] 
t6050: show that git cat-file --batch fails with replace objects

When --batch is passed to git cat-file, the sha1_object_info_extended()
function is used to get information about the objects passed to
git cat-file.

Unfortunately sha1_object_info_extended() doesn't take care of
object replacement properly, so it will often fail with a
message like this:

$ echo a3fb2e1845a1aaf129b7975048973414dc172173 | git cat-file --batch
a3fb2e1845a1aaf129b7975048973414dc172173 commit 231
fatal: object a3fb2e1845a1aaf129b7975048973414dc172173 change size!?

The goal of this patch is to show this breakage.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agosha1_object_info_extended(): add an "unsigned flags" parameter
Christian Couder [Wed, 11 Dec 2013 07:46:07 +0000 (08:46 +0100)] 
sha1_object_info_extended(): add an "unsigned flags" parameter

This parameter is not used yet, but it will be used to tell
sha1_object_info_extended() if it should perform object
replacement or not.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agosha1_file.c: add lookup_replace_object_extended() to pass flags
Christian Couder [Wed, 11 Dec 2013 07:46:06 +0000 (08:46 +0100)] 
sha1_file.c: add lookup_replace_object_extended() to pass flags

Currently, there is only one caller to lookup_replace_object()
that can benefit from passing it some flags, but we expect
that there could be more.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoreplace_object: don't check read_replace_refs twice
Christian Couder [Wed, 11 Dec 2013 07:46:05 +0000 (08:46 +0100)] 
replace_object: don't check read_replace_refs twice

Since e1111cef (inline lookup_replace_object() calls,
May 15 2011) the read_replace_refs global variable is
checked twice, once in lookup_replace_object() and
once again in do_lookup_replace_object().

As do_lookup_replace_object() is called only from
lookup_replace_object(), we can remove the check in
do_lookup_replace_object().

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorename READ_SHA1_FILE_REPLACE flag to LOOKUP_REPLACE_OBJECT
Christian Couder [Wed, 11 Dec 2013 07:46:04 +0000 (08:46 +0100)] 
rename READ_SHA1_FILE_REPLACE flag to LOOKUP_REPLACE_OBJECT

The READ_SHA1_FILE_REPLACE flag is more related to using the
lookup_replace_object() function rather than the
read_sha1_file() function.

We also need such a flag to be used with sha1_object_info()
instead of read_sha1_file().

The name LOOKUP_REPLACE_OBJECT is therefore better for this
flag.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocat-file: handle --batch format with missing type/size
Jeff King [Wed, 11 Dec 2013 23:15:50 +0000 (07:15 +0800)] 
cat-file: handle --batch format with missing type/size

Commit 98e2092 taught cat-file to stream blobs with --batch,
which requires that we look up the object type before
loading it into memory.  As a result, we now print the
object header from information in sha1_object_info, and the
actual contents from the read_sha1_file. We double-check
that the information we printed in the header matches the
content we are about to show.

Later, commit 93d2a60 allowed custom header lines for
--batch, and commit 5b08640 made type lookups optional. As a
result, specifying a header line without the type or size
means that we will not look up those items at all.

This causes our double-checking to erroneously die with an
error; we think the type or size has changed, when in fact
it was simply left at "0".

For the size, we can fix this by only doing the consistency
double-check when we have retrieved the size via
sha1_object_info. In the case that we have not retrieved the
value, that means we also did not print it, so there is
nothing for us to check that we are consistent with.

We could do the same for the type. However, besides our
consistency check, we also care about the type in deciding
whether to stream or not. So instead of handling the case
where we do not know the type, this patch instead makes sure
that we always trigger a type lookup when we are printing,
so that even a format without the type will stream as we
would in the normal case.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocat-file: pass expand_data to print_object_or_die
Jeff King [Wed, 11 Dec 2013 23:01:42 +0000 (07:01 +0800)] 
cat-file: pass expand_data to print_object_or_die

We currently individually pass the sha1, type, and size
fields calculated by sha1_object_info. However, if we pass
the whole struct, the called function can make more
intelligent decisions about which fields were actually
filled by sha1_object_info.

This patch takes that first refactoring step, passing the
whole struct, so further patches can make those decisions
with less noise in their diffs. There should be no
functional change to this patch (aside from a minor typo fix
in the error message).

As a side effect, we can rename the local variables in the
function to "type" and "size", since the names are no longer
taken.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorebase: use reflog to find common base with upstream
John Keeping [Mon, 9 Dec 2013 23:16:16 +0000 (23:16 +0000)] 
rebase: use reflog to find common base with upstream

Commit 15a147e (rebase: use @{upstream} if no upstream specified,
2011-02-09) says:

Make it default to 'git rebase @{upstream}'. That is also what
'git pull [--rebase]' defaults to, so it only makes sense that
'git rebase' defaults to the same thing.

but that isn't actually the case.  Since commit d44e712 (pull: support
rebased upstream + fetch + pull --rebase, 2009-07-19), pull has actually
chosen the most recent reflog entry which is an ancestor of the current
branch if it can find one.

Add a '--fork-point' argument to git-rebase that can be used to trigger
this behaviour.  This option is turned on by default if no non-option
arguments are specified on the command line, otherwise we treat an
upstream specified on the command-line literally.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoMerge git://repo.or.cz/git-gui
Junio C Hamano [Mon, 9 Dec 2013 22:57:00 +0000 (14:57 -0800)] 
Merge git://repo.or.cz/git-gui

* git://repo.or.cz/git-gui:
  git-gui: correct spelling errors in comments
  git-gui: add menu item to launch a bash shell on Windows.
  git-gui: corrected setup of git worktree under cygwin.
  git-gui: right half window is paned
  git-gui: Add gui.displayuntracked option
  git-gui: show the maxrecentrepo config option in the preferences dialog
  git-gui: added gui.maxrecentrepo to extend the number of remembered repos
  git-gui: Improve font rendering on retina macbooks

10 years agoMerge git://ozlabs.org/~paulus/gitk
Junio C Hamano [Mon, 9 Dec 2013 22:55:41 +0000 (14:55 -0800)] 
Merge git://ozlabs.org/~paulus/gitk

* git://ozlabs.org/~paulus/gitk:
  gitk: Recognize -L option
  gitk: Support showing the gathered inline diffs
  gitk: Split out diff part in $commitinfo
  gitk: Refactor per-line part of getblobdiffline and its support
  gitk: Support -G option from the command line
  gitk: Tag display improvements

10 years agogit_connect(): use common return point
Torsten Bögershausen [Thu, 28 Nov 2013 19:50:15 +0000 (20:50 +0100)] 
git_connect(): use common return point

Use only one return point from git_connect(), doing the

    free();
    return conn;

only at one place in the code.

There may be a little confusion what the variable "host" is for.  At
some places it is only the host part, at other places it may include
the port number, so change host into hostandport here.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoconnect.c: refactor url parsing
Torsten Bögershausen [Thu, 28 Nov 2013 19:50:03 +0000 (20:50 +0100)] 
connect.c: refactor url parsing

Make the function is_local() in transport.c public, rename it into
url_is_local_not_ssh() and use it in both transport.c and connect.c

Use a protocol "local" for URLs for the local file system.

One note about using file:// under Windows:

The (absolute) path on Unix like system typically starts with "/".
When the host is empty, it can be omitted, so that a shell scriptlet
url=file://$pwd
will give a URL like "file:///home/user/repo".

Windows does not have the same concept of a root directory located in "/".
When parsing the URL allow "file://C:/user/repo"
(even if RFC1738 indicates that "file:///C:/user/repo" should be used).

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit_connect(): refactor the port handling for ssh
Torsten Bögershausen [Thu, 28 Nov 2013 19:49:54 +0000 (20:49 +0100)] 
git_connect(): refactor the port handling for ssh

Use get_host_and_port() even for ssh.
Remove the variable port git_connect(), and simplify parse_connect_url()
Use only one return point in git_connect(), doing the free() and return conn.

t5601 had 2 corner test cases which now pass.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit fetch: support host:/~repo
Torsten Bögershausen [Thu, 28 Nov 2013 19:49:38 +0000 (20:49 +0100)] 
git fetch: support host:/~repo

The documentation (in urls.txt) says that

    "ssh://host:/~repo",
    "host:/~repo" or
    "host:~repo"

specify the repository "repo" in the home directory at "host".

This has not been working for "host:/~repo".

Before commit 356bec "Support [address] in URLs", the comparison
"url != hostname" could be used to determine if the URL had a scheme
or not: "ssh://host/host" != "host".

However, after 356bec "[::1]" was converted into "::1", yielding
url != hostname as well.  To fix this regression, don't use
"if (url != hostname)", but look at the separator instead.

Rename the variable "c" into "separator" to make it easier to read.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agot5500: add test cases for diag-url
Torsten Bögershausen [Thu, 28 Nov 2013 19:49:29 +0000 (20:49 +0100)] 
t5500: add test cases for diag-url

Add test cases using git fetch-pack --diag-url:

- parse out host and path for URLs with a scheme (git:// file:// ssh://)
- parse host names embedded by [] correctly
- extract the port number, if present
- separate URLs like "file" (which are local)
  from URLs like "host:repo" which should use ssh

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit fetch-pack: add --diag-url
Torsten Bögershausen [Thu, 28 Nov 2013 19:49:17 +0000 (20:49 +0100)] 
git fetch-pack: add --diag-url

The main purpose is to trace the URL parser called by git_connect() in
connect.c

The main features of the parser can be listed as this:

- parse out host and path for URLs with a scheme (git:// file:// ssh://)
- parse host names embedded by [] correctly
- extract the port number, if present
- separate URLs like "file" (which are local)
  from URLs like "host:repo" which should use ssh

Add the new parameter "--diag-url" to "git fetch-pack", which prints
the value for protocol, host and path to stderr and exits.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit_connect: factor out discovery of the protocol and its parts
Johannes Sixt [Thu, 28 Nov 2013 19:49:01 +0000 (20:49 +0100)] 
git_connect: factor out discovery of the protocol and its parts

git_connect has grown large due to the many different protocols syntaxes
that are supported. Move the part of the function that parses the URL to
connect to into a separate function for readability.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogit_connect: remove artificial limit of a remote command
Johannes Sixt [Thu, 28 Nov 2013 19:48:45 +0000 (20:48 +0100)] 
git_connect: remove artificial limit of a remote command

Since day one, function git_connect() had a limit on the command line of
the command that is invoked to make a connection. 7a33bcbe converted the
code that constructs the command to strbuf. This would have been the
right time to remove the limit, but it did not happen. Remove it now.

git_connect() uses start_command() to invoke the command; consequently,
the limits of the system still apply, but are diagnosed only at execve()
time. But these limits are more lenient than the 1K that git_connect()
imposed.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorev-parse: be more careful with munging arguments
Jeff King [Fri, 6 Dec 2013 22:07:52 +0000 (17:07 -0500)] 
rev-parse: be more careful with munging arguments

When rev-parse looks at whether an argument like "foo..bar" or
"foobar^@" is a difference or parent-shorthand, it internally
munges the arguments so that it can pass the individual rev
arguments to get_sha1(). However, we do not consistently un-munge
the result.

For cases where we do not match (e.g., "doesnotexist..HEAD"), we
would then want to try to treat the argument as a filename.
try_difference gets() this right, and always unmunges in this case.
However, try_parent_shorthand() never unmunges, leading to incorrect
error messages, or even incorrect results:

  $ git rev-parse foobar^@
  foobar
  fatal: ambiguous argument 'foobar': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

  $ >foobar
  $ git rev-parse foobar^@
  foobar

For cases where we do match, neither function unmunges. This does
not currently matter, since we are done with the argument. However,
a future patch will do further processing, and this prepares for
it. In addition, it's simply a confusing interface for some cases to
modify the const argument, and others not to.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoremote: fix status with branch...rebase=preserve
Felipe Contreras [Sat, 7 Dec 2013 13:08:37 +0000 (07:08 -0600)] 
remote: fix status with branch...rebase=preserve

Commit 66713ef (pull: allow pull to preserve merges when rebasing)
didn't include an update so 'git remote status' parses branch.<name>.rebase=preserve
correctly, let's do that.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoDocumentation: document pitfalls with 3-way merge
brian m. carlson [Sun, 8 Dec 2013 20:40:27 +0000 (20:40 +0000)] 
Documentation: document pitfalls with 3-way merge

Oftentimes people will make the same change in two branches, revert the change
in one branch, and then be surprised when a merge reinstitutes that change when
the branches are merged.  Add an explanatory paragraph that explains that this
occurs and the reason why, so people are not surprised.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agofetch: add missing documentation
Felipe Contreras [Sun, 8 Dec 2013 05:56:58 +0000 (23:56 -0600)] 
fetch: add missing documentation

There's no mention of the 'origin' default, or the fact that the
upstream tracking branch remote is used.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agot: trivial whitespace cleanups
Felipe Contreras [Sun, 8 Dec 2013 05:56:57 +0000 (23:56 -0600)] 
t: trivial whitespace cleanups

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoabspath: trivial style fix
Felipe Contreras [Sun, 8 Dec 2013 05:56:56 +0000 (23:56 -0600)] 
abspath: trivial style fix

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoremote-hg: add tests for special filenames
Felipe Contreras [Sat, 7 Dec 2013 13:09:43 +0000 (07:09 -0600)] 
remote-hg: add tests for special filenames

So that we check that UTF-8 and spaces work fine.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoremote-hg: fix 'shared path' path
Felipe Contreras [Sat, 7 Dec 2013 13:09:42 +0000 (07:09 -0600)] 
remote-hg: fix 'shared path' path

If the repository is moved, the absolute path of the shared repository
would fail.

Make sure it's always up-to-date.

Reported-by: Michael Davis <mjmdavis@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoremote-helpers: add extra safety checks
Felipe Contreras [Sat, 7 Dec 2013 13:09:41 +0000 (07:09 -0600)] 
remote-helpers: add extra safety checks

Suggested-by: Roman Ovchinnikov <coolthecold@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoremote-hg: avoid buggy strftime()
jcb91 [Sat, 7 Dec 2013 13:09:40 +0000 (07:09 -0600)] 
remote-hg: avoid buggy strftime()

  error on pull: fatal: Invalid raw date "" in ident: remote-hg <>

Neither %s nor %z are officially supported by python, they may work on
some (most?) platforms, but not all.

removed strftime use of %s and %z, which are not officially supported by python, with standard formats

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agopull: use merge-base --fork-point when appropriate
John Keeping [Sun, 8 Dec 2013 12:47:25 +0000 (12:47 +0000)] 
pull: use merge-base --fork-point when appropriate

Since commit d96855f (merge-base: teach "--fork-point" mode, 2013-10-23)
we can replace a shell loop in git-pull with a single call to
git-merge-base.  So let's do so.

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoparse-options: remove OPT_BOOLEAN
Nguyễn Thái Ngọc Duy [Sat, 7 Dec 2013 05:02:53 +0000 (12:02 +0700)] 
parse-options: remove OPT_BOOLEAN

After a86a8b9 (sb/parseopt-boolean-removal), the deprecated
OPT_BOOLEAN is not used anywhere except by OPT__* macros. Kill
OPT_BOOLEAN and make OPT__* use OPT_COUNTUP directly instead. This
should stop OPT_BOOLEAN from entering the tree again in new patches.

OPT__DRY_RUN() is converted to use OPT_BOOL though because it does not
make sense to increase the level of dryness. All OPT__DRY_RUN call
sites have been checked and they look safe for OPT_BOOL.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agorev-parse: correctly diagnose revision errors before "--"
Jeff King [Fri, 6 Dec 2013 22:05:48 +0000 (17:05 -0500)] 
rev-parse: correctly diagnose revision errors before "--"

Rev-parse understands that a "--" may separate revisions and
filenames, and that anything after the "--" is taken as-is.
However, it does not understand that anything before the
token must be a revision (which is the usual rule
implemented by the setup_revisions parser).

Since rev-parse prefers revisions to files when parsing
before the "--", we end up with the correct result (if such
an argument is a revision, we parse it as one, and if it is
not, it is an error either way).  However, we misdiagnose
the errors:

  $ git rev-parse foobar -- >/dev/null
  fatal: ambiguous argument 'foobar': unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

  $ >foobar
  $ git rev-parse foobar -- >/dev/null
  fatal: bad flag '--' used after filename

In both cases, we should know that the real error is that
"foobar" is meant to be a revision, but could not be
resolved.

Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogitignore.txt: clarify recursive nature of excluded directories
Karsten Blees [Thu, 7 Nov 2013 21:36:29 +0000 (22:36 +0100)] 
gitignore.txt: clarify recursive nature of excluded directories

Additionally, precedence of negated patterns is exactly as outlined in
the DESCRIPTION section, we don't need to repeat this.

Signed-off-by: Karsten Blees <blees@dcon.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agodifftool: display the number of files in the diff queue in the prompt
Zoltan Klinger [Thu, 5 Dec 2013 23:38:46 +0000 (10:38 +1100)] 
difftool: display the number of files in the diff queue in the prompt

When --prompt option is set, git-difftool displays a prompt for each
modified file to be viewed in an external diff program.  At that
point, it could be useful to display a counter and the total number
of files in the diff queue.

Below is the current difftool prompt for the first of 5 modified files:

    Viewing: 'diff.c'
    Launch 'vimdiff' [Y/n]:

Consider the modified prompt:

    Viewing (1/5): 'diff.c'
    Launch 'vimdiff' [Y/n]:

The current GIT_EXTERNAL_DIFF mechanism does not tell the number of
paths in the diff queue nor the current counter.  To make this
"counter/total" info available for GIT_EXTERNAL_DIFF programs
without breaking existing ones by doing the following:

 - Keep track of the number of paths shown so far in diff_options;

 - Export two new environment variables from run_external_diff() to
   show the total number of paths (from diff_queue_struct) and the
   current value of the counter (from diff_options); and

 - Update git-difftool--helper to use these two environment variables.

Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agopathspec.c: support adding prefix magic to a pathspec with mnemonic magic
Nguyễn Thái Ngọc Duy [Fri, 6 Dec 2013 07:30:49 +0000 (14:30 +0700)] 
pathspec.c: support adding prefix magic to a pathspec with mnemonic magic

Back in 233c3e6 (parse_pathspec: preserve prefix length via
PATHSPEC_PREFIX_ORIGIN - 2013-07-14), parse_pathspec() is taught to
save prefix length as a dynamic magic. This is needed when the
pathspec is passed to another process and and prefix lenght would be
lost.

Back then we support two cases. If the pathspec is normal, e.g. "abc",
we simply add the prefix to become ":(prefix:2)abc". If the pathspec
contains long magic, e.g. ":(foo,bar)abc" then we turn it to
":(foo,bar,prefix:2)abc". We do not support prefixing on short form,
because the only supported mnemonic '/' disappears after the the
preprocessing steps.

With the introduction of exclude magic with mnemonic '!', we need to
add support for the short form case so that ':!abc' becomes
':(exclude,prefix:2)abc'. Without this, it will break

    cd Documentation
    git add -p -- . ':!technical'

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoSupport pathspec magic :(exclude) and its short form :!
Nguyễn Thái Ngọc Duy [Fri, 6 Dec 2013 07:30:48 +0000 (14:30 +0700)] 
Support pathspec magic :(exclude) and its short form :!

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoglossary-content.txt: rephrase magic signature part
Nguyễn Thái Ngọc Duy [Fri, 6 Dec 2013 07:30:47 +0000 (14:30 +0700)] 
glossary-content.txt: rephrase magic signature part

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoclone,fetch: catch non positive --depth option value
Nguyễn Thái Ngọc Duy [Thu, 5 Dec 2013 03:31:11 +0000 (10:31 +0700)] 
clone,fetch: catch non positive --depth option value

Instead of simply ignoring the value passed to --depth option when
it is zero or negative, catch and report it as an error to let
people know that they were using the option incorrectly.

Original-patch-by: Andrés G. Aragoneses <knocte@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoconfig: arbitrary number of matches for --unset and --replace-all
Thomas Rast [Wed, 13 Nov 2013 10:19:00 +0000 (11:19 +0100)] 
config: arbitrary number of matches for --unset and --replace-all

git-config used a static match array to hold the matches we want to
unset/replace when using --unset or --replace-all.  Use a
variable-sized array instead.

This in particular fixes the symptoms git-svn had when storing large
numbers of svn-remote.*.added-placeholder entries in the config file.

While the tests are rather more paranoid than just --unset and
--replace-all, the other operations already worked.  Indeed git-svn's
usage only breaks the first time *after* creating so many entries,
when it wants to unset and re-add them all.

Reported-by: Jess Hottenstein <jess.hottenstein@gmail.com>
Signed-off-by: Thomas Rast <tr@thomasrast.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoStart 1.9 cycle
Junio C Hamano [Fri, 6 Dec 2013 19:20:04 +0000 (11:20 -0800)] 
Start 1.9 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoMerge branch 'jk/remove-experimental-loose-object-support'
Junio C Hamano [Fri, 6 Dec 2013 19:09:42 +0000 (11:09 -0800)] 
Merge branch 'jk/remove-experimental-loose-object-support'

* jk/remove-experimental-loose-object-support:
  drop support for "experimental" loose objects

10 years agoMerge branch 'nd/magic-pathspec'
Junio C Hamano [Fri, 6 Dec 2013 19:08:03 +0000 (11:08 -0800)] 
Merge branch 'nd/magic-pathspec'

"git diff -- ':(icase)makefile'" were rejected unnecessarily.
This needs to be merged to 'maint' later.

* nd/magic-pathspec:
  diff: restrict pathspec limitations to diff b/f case only

10 years agoMerge branch 'rr/for-each-ref-decoration'
Junio C Hamano [Fri, 6 Dec 2013 19:07:20 +0000 (11:07 -0800)] 
Merge branch 'rr/for-each-ref-decoration'

Add a few formatting directives to "git for-each-ref --format=...",
to paint them in color, etc.

* rr/for-each-ref-decoration:
  for-each-ref: avoid color leakage
  for-each-ref: introduce %(color:...) for color
  for-each-ref: introduce %(upstream:track[short])
  for-each-ref: introduce %(HEAD) asterisk marker
  t6300 (for-each-ref): don't hardcode SHA-1 hexes
  t6300 (for-each-ref): clearly demarcate setup

10 years agoMerge branch 'jc/bundle'
Junio C Hamano [Fri, 6 Dec 2013 19:07:14 +0000 (11:07 -0800)] 
Merge branch 'jc/bundle'

Code clean-up.

* jc/bundle:
  bundle: use argv-array

10 years agoMerge branch 'rh/remote-hg-bzr-updates'
Junio C Hamano [Fri, 6 Dec 2013 19:06:52 +0000 (11:06 -0800)] 
Merge branch 'rh/remote-hg-bzr-updates'

Updates to remote-bzr and remote-hg in contrib.

* rh/remote-hg-bzr-updates:
  remote-bzr, remote-hg: fix email address regular expression
  test-hg.sh: help user correlate verbose output with email test
  test-hg.sh: fix duplicate content strings in author tests
  test-hg.sh: avoid obsolete 'test' syntax
  test-hg.sh: eliminate 'local' bashism
  test-bzr.sh, test-hg.sh: prepare for change to push.default=simple
  test-bzr.sh, test-hg.sh: allow running from any dir
  test-lib.sh: convert $TEST_DIRECTORY to an absolute path

10 years agoMerge branch 'jn/perl-lib-extra'
Junio C Hamano [Fri, 6 Dec 2013 19:05:38 +0000 (11:05 -0800)] 
Merge branch 'jn/perl-lib-extra'

Allow customizing the paths to Perl modules with the new
PERLLIB_EXTRA makefile variable.

* jn/perl-lib-extra:
  Makefile: add PERLLIB_EXTRA variable that adds to default perl path
  Makefile: rebuild perl scripts when perl paths change

10 years agopack-objects: name pack files after trailer hash
Jeff King [Thu, 5 Dec 2013 20:28:07 +0000 (15:28 -0500)] 
pack-objects: name pack files after trailer hash

Our current scheme for naming packfiles is to calculate the
sha1 hash of the sorted list of objects contained in the
packfile. This gives us a unique name, so we are reasonably
sure that two packs with the same name will contain the same
objects.

It does not, however, tell us that two such packs have the
exact same bytes. This makes things awkward if we repack the
same set of objects. Due to run-to-run variations, the bytes
may not be identical (e.g., changed zlib or git versions,
different source object reuse due to new packs in the
repository, or even different deltas due to races during a
multi-threaded delta search).

In theory, this could be helpful to a program that cares
that the packfile contains a certain set of objects, but
does not care about the particular representation. In
practice, no part of git makes use of that, and in many
cases it is potentially harmful. For example, if a dumb http
client fetches the .idx file, it must be sure to get the
exact .pack that matches it. Similarly, a partial transfer
of a .pack file cannot be safely resumed, as the actual
bytes may have changed.  This could also affect a local
client which opened the .idx and .pack files, closes the
.pack file (due to memory or file descriptor limits), and
then re-opens a changed packfile.

In all of these cases, git can detect the problem, as we
have the sha1 of the bytes themselves in the pack trailer
(which we verify on transfer), and the .idx file references
the trailer from the matching packfile. But it would be
simpler and more efficient to actually get the correct
bytes, rather than noticing the problem and having to
restart the operation.

This patch simply uses the pack trailer sha1 as the pack
name. It should be similarly unique, but covers the exact
representation of the objects. Other parts of git should not
care, as the pack name is returned by pack-objects and is
essentially opaque.

One test needs to be updated, because it actually corrupts a
pack and expects that re-packing the corrupted bytes will
use the same name. It won't anymore, but we can easily just
use the name that pack-objects hands back.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agocommit -v: strip diffs and submodule shortlogs from the commit message
Jens Lehmann [Thu, 5 Dec 2013 19:44:14 +0000 (20:44 +0100)] 
commit -v: strip diffs and submodule shortlogs from the commit message

When using the '-v' option of "git commit" the diff added to the commit
message temporarily for editing is stripped off after the user exited the
editor by searching for "\ndiff --git " and truncating the commmit message
there if it is found.

But this approach has two problems:

- when the commit message itself contains a line starting with
  "diff --git" it will be truncated there prematurely; and

- when the "diff.submodule" setting is set to "log", the diff may
  start with "Submodule <hash1>..<hash2>", which will be left in
  the commit message while it shouldn't.

Fix that by introducing a special scissor separator line starting with the
comment character ('#' or the core.commentChar config if set) followed by
two lines describing what it is for. The scissor line - which will not be
translated - is used to reliably detect the start of the diff so it can be
chopped off from the commit message, no matter what the user enters there.

Turn a known test failure fixed by this change into a successful test;
also add one for a diff starting with a submodule log and another one for
proper handling of the comment char.

Reported-by: Ari Pollak <ari@debian.org>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoreplace {pre,suf}fixcmp() with {starts,ends}_with()
Christian Couder [Sat, 30 Nov 2013 20:55:40 +0000 (21:55 +0100)] 
replace {pre,suf}fixcmp() with {starts,ends}_with()

Leaving only the function definitions and declarations so that any
new topic in flight can still make use of the old functions, replace
existing uses of the prefixcmp() and suffixcmp() with new API
functions.

The change can be recreated by mechanically applying this:

    $ git grep -l -e prefixcmp -e suffixcmp -- \*.c |
      grep -v strbuf\\.c |
      xargs perl -pi -e '
        s|!prefixcmp\(|starts_with\(|g;
        s|prefixcmp\(|!starts_with\(|g;
        s|!suffixcmp\(|ends_with\(|g;
        s|suffixcmp\(|!ends_with\(|g;
      '

on the result of preparatory changes in this series.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agostrbuf: introduce starts_with() and ends_with()
Christian Couder [Sun, 1 Dec 2013 07:49:16 +0000 (08:49 +0100)] 
strbuf: introduce starts_with() and ends_with()

prefixcmp() and suffixcmp() share the common "cmp" suffix that
typically are used to name functions that can be used for ordering,
but they can't, because they are not antisymmetric:

        prefixcmp("foo", "foobar") < 0
        prefixcmp("foobar", "foo") == 0

We in fact do not use these functions for ordering.  Replace them
with functions that just check for equality.

Add starts_with() and end_with() that will be used to replace
prefixcmp() and suffixcmp(), respectively, as the first step.  These
are named after corresponding functions/methods in programming
languages, like Java, Python and Ruby.

In vcs-svn/fast_export.c, there was already an ends_with() function
that did the same thing. Let's use the new one instead while at it.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agobuiltin/remote: remove postfixcmp() and use suffixcmp() instead
Christian Couder [Sun, 1 Dec 2013 07:49:15 +0000 (08:49 +0100)] 
builtin/remote: remove postfixcmp() and use suffixcmp() instead

Commit 8cc5b290 (git merge -X<option>, 25 Nov 2009) introduced
suffixcmp() with nearly the same implementation as postfixcmp()
that already existed since commit 211c8968 (Make git-remote a
builtin, 29 Feb 2008).

The only difference between the two implementations is that,
when the string is smaller than the suffix, one implementation
returns 1 while the other one returns -1.

But, as postfixcmp() is only used to compare for equality, the
distinction does not matter and does not affect the correctness of
this patch.

As postfixcmp() has always been static in builtin/remote.c
and is used nowhere else, it makes more sense to remove it
and use suffixcmp() instead in builtin/remote.c, rather than
to remove suffixcmp().

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoenvironment: normalize use of prefixcmp() by removing " != 0"
Christian Couder [Sun, 1 Dec 2013 07:49:14 +0000 (08:49 +0100)] 
environment: normalize use of prefixcmp() by removing " != 0"

To be able to automatically convert prefixcmp() to starts_with()
we need first to make sure that prefixcmp() is always used in
the same way.

So let's remove " != 0" after prefixcmp().

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoSync with 1.8.5
Junio C Hamano [Thu, 5 Dec 2013 22:11:11 +0000 (14:11 -0800)] 
Sync with 1.8.5

10 years agoMerge branch 'gj/push-more-verbose-advice' (early part)
Junio C Hamano [Thu, 5 Dec 2013 22:03:32 +0000 (14:03 -0800)] 
Merge branch 'gj/push-more-verbose-advice' (early part)

* 'gj/push-more-verbose-advice' (early part):
  push: enhance unspecified push default warning

10 years agoMerge branch 'jn/mediawiki-makefile-updates'
Junio C Hamano [Thu, 5 Dec 2013 21:00:23 +0000 (13:00 -0800)] 
Merge branch 'jn/mediawiki-makefile-updates'

Build and installation procedure clean-up.

* jn/mediawiki-makefile-updates:
  git-remote-mediawiki build: handle DESTDIR/INSTLIBDIR with whitespace
  git-remote-mediawiki build: make 'install' command configurable
  git-remote-mediawiki: honor DESTDIR in "make install"
  git-remote-mediawiki: do not remove installed files in "clean" target

10 years agoMerge branch 'jl/submodule-update-retire-orig-flags'
Junio C Hamano [Thu, 5 Dec 2013 21:00:20 +0000 (13:00 -0800)] 
Merge branch 'jl/submodule-update-retire-orig-flags'

Code clean-up.

* jl/submodule-update-retire-orig-flags:
  submodule update: remove unnecessary orig_flags variable

10 years agoMerge branch 'nd/wt-status-align-i18n'
Junio C Hamano [Thu, 5 Dec 2013 21:00:16 +0000 (13:00 -0800)] 
Merge branch 'nd/wt-status-align-i18n'

An attempt to automatically align the names in the "git status"
output, taking the display width of (translated) section labels
into account.

* nd/wt-status-align-i18n:
  wt-status: take the alignment burden off translators

10 years agoMerge branch 'sb/sha1-loose-object-info-check-existence'
Junio C Hamano [Thu, 5 Dec 2013 21:00:11 +0000 (13:00 -0800)] 
Merge branch 'sb/sha1-loose-object-info-check-existence'

"git cat-file --batch-check=ok" did not check the existence of the
named object.

* sb/sha1-loose-object-info-check-existence:
  sha1_loose_object_info(): do not return success on missing object

10 years agoMerge branch 'jk/two-way-merge-corner-case-fix'
Junio C Hamano [Thu, 5 Dec 2013 20:59:25 +0000 (12:59 -0800)] 
Merge branch 'jk/two-way-merge-corner-case-fix'

Fix a rather longstanding corner-case bug in twoway "reset to
there" merge, which is most often seen in "git am --abort".

* jk/two-way-merge-corner-case-fix:
  t1005: add test for "read-tree --reset -u A B"
  t1005: reindent
  unpack-trees: fix "read-tree -u --reset A B" with conflicted index

10 years agoMerge branch 'jc/ref-excludes'
Junio C Hamano [Thu, 5 Dec 2013 20:59:09 +0000 (12:59 -0800)] 
Merge branch 'jc/ref-excludes'

People often wished a way to tell "git log --branches" (and "git
log --remotes --not --branches") to exclude some local branches
from the expansion of "--branches" (similarly for "--tags", "--all"
and "--glob=<pattern>").  Now they have one.

* jc/ref-excludes:
  rev-parse: introduce --exclude=<glob> to tame wildcards
  rev-list --exclude: export add/clear-ref-exclusion and ref-excluded API
  rev-list --exclude: tests
  document --exclude option
  revision: introduce --exclude=<glob> to tame wildcards

10 years agoMerge branch 'nv/parseopt-opt-arg'
Junio C Hamano [Thu, 5 Dec 2013 20:59:03 +0000 (12:59 -0800)] 
Merge branch 'nv/parseopt-opt-arg'

Enhance "rev-parse --parseopt" mode to help parsing options with
an optional parameter.

* nv/parseopt-opt-arg:
  rev-parse --parseopt: add the --stuck-long mode
  Use the word 'stuck' instead of 'sticked'

10 years agoMerge branch 'bc/http-100-continue'
Junio C Hamano [Thu, 5 Dec 2013 20:58:58 +0000 (12:58 -0800)] 
Merge branch 'bc/http-100-continue'

Issue "100 Continue" responses to help use of GSS-Negotiate
authentication scheme over HTTP transport when needed.

* bc/http-100-continue:
  remote-curl: fix large pushes with GSSAPI
  remote-curl: pass curl slot_results back through run_slot
  http: return curl's AUTHAVAIL via slot_results

10 years agoMerge branch 'jc/merge-base-reflog'
Junio C Hamano [Thu, 5 Dec 2013 20:58:27 +0000 (12:58 -0800)] 
Merge branch 'jc/merge-base-reflog'

Code the logic in "pull --rebase" that figures out a fork point
from reflog entries in C.

* jc/merge-base-reflog:
  merge-base: teach "--fork-point" mode
  merge-base: use OPT_CMDMODE and clarify the command line parsing

10 years agoMerge branch 'jk/replace-perl-in-built-scripts'
Junio C Hamano [Thu, 5 Dec 2013 20:58:21 +0000 (12:58 -0800)] 
Merge branch 'jk/replace-perl-in-built-scripts'

* jk/replace-perl-in-built-scripts:
  use @@PERL@@ in built scripts

10 years agoMerge branch 'jh/loose-object-dirs-creation-race'
Junio C Hamano [Thu, 5 Dec 2013 20:54:14 +0000 (12:54 -0800)] 
Merge branch 'jh/loose-object-dirs-creation-race'

When two processes created one loose object file each, which fell
into the same fan-out bucket that previously did not have any
objects, they both tried to do an equivalent of

    mkdir .git/objects/$fanout &&
    chmod $shared_perm .git/objects/$fanout

before writing into their file .git/objects/$fanout/$remainder,
one of which could have failed unnecessarily when the second
invocation of mkdir found that the directory already has been
created by the first one.

* jh/loose-object-dirs-creation-race:
  sha1_file.c:create_tmpfile(): Fix race when creating loose object dirs

10 years agoMerge branch 'jk/robustify-parse-commit'
Junio C Hamano [Thu, 5 Dec 2013 20:54:01 +0000 (12:54 -0800)] 
Merge branch 'jk/robustify-parse-commit'

* jk/robustify-parse-commit:
  checkout: do not die when leaving broken detached HEAD
  use parse_commit_or_die instead of custom message
  use parse_commit_or_die instead of segfaulting
  assume parse_commit checks for NULL commit
  assume parse_commit checks commit->object.parsed
  log_tree_diff: die when we fail to parse a commit

10 years agoMerge branch 'ak/submodule-foreach-quoting'
Junio C Hamano [Thu, 5 Dec 2013 20:53:17 +0000 (12:53 -0800)] 
Merge branch 'ak/submodule-foreach-quoting'

A behavior change, but a worthwhile one: "git submodule foreach"
was treating its arguments as part of a single command to be
concatenated and passed to a shell, making writing buggy
scripts too easy.

This patch preserves the old "just pass it to the shell" behavior
when a single argument is passed to 'git submodule foreach' and
moves to a new "skip the shell and use the arguments passed
unmolested" behavior when more than one argument is passed.

The old behavior (always concatenating and passing to the shell)
was similar to the 'ssh' command, while the new behavior (switching
on the number of arguments) is what 'xterm -e' does.

May need more thought to make sure this change is advertised well
so that scripts that used multiple arguments but added their own
extra layer of quoting are not broken.

* ak/submodule-foreach-quoting:
  submodule foreach: skip eval for more than one argument

10 years agot5000: simplify gzip prerequisite checks
Jeff King [Tue, 3 Dec 2013 13:21:40 +0000 (08:21 -0500)] 
t5000: simplify gzip prerequisite checks

In t5000, we test the built-in ".tar.gz" config for
git-archive. To make our tests portable, we check that we
have a way to both gzip and gunzip, and we respected
environment variables to point to alternate commands for
doing these operations.

However, the $GZIP variable did not actually do anything, as
changing it would not affect the baked-in value in
archive-tar.c. Moreover, setting the variable $GZIP
influences gzip itself. From the gzip man page:

  The environment variable GZIP can hold a set of default
  options for gzip. These options are interpreted first and
  can be overwritten by explicit command line parameters.

We could rename this variable, and use it to set up custom
config (or even have a Makefile knob to affect the built
binary), but it is not worth the trouble; nobody has ever
reported a problem with the baked-in default, and they can
always change it via config if they need to. Let's just drop
the variable and use "gzip" in the test (keeping the
prerequisite, of course).

While we're at it, we can drop the GUNZIP variable and
prerequisite; it uses "gzip -d", so if we have GZIP, we
will have both.

We can also use test_lazy_prereq for the gzip prerequisite,
which is simpler and behaves more consistently with the rest
of git (e.g., by making output available when the test is
run with "-v").

Noticed-by: Christian Hesse <mail@eworm.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agogettext.c: detect the vsnprintf bug at runtime
Nguyễn Thái Ngọc Duy [Sun, 1 Dec 2013 02:45:38 +0000 (09:45 +0700)] 
gettext.c: detect the vsnprintf bug at runtime

Bug 6530 [1] in glibc causes "git show v0.99.6~1" to fail with error
"your vsnprintf is broken". The workaround avoids that, but it
corrupts system error messages in non-C locales.

The bug has been fixed since 2.17. We could know running glibc version
with gnu_get_libc_version(). But version is not a sure way to detect
the bug because downstream may back port the fix to older versions. Do
a runtime test that immitates the call flow that leads to "your
vsnprintf is broken". Only enable the workaround if the test fails.

Tested on Gentoo Linux, glibc 2.16.0 and 2.17, amd64.

[1] http://sourceware.org/bugzilla/show_bug.cgi?id=6530

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agot5601: add tests for ssh
Torsten Bögershausen [Thu, 28 Nov 2013 19:48:22 +0000 (20:48 +0100)] 
t5601: add tests for ssh

Add more tests testing all the combinations:

 -IPv4 or IPv6
 -path starting with "/" or with "/~"
 -with and without the ssh:// scheme

Some tests fail; they need updates in connect.c

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agot5601: remove clear_ssh, refactor setup_ssh_wrapper
Torsten Bögershausen [Thu, 28 Nov 2013 19:53:47 +0000 (20:53 +0100)] 
t5601: remove clear_ssh, refactor setup_ssh_wrapper

Commit 8d3d28f5 added test cases for URLs which should be ssh.
Remove the function clear_ssh, use test_when_finished to clean up.

Introduce the function setup_ssh_wrapper, which could be factored
out together with expect_ssh.

Tighten one test and use "foo:bar" instead of "./foo:bar",

Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agopush: also use "upstream" mapping when pushing a single ref
Junio C Hamano [Wed, 4 Dec 2013 00:23:35 +0000 (16:23 -0800)] 
push: also use "upstream" mapping when pushing a single ref

When the user is using the 'upstream' mode, these commands:

    $ git push
    $ git push origin

would find the 'upstream' branch for the current branch, and then
push the current branch to update it.  However, pushing a single
branch explicitly, i.e.

    $ git push origin $(git symbolic-ref --short HEAD)

would not go through the same ref mapping process, and ends up
updating the branch at 'origin' of the same name, which may not
necessarily be the upstream of the branch being pushed.

In the spirit similar to the previous one, map a colon-less refspec
using the upstream mapping logic.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agopush: use remote.$name.push as a refmap
Junio C Hamano [Tue, 3 Dec 2013 23:41:15 +0000 (15:41 -0800)] 
push: use remote.$name.push as a refmap

Since f2690487 (fetch: opportunistically update tracking refs,
2013-05-11), we stopped taking a non-storing refspec given on the
command line of "git fetch" literally, and instead started mapping
it via remote.$name.fetch refspecs.  This allows

    $ git fetch origin master

from the 'origin' repository, which is configured with

    [remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*

to update refs/remotes/origin/master with the result, as if the
command line were

    $ git fetch origin +master:refs/remotes/origin/master

to reduce surprises and improve usability.  Before that change, a
refspec on the command line without a colon was only to fetch the
history and leave the result in FETCH_HEAD, without updating the
remote-tracking branches.

When you are simulating a fetch from you by your mothership with a
push by you into your mothership, instead of having:

    [remote "satellite"]
        fetch = +refs/heads/*:refs/remotes/satellite/*

on the mothership repository and running:

    mothership$ git fetch satellite

you would have:

    [remote "mothership"]
        push = +refs/heads/*:refs/remotes/satellite/*

on your satellite machine, and run:

    satellite$ git push mothership

Because we so far did not make the corresponding change to the push
side, this command:

    satellite$ git push mothership master

does _not_ allow you on the satellite to only push 'master' out but
still to the usual destination (i.e. refs/remotes/satellite/master).

Implement the logic to map an unqualified refspec given on the
command line via the remote.$name.push refspec.  This will bring a
bit more symmetry between "fetch" and "push".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agomv: let 'git mv file no-such-dir/' error out
Matthieu Moy [Tue, 3 Dec 2013 08:32:04 +0000 (09:32 +0100)] 
mv: let 'git mv file no-such-dir/' error out

Git used to trim the trailing slash, and make the command equivalent
to 'git mv file no-such-dir', which created the file no-such-dir
(while the trailing slash explicitly stated that it could only be a
directory).

This patch skips the trailing slash removal for the destination
path.  The path with its trailing slash is passed to rename(2),
which errors out with the appropriate message:

  $ git mv file no-such-dir/
  fatal: renaming 'file' failed: Not a directory

Original-patch-by: Duy Nguyen <pclouds@gmail.com>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agosend-email: set SSL options through IO::Socket::SSL::set_client_defaults
Thomas Rast [Sun, 1 Dec 2013 22:48:43 +0000 (23:48 +0100)] 
send-email: set SSL options through IO::Socket::SSL::set_client_defaults

When --smtp-encryption=ssl, we use a Net::SMTP::SSL connection,
passing its ->new all the options that would otherwise go to
Net::SMTP->new (most options) and IO::Socket::SSL->start_SSL (for the
SSL options).

However, while Net::SMTP::SSL replaces the underlying socket class
with an SSL socket, it does nothing to allow passing options to that
socket.  So the SSL-relevant options are lost.

Fortunately there is an escape hatch: we can directly set the options
with IO::Socket::SSL::set_client_defaults.  They will then persist
within the IO::Socket::SSL module.

Signed-off-by: Thomas Rast <tr@thomasrast.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agosend-email: --smtp-ssl-cert-path takes an argument
Thomas Rast [Sun, 1 Dec 2013 22:48:42 +0000 (23:48 +0100)] 
send-email: --smtp-ssl-cert-path takes an argument

35035bb (send-email: be explicit with SSL certificate verification,
2013-07-18) forgot to specify that --smtp-ssl-cert-path takes a string
argument.  This means that the option could not actually be used as
intended.  Presumably noone noticed because it's much easier to set it
through configs anyway.

Add the required "=s".

Signed-off-by: Thomas Rast <tr@thomasrast.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agosend-email: pass Debug to Net::SMTP::SSL::new
Thomas Rast [Sun, 1 Dec 2013 22:48:41 +0000 (23:48 +0100)] 
send-email: pass Debug to Net::SMTP::SSL::new

We forgot to pass the Debug option through to Net::SMTP::SSL->new --
which is the same as Net::SMTP->new.  This meant that with security
set to SSL, we would never enable debug output.

Pass through the flag.

Signed-off-by: Thomas Rast <tr@thomasrast.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agobuiltin/push.c: use strbuf instead of manual allocation
Junio C Hamano [Tue, 3 Dec 2013 22:33:10 +0000 (14:33 -0800)] 
builtin/push.c: use strbuf instead of manual allocation

The command line arguments given to "git push" are massaged into
a list of refspecs in set_refspecs() function. This was implemented
using xmalloc, strcpy and friends, but it is much easier to read if
done using strbuf.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agostop installing git-tar-tree link
Jonathan Nieder [Mon, 2 Dec 2013 23:37:10 +0000 (15:37 -0800)] 
stop installing git-tar-tree link

When the built-in "git tar-tree" command (a thin wrapper around "git
archive") was removed in 925ceccf (tar-tree: remove deprecated
command, 2013-11-10), the build continued to install a non-functioning
git-tar-tree command in gitexecdir by mistake:

$ PATH=$(git --exec-path):$PATH
$ git-tar-tree -h
fatal: cannot handle tar-tree internally

The list of links in gitexecdir is populated from BUILTIN_OBJS, which
includes builtin/tar-tree.o to implement "git get-tar-commit-id".
Rename the get-tar-commit-id source file to builtin/get-tar-commit-id.c
to reflect its purpose and fix 'make install'.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoSync with 1.8.5.1
Junio C Hamano [Tue, 3 Dec 2013 19:42:03 +0000 (11:42 -0800)] 
Sync with 1.8.5.1

* maint:
  Git 1.8.5.1
  ref-iteration doc: add_submodule_odb() returns 0 for success

10 years agoMerge branch 'nd/glossary-content-pathspec-markup'
Junio C Hamano [Tue, 3 Dec 2013 19:41:52 +0000 (11:41 -0800)] 
Merge branch 'nd/glossary-content-pathspec-markup'

* nd/glossary-content-pathspec-markup:
  glossary-content.txt: fix documentation of "**" patterns

10 years agoMerge branch 'jj/doc-markup-gitcli'
Junio C Hamano [Tue, 3 Dec 2013 19:41:46 +0000 (11:41 -0800)] 
Merge branch 'jj/doc-markup-gitcli'

* jj/doc-markup-gitcli:
  Documentation/gitcli.txt: fix double quotes

10 years agoMerge branch 'jj/doc-markup-hints-in-coding-guidelines'
Junio C Hamano [Tue, 3 Dec 2013 19:41:43 +0000 (11:41 -0800)] 
Merge branch 'jj/doc-markup-hints-in-coding-guidelines'

* jj/doc-markup-hints-in-coding-guidelines:
  State correct usage of literal examples in man pages in the coding standards

10 years agoMerge branch 'jj/log-doc'
Junio C Hamano [Tue, 3 Dec 2013 19:41:40 +0000 (11:41 -0800)] 
Merge branch 'jj/log-doc'

Mark-up fixes.

* jj/log-doc:
  Documentation/git-log.txt: mark-up fix and minor rephasing
  Documentation/git-log: update "--log-size" description

10 years agoMerge branch 'jj/rev-list-options-doc'
Junio C Hamano [Tue, 3 Dec 2013 19:41:37 +0000 (11:41 -0800)] 
Merge branch 'jj/rev-list-options-doc'

Mark-up and grammo fixes.

* jj/rev-list-options-doc:
  Documentation/rev-list-options.txt: fix some grammatical issues and typos
  Documentation/rev-list-options.txt: fix mark-up

10 years agoMerge branch 'mi/typofixes'
Junio C Hamano [Tue, 3 Dec 2013 19:41:33 +0000 (11:41 -0800)] 
Merge branch 'mi/typofixes'

* mi/typofixes:
  contrib: typofixes
  Documentation/technical/http-protocol.txt: typofixes
  typofixes: fix misspelt comments

10 years agoMerge branch 'tb/doc-fetch-pack-url'
Junio C Hamano [Tue, 3 Dec 2013 19:41:31 +0000 (11:41 -0800)] 
Merge branch 'tb/doc-fetch-pack-url'

* tb/doc-fetch-pack-url:
  git-fetch-pack uses URLs like git-fetch

10 years agoGit 1.8.5.1 v1.8.5.1
Junio C Hamano [Tue, 3 Dec 2013 19:16:56 +0000 (11:16 -0800)] 
Git 1.8.5.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoref-iteration doc: add_submodule_odb() returns 0 for success
Nick Townsend [Mon, 25 Nov 2013 23:31:09 +0000 (15:31 -0800)] 
ref-iteration doc: add_submodule_odb() returns 0 for success

The usage sample of add_submodule_odb() function in the Submodules
section expects non-zero return value for success, but the function
actually reports success with zero.

Helped-by: René Scharfe <l.s.r@web.de>
Reviewed-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Nick Townsend <nick.townsend@mac.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
10 years agoSync with 1.8.4.5
Junio C Hamano [Mon, 2 Dec 2013 23:34:44 +0000 (15:34 -0800)] 
Sync with 1.8.4.5

10 years agoGit 1.8.4.5 v1.8.4.5
Junio C Hamano [Mon, 2 Dec 2013 23:33:30 +0000 (15:33 -0800)] 
Git 1.8.4.5

Signed-off-by: Junio C Hamano <gitster@pobox.com>