gitweb.git
Test 'commit --only' after 'checkout --orphan'Thomas Rast Sat, 1 Jun 2013 11:02:00 +0000 (13:02 +0200)

Test 'commit --only' after 'checkout --orphan'

There are some index handling subtleties in 'commit --only' that are
best tested when we have an existing index, but an unborn or empty
HEAD. These circumstances are easily produced by 'checkout --orphan',
but we did not previously have a test for it.

The main expected failure mode would be: erroneously loading the
existing index contents when building the temporary index that is used
for --only. Cf.

http://article.gmane.org/gmane.comp.version-control.git/225969

and subsequent discussion.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

sha1_name: fix error message for @{<N>}, @{<date>}Ramkumar Ramachandra Wed, 22 May 2013 10:39:55 +0000 (16:09 +0530)

sha1_name: fix error message for @{<N>}, @{<date>}

Currently, when we try to resolve @{<N>} or @{<date>} when the reflog
doesn't go back far enough, we get errors like:

# on branch master
$ git show @{10000}
fatal: Log for '' only has 7 entries.

$ git show @{10000.days.ago}
warning: Log for '' only goes back to Tue, 21 May 2013 14:14:45 +0530.
...

# detached HEAD case
$ git show @{10000}
fatal: Log for '' only has 2005 entries.

$ git show master@{10000}
fatal: Log for 'master' only has 7 entries.

The empty string '' is confusing and does not convey information
about whose logs we are inspecting. Change this so that we get:

# on branch master
$ git show @{10000}
fatal: Log for 'master' only has 7 entries.

$ git show @{10000.days.ago}
warning: Log for 'master' only goes back to Tue, 21 May 2013 14:14:45 +0530.
...

# detached HEAD case
$ git show @{10000}
fatal: Log for 'HEAD' only has 2005 entries.

$ git show master@{10000}
fatal: Log for 'master' only has 7 entries.

Also one of the message strings given to die() now points into
real_ref that was not used in that fashion, so stop freeing the
underlying storage for it.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Bug-spotted-and-fixed-by: Thomas Rast
Signed-off-by: Junio C Hamano <gitster@pobox.com>

path: Fix a sparse warningRamsay Jones Wed, 29 May 2013 23:53:28 +0000 (00:53 +0100)

path: Fix a sparse warning

On MinGW, sparse issues an "'get_st_mode_bits' not declared. Should
it be static?" warning. The MinGW and MSVC builds do not see the
declaration of this function, within git-compat-util.h, due to its
placement within an preprocessor conditional.

In order to suppress the warning, we simply move the declaration to
the top level of the header.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: make push.default = current use resolved HEADRamkumar Ramachandra Wed, 29 May 2013 19:21:51 +0000 (00:51 +0530)

push: make push.default = current use resolved HEAD

With this change, the output of the push (with push.default set to
current) changes subtly from:

$ git push
...
* [new branch] HEAD -> push-current-head

to:

$ git push
...
* [new branch] push-current-head -> push-current-head

This patch was written with a different motivation. There is a problem
unique to push.default = current:

# on branch push-current-head
$ git push
# on another terminal
$ git checkout master
# return to the first terminal
# the push tried to push master!

This happens because the 'git checkout' on the second terminal races
with the 'git push' on the first terminal. Although this patch does not
solve the core problem (there is still no guarantee that 'git push' on
the first terminal will resolve HEAD before 'git checkout' changes HEAD
on the second), it works in practice.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: fail early with detached HEAD and currentRamkumar Ramachandra Wed, 29 May 2013 19:21:50 +0000 (00:51 +0530)

push: fail early with detached HEAD and current

Setting push.default to current adds the refspec "HEAD" for the
transport layer to handle. If "HEAD" doesn't resolve to a branch (and
since no refspec rhs is specified), the push fails after some time with
a cryptic error message:

$ git push
error: unable to push to unqualified destination: HEAD
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
error: failed to push some refs to 'git@github.com:artagnon/git'

Fail early with a nicer error message:

$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

git push ram HEAD:<name-of-remote-branch>

Just like in the upstream and simple cases.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Sync with maintJunio C Hamano Wed, 29 May 2013 22:21:47 +0000 (15:21 -0700)

Sync with maint

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

Start 1.8.3.1 maintenance trackJunio C Hamano Wed, 29 May 2013 22:21:15 +0000 (15:21 -0700)

Start 1.8.3.1 maintenance track

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

Merge branch 'maint-1.8.2' into maintJunio C Hamano Wed, 29 May 2013 22:20:36 +0000 (15:20 -0700)

Merge branch 'maint-1.8.2' into maint

* maint-1.8.2:
trivial: Add missing period in documentation

Start 1.8.4 cycleJunio C Hamano Wed, 29 May 2013 22:19:12 +0000 (15:19 -0700)

Start 1.8.4 cycle

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

Merge branch 'jn/config-ignore-inaccessible'Junio C Hamano Wed, 29 May 2013 21:30:10 +0000 (14:30 -0700)

Merge branch 'jn/config-ignore-inaccessible'

When $HOME is misconfigured to point at an unreadable directory, we
used to complain and die. This loosens the check.

* jn/config-ignore-inaccessible:
config: allow inaccessible configuration under $HOME

Merge branch 'jk/lookup-object-prefer-latest'Junio C Hamano Wed, 29 May 2013 21:29:58 +0000 (14:29 -0700)

Merge branch 'jk/lookup-object-prefer-latest'

Optimizes object lookup when the object hashtable starts to become
crowded.

* jk/lookup-object-prefer-latest:
lookup_object: prioritize recently found objects

Merge branch 'jk/subtree-do-not-push-if-split-fails'Junio C Hamano Wed, 29 May 2013 21:29:53 +0000 (14:29 -0700)

Merge branch 'jk/subtree-do-not-push-if-split-fails'

"git subtree" (in contrib/) had one codepath with loose error
checks to lose data at the remote side.

* jk/subtree-do-not-push-if-split-fails:
contrib/subtree: don't delete remote branches if split fails

Merge branch 'jk/test-output'Junio C Hamano Wed, 29 May 2013 21:29:11 +0000 (14:29 -0700)

Merge branch 'jk/test-output'

When TEST_OUTPUT_DIRECTORY setting is used, it was handled somewhat
inconsistently between the test framework and t/Makefile, and logic
to summarize the results looked at a wrong place.

* jk/test-output:
t/Makefile: don't define TEST_RESULTS_DIRECTORY recursively
test output: respect $TEST_OUTPUT_DIRECTORY
t/Makefile: fix result handling with TEST_OUTPUT_DIRECTORY

Merge branch 'rj/sparse'Junio C Hamano Wed, 29 May 2013 21:24:02 +0000 (14:24 -0700)

Merge branch 'rj/sparse'

* rj/sparse:
sparse: Fix mingw_main() argument number/type errors
compat/mingw.c: Fix some sparse warnings
compat/win32mmap.c: Fix some sparse warnings
compat/poll/poll.c: Fix a sparse warning
compat/win32/pthread.c: Fix a sparse warning
compat/unsetenv.c: Fix a sparse warning
compat/nedmalloc: Fix compiler warnings on linux
compat/nedmalloc: Fix some sparse warnings
compat/fnmatch/fnmatch.c: Fix a sparse error
compat/regex/regexec.c: Fix some sparse warnings

Merge branch 'mh/packed-refs-various'Junio C Hamano Wed, 29 May 2013 21:23:49 +0000 (14:23 -0700)

Merge branch 'mh/packed-refs-various'

Update reading and updating packed-refs file, correcting corner case
bugs.

* mh/packed-refs-various: (33 commits)
refs: handle the main ref_cache specially
refs: change do_for_each_*() functions to take ref_cache arguments
pack_one_ref(): do some cheap tests before a more expensive one
pack_one_ref(): use write_packed_entry() to do the writing
pack_one_ref(): use function peel_entry()
refs: inline function do_not_prune()
pack_refs(): change to use do_for_each_entry()
refs: use same lock_file object for both ref-packing functions
pack_one_ref(): rename "path" parameter to "refname"
pack-refs: merge code from pack-refs.{c,h} into refs.{c,h}
pack-refs: rename handle_one_ref() to pack_one_ref()
refs: extract a function write_packed_entry()
repack_without_ref(): write peeled refs in the rewritten file
t3211: demonstrate loss of peeled refs if a packed ref is deleted
refs: change how packed refs are deleted
search_ref_dir(): return an index rather than a pointer
repack_without_ref(): silence errors for dangling packed refs
t3210: test for spurious error messages for dangling packed refs
refs: change the internal reference-iteration API
refs: extract a function peel_entry()
...

Merge branch 'as/check-ignore'Junio C Hamano Wed, 29 May 2013 21:23:39 +0000 (14:23 -0700)

Merge branch 'as/check-ignore'

Enhance "check-ignore" (1.8.2 update) to work more like "check-attr"
over bidi-pipes.

* as/check-ignore:
t0008: use named pipe (FIFO) to test check-ignore streaming
Documentation: add caveats about I/O buffering for check-{attr,ignore}
check-ignore: allow incremental streaming of queries via --stdin
check-ignore: move setup into cmd_check_ignore()
check-ignore: add -n / --non-matching option
t0008: remove duplicated test fixture data

Merge branch 'jh/checkout-auto-tracking'Junio C Hamano Wed, 29 May 2013 21:23:10 +0000 (14:23 -0700)

Merge branch 'jh/checkout-auto-tracking'

Update "git checkout foo" that DWIMs the intended "upstream" and
turns it into "git checkout -t -b foo remotes/origin/foo" to
correctly take existing remote definitions into account.

The remote "origin" may be what uniquely map its own branch to
remotes/some/where/foo but that some/where may not be "origin".

* jh/checkout-auto-tracking:
glossary: Update and rephrase the definition of a remote-tracking branch
branch.c: Validate tracking branches with refspecs instead of refs/remotes/*
t9114.2: Don't use --track option against "svn-remote"-tracking branches
t7201.24: Add refspec to keep --track working
t3200.39: tracking setup should fail if there is no matching refspec.
checkout: Use remote refspecs when DWIMming tracking branches
t2024: Show failure to use refspec when DWIMming remote branch names
t2024: Add tests verifying current DWIM behavior of 'git checkout <branch>'

Merge branch 'jc/prune-all'Junio C Hamano Wed, 29 May 2013 21:23:03 +0000 (14:23 -0700)

Merge branch 'jc/prune-all'

We used the approxidate() parser for "--expire=<timestamp>" options
of various commands, but it is better to treat --expire=all and
--expire=now a bit more specially than using the current timestamp.
Update "git gc" and "git reflog" with a new parsing function for
expiry dates.

* jc/prune-all:
prune: introduce OPT_EXPIRY_DATE() and use it
api-parse-options.txt: document "no-" for non-boolean options
git-gc.txt, git-reflog.txt: document new expiry options
date.c: add parse_expiry_date()

Merge branch 'mh/fetch-into-shallow'Junio C Hamano Wed, 29 May 2013 21:20:30 +0000 (14:20 -0700)

Merge branch 'mh/fetch-into-shallow'

"git fetch" into a shallow repository from a repository that does
not know about the shallow boundary commits (e.g. a different fork
from the repository the current shallow repository was cloned from)
did not work correctly.

* mh/fetch-into-shallow:
t5500: add test for fetching with an unknown 'shallow'
upload-pack: ignore 'shallow' lines with unknown obj-ids

Merge branch 'js/transport-helper-error-reporting-fix'Junio C Hamano Wed, 29 May 2013 21:20:25 +0000 (14:20 -0700)

Merge branch 'js/transport-helper-error-reporting-fix'

Finishing touches to fc/transport-helper-error-reporting topic.

* js/transport-helper-error-reporting-fix:
git-remote-testgit: build it to run under $SHELL_PATH
git-remote-testgit: further remove some bashisms
git-remote-testgit: avoid process substitution

Merge branch 'fc/transport-helper-error-reporting'Junio C Hamano Wed, 29 May 2013 21:20:16 +0000 (14:20 -0700)

Merge branch 'fc/transport-helper-error-reporting'

Update transport helper to report errors and maintain ref hierarchy
used to keep track of remote helper state better.

* fc/transport-helper-error-reporting:
transport-helper: fix remote helper namespace regression
test: remote-helper: add missing and
t5801: "VAR=VAL shell_func args" is forbidden
transport-helper: update remote helper namespace
transport-helper: trivial code shuffle
transport-helper: warn when refspec is not used
transport-helper: clarify pushing without refspecs
transport-helper: update refspec documentation
transport-helper: clarify *:* refspec
transport-helper: improve push messages
transport-helper: mention helper name when it dies
transport-helper: report errors properly

completion: zsh: improve bash script loadingFelipe Contreras Sat, 25 May 2013 03:31:44 +0000 (22:31 -0500)

completion: zsh: improve bash script loading

It's better to check in multiple locations, so the user doesn't have to.

And update the documentation.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

archive-zip:write_zip_entry: Remove second reset of... Stefan Beller Sun, 26 May 2013 19:11:35 +0000 (21:11 +0200)

archive-zip:write_zip_entry: Remove second reset of size variable to zero.

It is set to zero just 3 lines before.
Reported by cppcheck.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

difftool --dir-diff: allow changing any clean working... Kenichi Saita Wed, 29 May 2013 16:01:23 +0000 (01:01 +0900)

difftool --dir-diff: allow changing any clean working tree file

The temporary directory prepared by "difftool --dir-diff" to
show the result of a change can be modified by the user via
the tree diff program, and we try hard not to lose changes
to them after tree diff program returns to us.

However, the set of files to be copied back is computed
differently between --symlinks and --no-symlinks modes. The
former checks all paths that start out as identical to the
working tree file, while the latter checks paths that
already had a local modification in the working tree,
allowing changes made in the tree diff program to paths that
did not have any local change to be lost.

Signed-off-by: Kenichi Saita <nitoyon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

push: factor out the detached HEAD error messageRamkumar Ramachandra Wed, 29 May 2013 19:21:49 +0000 (00:51 +0530)

push: factor out the detached HEAD error message

With push.default set to upstream or simple, and a detached HEAD, git
push prints the following error:

$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

git push ram HEAD:<name-of-remote-branch>

This error is not unique to upstream or simple: current cannot push with
a detached HEAD either. So, factor out the error string in preparation
for using it in current.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

get_sha1: warn about full or short object names that... Nguyễn Thái Ngọc Duy Wed, 29 May 2013 12:12:42 +0000 (19:12 +0700)

get_sha1: warn about full or short object names that look like refs

When we get 40 hex digits, we immediately assume it's an SHA-1. This
is the right thing to do because we have no way else to specify an
object. If there is a ref with the same object name, it will be
ignored. Warn the user about this case because the ref with full
object name is likely a mistake, for example

git checkout -b $empty_var $(git rev-parse something)

advice.object_name_warning is not documented because frankly people
should not be aware about it until they encounter this situation.

While at there, warn about ambiguation with abbreviated SHA-1 too.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

prompt: fix for simple rebaseFelipe Contreras Wed, 29 May 2013 06:21:28 +0000 (01:21 -0500)

prompt: fix for simple rebase

When we are rebasing without options ('am' mode), the head rebased lives
in '$g/rebase-apply/head-name', so lets use that information so it's
reported the same way as if we were doing other rebases (-i or -m).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

rebase: implement --[no-]autostash and rebase.autostashRamkumar Ramachandra Sun, 12 May 2013 11:56:41 +0000 (17:26 +0530)

rebase: implement --[no-]autostash and rebase.autostash

This new feature allows a rebase to be executed on a dirty worktree or
index. It works by creating a temporary "dangling merge commit" out
of the worktree and index changes (via 'git stash create'), and
automatically applying it after a successful rebase or abort.

rebase stores the SHA-1 hex of the temporary merge commit, along with
the rest of the rebase state, in either
.git/{rebase-merge,rebase-apply}/autostash depending on the kind of
rebase. Since $state_dir is automatically removed at the end of a
successful rebase or abort, so is the autostash.

The advantage of this approach is that we do not affect the normal
stash's reflogs, making the autostash invisible to the end-user. This
means that you can use 'git stash' during a rebase as usual.

When the autostash application results in a conflict, we push
$state_dir/autostash onto the normal stash and remove $state_dir
ending the rebase. The user can inspect the stash, and pop or drop at
any time.

Most significantly, this feature means that a caller like pull (with
pull.rebase set to true) can easily be patched to remove the
require_clean_work_tree restriction.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-remote-mediawiki: better error message when HTTP... Matthieu Moy Wed, 29 May 2013 12:06:29 +0000 (14:06 +0200)

git-remote-mediawiki: better error message when HTTP(S) access fails

My use-case is an invalid SSL certificate. Pulling from the wiki with a
recent version of libwww-perl fails, and git-remote-mediawiki gave no
clue about the reason. Give the mediawiki API detailed error message, and
since it is not so informative, hint the user about an invalid SSL
certificate on https:// urls.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

trivial: Add missing period in documentationPhil Hord Tue, 28 May 2013 19:36:44 +0000 (19:36 +0000)

trivial: Add missing period in documentation

Signed-off-by: Phil Hord <hordp@cisco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

commit: don't start editor if empty message is given... René Scharfe Sat, 25 May 2013 21:43:34 +0000 (23:43 +0200)

commit: don't start editor if empty message is given with -m

If an empty message is specified with the option -m of git commit then
the editor is started. That's unexpected and unnecessary. Instead of
using the length of the message string for checking if the user
specified one, directly remember if the option -m was given.

Reported-by: Mislav Marohnić <mislav.marohnic@gmail.com>
Signed-off-by: René Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

credential-osxkeychain: support more protocolsXidorn Quan Tue, 28 May 2013 02:36:21 +0000 (10:36 +0800)

credential-osxkeychain: support more protocols

Add protocol imap, imaps, ftp and smtp for credential-osxkeychain.

Signed-off-by: Xidorn Quan <quanxunzhen@gmail.com>
Acked-by: John Szakmeister <john@szakmeister.net>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fix segfault with git log -c --followClemens Buchacher Mon, 27 May 2013 22:49:57 +0000 (00:49 +0200)

fix segfault with git log -c --follow

In diff_tree_combined we make a copy of diffopts. In
try_to_follow_renames, called via diff_tree_sha1, we free and
re-initialize diffopts->pathspec->items. Since we did not make a deep
copy of diffopts in diff_tree_combined, the original diffopts does not
get the update. By the time we return from diff_tree_combined,
rev->diffopt->pathspec->items points to an invalid memory address. We
get a segfault next time we try to access that pathspec.

Instead, along with the copy of diffopts, make a copy pathspec->items as
well.

We would also have to make a copy of pathspec->raw to keep it consistent
with pathspec->items, but nobody seems to rely on that.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

send-email: remove warning about unset chainreplytoFelipe Contreras Sat, 25 May 2013 03:44:52 +0000 (22:44 -0500)

send-email: remove warning about unset chainreplyto

Three years and a half is probably more than enough time to give users
the opportunity to configure Git to do what they want. If they haven't
changed the configuration by now, this warning message is not going to
do anything for them anyway.

This effectively reverts commit 528fb08 (prepare send-email for smoother
change of --chain-reply-to default).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

prune-packed: avoid implying "1" is DRY_RUN in prune_pa... Nguyễn Thái Ngọc Duy Mon, 27 May 2013 11:18:47 +0000 (18:18 +0700)

prune-packed: avoid implying "1" is DRY_RUN in prune_packed_objects()

Commit b60daf0 (Make git-prune-packed a bit more chatty. - 2007-01-12)
changes the meaning of prune_packed_objects()'s argument, from "dry
run or not dry run" to a bitmap.

It however forgot to update prune_packed_objects() caller in
builtin/prune.c to use new DRY_RUN macro. It's fine (for a long time!)
but there is a risk that someday someone may change the value of
DRY_RUN to something else and builtin/prune.c suddenly breaks. Avoid
that possibility.

While at there, change "opts == VERBOSE" to "opts & VERBOSE" as there
is no obvious reason why we only be chatty when DRY_RUN is not set.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test: rebase: fix --interactive testFelipe Contreras Tue, 28 May 2013 12:54:31 +0000 (07:54 -0500)

test: rebase: fix --interactive test

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test: trivial cleanupsFelipe Contreras Tue, 28 May 2013 12:54:29 +0000 (07:54 -0500)

test: trivial cleanups

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote: trivial style cleanupFelipe Contreras Tue, 28 May 2013 12:54:27 +0000 (07:54 -0500)

remote: trivial style cleanup

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch: don't try to update unfetched tracking refsJohn Keeping Mon, 27 May 2013 16:33:09 +0000 (17:33 +0100)

fetch: don't try to update unfetched tracking refs

Since commit f269048 (fetch: opportunistically update tracking refs,
2013-05-11) we update tracking refs opportunistically when fetching
remote branches. However, if there is a configured non-pattern refspec
that does not match any of the refspecs given on the command line then a
fatal error occurs.

Fix this by setting the "missing_ok" flag when calling get_fetch_map.

Test-added-by: Jeff King <peff@peff.net>
Signed-off-by: John Keeping <john@keeping.me.uk>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

clone: open a shortcut for connectivity checkNguyễn Thái Ngọc Duy Sun, 26 May 2013 01:16:17 +0000 (08:16 +0700)

clone: open a shortcut for connectivity check

In order to make sure the cloned repository is good, we run "rev-list
--objects --not --all $new_refs" on the repository. This is expensive
on large repositories. This patch attempts to mitigate the impact in
this special case.

In the "good" clone case, we only have one pack. If all of the
following are met, we can be sure that all objects reachable from the
new refs exist, which is the intention of running "rev-list ...":

- all refs point to an object in the pack
- there are no dangling pointers in any object in the pack
- no objects in the pack point to objects outside the pack

The second and third checks can be done with the help of index-pack as
a slight variation of --strict check (which introduces a new condition
for the shortcut: pack transfer must be used and the number of objects
large enough to call index-pack). The first is checked in
check_everything_connected after we get an "ok" from index-pack.

"index-pack + new checks" is still faster than the current "index-pack
+ rev-list", which is the whole point of this patch. If any of the
conditions fail, we fall back to the good old but expensive "rev-list
..". In that case it's even more expensive because we have to pay for
the new checks in index-pack. But that should only happen when the
other side is either buggy or malicious.

Cloning linux-2.6 over file://

before after
real 3m25.693s 2m53.050s
user 5m2.037s 4m42.396s
sys 0m13.750s 0m16.574s

A more realistic test with ssh:// over wireless

before after
real 11m26.629s 10m4.213s
user 5m43.196s 5m19.444s
sys 0m35.812s 0m37.630s

This shortcut is not applied to shallow clones, partly because shallow
clones should have no more objects than a usual fetch and the cost of
rev-list is acceptable, partly to avoid dealing with corner cases when
grafting is involved.

This shortcut does not apply to unpack-objects code path either
because the number of objects must be small in order to trigger that
code path.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

index-pack: remove dead code (it should never happen)Nguyễn Thái Ngọc Duy Sun, 26 May 2013 01:16:16 +0000 (08:16 +0700)

index-pack: remove dead code (it should never happen)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fetch-pack: prepare updated shallow file before fetchin... Nguyễn Thái Ngọc Duy Sun, 26 May 2013 01:16:15 +0000 (08:16 +0700)

fetch-pack: prepare updated shallow file before fetching the pack

index-pack --strict looks up and follows parent commits. If shallow
information is not ready by the time index-pack is run, index-pack may
be led to non-existent objects. Make fetch-pack save shallow file to
disk before invoking index-pack.

git learns new global option --shallow-file to pass on the alternate
shallow file path. Undocumented (and not even support --shallow-file=
syntax) because it's unlikely to be used again elsewhere.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add support for --forceFelipe Contreras Sat, 25 May 2013 02:30:04 +0000 (21:30 -0500)

remote-hg: add support for --force

And get rid of the remote-hg.force-push option hack.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add support for --dry-runFelipe Contreras Sat, 25 May 2013 02:30:03 +0000 (21:30 -0500)

remote-hg: add support for --dry-run

This needs a specific patch from Git not applied yet.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: check if a fetch is neededFelipe Contreras Sat, 25 May 2013 02:30:02 +0000 (21:30 -0500)

remote-hg: check if a fetch is needed

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: trivial cleanupFelipe Contreras Sat, 25 May 2013 02:30:01 +0000 (21:30 -0500)

remote-hg: trivial cleanup

It's better to catch the exception later on.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-helpers: improve marks usageFelipe Contreras Sat, 25 May 2013 02:30:00 +0000 (21:30 -0500)

remote-helpers: improve marks usage

Always convert to strings (they are unicode because they come from JSON).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add check_push() helperFelipe Contreras Sat, 25 May 2013 02:29:59 +0000 (21:29 -0500)

remote-hg: add check_push() helper

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add setup_big_push() helperFelipe Contreras Sat, 25 May 2013 02:29:58 +0000 (21:29 -0500)

remote-hg: add setup_big_push() helper

So we don't duplicate these commands.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: remove files before modificationsFelipe Contreras Sat, 25 May 2013 02:29:57 +0000 (21:29 -0500)

remote-hg: remove files before modifications

Otherwise replacing a file with a directory doesn't work.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: improve lightweight tag authorFelipe Contreras Sat, 25 May 2013 02:29:56 +0000 (21:29 -0500)

remote-hg: improve lightweight tag author

Use git's committer.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: use remote 'default' not local oneFelipe Contreras Sat, 25 May 2013 02:29:55 +0000 (21:29 -0500)

remote-hg: use remote 'default' not local one

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: improve branch listingFelipe Contreras Sat, 25 May 2013 02:29:54 +0000 (21:29 -0500)

remote-hg: improve branch listing

We want to show the remote heads, not the internal ones, which might
have garbage.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: simplify branch_tip()Felipe Contreras Sat, 25 May 2013 02:29:53 +0000 (21:29 -0500)

remote-hg: simplify branch_tip()

It simply picks the last head that is not closed, but we have a stored
list of open heads.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: check diverged bookmarksFelipe Contreras Sat, 25 May 2013 02:29:52 +0000 (21:29 -0500)

remote-hg: check diverged bookmarks

So that we can report a proper error.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: pass around revision refsFelipe Contreras Sat, 25 May 2013 02:29:51 +0000 (21:29 -0500)

remote-hg: pass around revision refs

So that when a diverge is detected, we know which ref to report an error
for.

Also, since we are not throwing an exception, return a proper error
code.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: implement custom checkheads()Felipe Contreras Sat, 25 May 2013 02:29:50 +0000 (21:29 -0500)

remote-hg: implement custom checkheads()

The version from Mercurial is extremely inefficient and convoluted, this
version achieves basically the same, at least for our purposes.

No functional changes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: implement custom push()Felipe Contreras Sat, 25 May 2013 02:29:49 +0000 (21:29 -0500)

remote-hg: implement custom push()

The one from mercurial does a ton of things we are not interested in,
and we need some special modifications which are impossible otherwise.

Most of the code is borrowed from Mercurial, and cleaned up, but should
be functionally the same for our purposes, except that multiple heads
are not detected.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: only update necessary revisionsFelipe Contreras Sat, 25 May 2013 02:29:48 +0000 (21:29 -0500)

remote-hg: only update necessary revisions

We don't care about the rest, and in fact, we shouldn't try to push
everything, as there might be garbage from previous failed pushes.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: force remote bookmark push selectivelyFelipe Contreras Sat, 25 May 2013 02:29:47 +0000 (21:29 -0500)

remote-hg: force remote bookmark push selectively

If we update the 'old' node, we might be updating the remote bookmark
even when our 'new' node is not related at all to what the remote has,
effectively forcing an update.

Let's do that only when forced push is configured.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: reorganize bookmark handlingFelipe Contreras Sat, 25 May 2013 02:29:46 +0000 (21:29 -0500)

remote-hg: reorganize bookmark handling

We don't need to update both internal and remote bookmarks, so let's do
one or the other, and move the shared code earlier, so it's simpler.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add test for failed double pushFelipe Contreras Sat, 25 May 2013 02:29:45 +0000 (21:29 -0500)

remote-hg: add test for failed double push

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add test for big pushFelipe Contreras Sat, 25 May 2013 02:29:44 +0000 (21:29 -0500)

remote-hg: add test for big push

With lots branches and bookmarks, non-ff, updated and new.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add test for new bookmark specialFelipe Contreras Sat, 25 May 2013 02:29:43 +0000 (21:29 -0500)

remote-hg: add test for new bookmark special

From the point of view of Mercurial, this creates a new branch head,
and requires a forced push.

Ideally, however, we would want it to work just like in git; new
branches can be pushed without problems.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add test for bookmark divergeFelipe Contreras Sat, 25 May 2013 02:29:42 +0000 (21:29 -0500)

remote-hg: add test for bookmark diverge

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add test for diverged pushFelipe Contreras Sat, 25 May 2013 02:29:41 +0000 (21:29 -0500)

remote-hg: add test for diverged push

Neither mercurial nor git allows pushing to a remote when it's a
non-fast-forward push. We should be able to detect these errors and
report them properly, as opposed to throwing an exception
stack-trace.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add test to push new bookmarkFelipe Contreras Sat, 25 May 2013 02:29:40 +0000 (21:29 -0500)

remote-hg: add test to push new bookmark

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add remote testsFelipe Contreras Sat, 25 May 2013 02:29:39 +0000 (21:29 -0500)

remote-hg: add remote tests

The logic when working with a local repository is totally different from
the one where we work with a remote repository; we need to pull and push
from it.

All this logic is currently not tested at all, so let's introduce a
variable to force the remote behavior.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: update bookmarks when using a remoteFelipe Contreras Sat, 25 May 2013 02:29:38 +0000 (21:29 -0500)

remote-hg: update bookmarks when using a remote

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add check_bookmark() test helperFelipe Contreras Sat, 25 May 2013 02:29:37 +0000 (21:29 -0500)

remote-hg: add check_bookmark() test helper

And check in a more proper way.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: simplify test checksFelipe Contreras Sat, 25 May 2013 02:29:36 +0000 (21:29 -0500)

remote-bzr: simplify test checks

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add tests for 'master' bookmarkFelipe Contreras Sat, 25 May 2013 02:29:35 +0000 (21:29 -0500)

remote-hg: add tests for 'master' bookmark

We want to make sure everything works correctly, even if there's a
'master' bookmark in Mercurial.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: always point HEAD to masterFelipe Contreras Sat, 25 May 2013 02:29:34 +0000 (21:29 -0500)

remote-hg: always point HEAD to master

Mercurial always checks out the 'default' branch, so there's no point in
complicating our lives trying to do something fancier, which causes
different behavior depending on whether the repository is local or
remote.

So let's always use 'default' (which we translate to 'master'), unless
we are in hg-git mode, which expects us to use the 'master' bookmark
instead.

Also, update the tests that used to check for different checkout
behaviors to simply check that the refs are there, remove unnecessary
ones, and fix the ones that expect something different.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: improve progress calculationFelipe Contreras Sat, 25 May 2013 02:29:33 +0000 (21:29 -0500)

remote-hg: improve progress calculation

No need to manually keep track of the revision count.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: trivial cleanupsFelipe Contreras Sat, 25 May 2013 02:29:32 +0000 (21:29 -0500)

remote-hg: trivial cleanups

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: ensure remote rebasing worksFelipe Contreras Sat, 25 May 2013 02:29:31 +0000 (21:29 -0500)

remote-hg: ensure remote rebasing works

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: upgrade version 1 marksFelipe Contreras Sat, 25 May 2013 02:29:30 +0000 (21:29 -0500)

remote-hg: upgrade version 1 marks

As suggested by Jed Brown; there's no need to re-import all the commits.

Cc: Jed Brown <jed@59a2.org>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: switch from revisions to SHA-1 noteidsFelipe Contreras Sat, 25 May 2013 02:29:29 +0000 (21:29 -0500)

remote-hg: switch from revisions to SHA-1 noteids

Otherwise we won't know if revisions are replaced.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: add version checks to the marksFelipe Contreras Sat, 25 May 2013 02:29:28 +0000 (21:29 -0500)

remote-hg: add version checks to the marks

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: improve node traversingFelipe Contreras Sat, 25 May 2013 02:29:27 +0000 (21:29 -0500)

remote-hg: improve node traversing

We won't be able to count the unmarked commits, but we are not going to
be able to do that anyway when we switch to SHA-1 ids.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: shuffle some codeFelipe Contreras Sat, 25 May 2013 02:29:26 +0000 (21:29 -0500)

remote-hg: shuffle some code

In preparation to shift to SHA-1's.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: use a shared repository storeFelipe Contreras Sat, 25 May 2013 02:29:25 +0000 (21:29 -0500)

remote-hg: use a shared repository store

This way we don't have to have duplicated Mercurial objects.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: load all extensionsFelipe Contreras Sat, 25 May 2013 02:29:24 +0000 (21:29 -0500)

remote-hg: load all extensions

The user might have then configured differently, plus, all of them will
be loaded anyway later on.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: test: simplify previous branch checkoutFelipe Contreras Sat, 25 May 2013 02:29:23 +0000 (21:29 -0500)

remote-hg: test: simplify previous branch checkout

@{-1} does the same thing.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-helpers: test: simplify remote URLsFelipe Contreras Sat, 25 May 2013 02:29:22 +0000 (21:29 -0500)

remote-helpers: test: simplify remote URLs

No need to specify $PWD any more.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-helpers: tests: general improvementsFelipe Contreras Sat, 25 May 2013 02:29:21 +0000 (21:29 -0500)

remote-helpers: tests: general improvements

So that we don't need a temporary directory.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-helpers: test: cleanup styleFelipe Contreras Sat, 25 May 2013 02:29:20 +0000 (21:29 -0500)

remote-helpers: test: cleanup style

So it's more standardized between all the tests.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-helpers: test: cleanup white-spacesFelipe Contreras Sat, 25 May 2013 02:29:19 +0000 (21:29 -0500)

remote-helpers: test: cleanup white-spaces

We prefer tabs to spaces.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: trivial reorganizationFelipe Contreras Sat, 25 May 2013 02:29:18 +0000 (21:29 -0500)

remote-hg: trivial reorganization

We only need to get the remote dict once.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-hg: test: be a little more quietFelipe Contreras Sat, 25 May 2013 02:29:17 +0000 (21:29 -0500)

remote-hg: test: be a little more quiet

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: add fallback check for a partial cloneFelipe Contreras Sat, 25 May 2013 02:24:26 +0000 (21:24 -0500)

remote-bzr: add fallback check for a partial clone

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: reorganize the way 'wanted' worksFelipe Contreras Sat, 25 May 2013 02:24:25 +0000 (21:24 -0500)

remote-bzr: reorganize the way 'wanted' works

If the user specified a list of branches, we ignore what the remote
repository lists, and simply use the branches directly. Since some
remotes don't report the branches correctly, this is useful.

Otherwise either fetch the repo, or the branch.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: trivial cleanupsFelipe Contreras Sat, 25 May 2013 02:24:24 +0000 (21:24 -0500)

remote-bzr: trivial cleanups

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: change global repoFelipe Contreras Sat, 25 May 2013 02:24:23 +0000 (21:24 -0500)

remote-bzr: change global repo

It's not used anyway.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: delay cloning/pullingFelipe Contreras Sat, 25 May 2013 02:24:22 +0000 (21:24 -0500)

remote-bzr: delay cloning/pulling

Until the branch is actually going to be used.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: simplify get_remote_branch()Felipe Contreras Sat, 25 May 2013 02:24:21 +0000 (21:24 -0500)

remote-bzr: simplify get_remote_branch()

No need for 'origin', it's only needed for the bzrdir 'sprout' method,
which can be greatly simplified.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: fix for files with spacesFelipe Contreras Sat, 25 May 2013 02:24:20 +0000 (21:24 -0500)

remote-bzr: fix for files with spaces

Set the maximum number of splits to make when dividing the diff stat
lines based on space characters.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

remote-bzr: recover from failed clonesFelipe Contreras Sat, 25 May 2013 02:24:19 +0000 (21:24 -0500)

remote-bzr: recover from failed clones

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

build: do not install git-remote-testpyFelipe Contreras Sat, 25 May 2013 02:41:06 +0000 (21:41 -0500)

build: do not install git-remote-testpy

It's only meant for testing.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

build: add NO_INSTALL variableFelipe Contreras Sat, 25 May 2013 02:41:05 +0000 (21:41 -0500)

build: add NO_INSTALL variable

So that we can specify which scripts we do not want to install (they are
for testing).

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>