Commit Graph

10183 Commits

Author SHA1 Message Date
Sam Hocevar
1f90a64891 git-p4: reduce number of server queries for fetches
When fetching changes from a depot using a full client spec, there
is no need to perform as many queries as there are top-level paths
in the client spec.  Instead we query all changes in chronological
order, also getting rid of the need to sort the results and remove
duplicates.

Signed-off-by: Sam Hocevar <sam@hocevar.net>
Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-21 11:26:55 -08:00
Luke Diamand
785e70f467 git-p4: failing test case for skipping changes with multiple depots
James Farwell reported that with multiple depots git-p4 would
skip changes.

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

Add a failing test case demonstrating the problem.

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-14 14:03:45 -08:00
Junio C Hamano
c87eec9784 Merge branch 'cb/t3404-shellquote'
* cb/t3404-shellquote:
  t3404: fix quoting of redirect for some versions of bash
2015-12-11 10:40:58 -08:00
Junio C Hamano
2b597f3307 Merge branch 'ls/test-must-fail-sigpipe'
Fix some racy client/server tests by treating SIGPIPE the same as a
normal non-zero exit.

* ls/test-must-fail-sigpipe:
  add "ok=sigpipe" to test_must_fail and use it to fix flaky tests
  implement test_might_fail using a refactored test_must_fail
2015-12-08 14:14:49 -08:00
Charles Bailey
7966230b7d t3404: fix quoting of redirect for some versions of bash
As CodingGuidelines says, some versions of bash errors out when
$variable substitution is used as the target for redirection without
being quoted (even though POSIX may not require such a quote).

Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-04 14:05:18 -08:00
Junio C Hamano
80c17cac36 Merge branch 'sg/bash-prompt-dirty-orphan'
Produce correct "dirty" marker for shell prompts, even when we
are on an orphan or an unborn branch.

* sg/bash-prompt-dirty-orphan:
  bash prompt: indicate dirty index even on orphan branches
  bash prompt: remove a redundant 'git diff' option
  bash prompt: test dirty index and worktree while on an orphan branch
2015-12-04 11:19:12 -08:00
Junio C Hamano
c69d08df96 Merge branch 'jk/send-email-complete-aliases'
Teach send-email to dump mail aliases, so that we can do tab completion
on the command line.

* jk/send-email-complete-aliases:
  completion: add support for completing email aliases
  sendemail: teach git-send-email to dump alias names
2015-12-04 11:19:11 -08:00
Junio C Hamano
2e5adec97a Merge branch 'jk/filter-branch-no-index'
Speed up filter-branch for cases where we only care about rewriting
commits, not tree data.

* jk/filter-branch-no-index:
  filter-branch: skip index read/write when possible
2015-12-04 11:19:10 -08:00
Jeff King
fd13a2ecfb Merge branch 'mk/blame-first-parent'
Regression fix for a topic already in master.

* mk/blame-first-parent:
  blame: fix object casting regression
2015-12-01 18:54:58 -05:00
Jeff King
e2187fe520 Merge branch 'rs/fsck-nul-header'
Fsck did not correctly detect a NUL-truncated header in a tag.

* rs/fsck-nul-header:
  fsck: treat a NUL in a tag header as an error
  t1450: add tests for NUL in headers of commits and tags
2015-12-01 18:54:47 -05:00
Jeff King
fa7095e63d Merge branch 'ls/p4-test-timeouts'
Work around some test flakiness with p4d.

* ls/p4-test-timeouts:
  git-p4: add trap to kill p4d on test exit
  git-p4: add p4d timeout in tests
  git-p4: retry kill/cleanup operations in tests with timeout
2015-12-01 18:54:40 -05:00
Jeff King
e0dd81b08e Merge branch 'js/test-modernize-t9300'
Clean up style in an ancient test.

* js/test-modernize-t9300:
  modernize t9300: move test preparations into test_expect_success
  modernize t9300: mark here-doc words to ignore tab indentation
  modernize t9300: use test_when_finished for clean-up
  modernize t9300: wrap lines after &&
  modernize t9300: use test_must_be_empty
  modernize t9300: use test_must_fail
  modernize t9300: single-quote placement and indentation
2015-12-01 18:54:37 -05:00
Jeff King
40fdcc5357 Merge branch 'maint'
* maint:
  http: treat config options sslCAPath and sslCAInfo as paths
  Documentation/diff: give --word-diff-regex=. example
  filter-branch: deal with object name vs. pathname ambiguity in tree-filter
  check-ignore: correct documentation about output
  git-p4: clean up after p4 submit failure
  git-p4: work with a detached head
  git-p4: add option to system() to return subshell status
  git-p4: add failing test for submit from detached head
  remote-http(s): support SOCKS proxies
  t5813: avoid creating urls that break on cygwin
  Escape Git's exec path in contrib/rerere-train.sh script
  allow hooks to ignore their standard input stream
  rebase-i-exec: Allow space in SHELL_PATH
  Documentation: make environment variable formatting more consistent
2015-12-01 17:32:38 -05:00
Jeff King
908a6e4156 Merge branch 'eg/p4-submit-catch-failure' into maint
Just like the working tree is cleaned up when the user cancelled
submission in P4Submit.applyCommit(), clean up the mess if "p4
submit" fails.

* eg/p4-submit-catch-failure:
  git-p4: clean up after p4 submit failure
2015-12-01 17:24:21 -05:00
Jeff King
5b228f956a Merge branch 'ld/p4-detached-head' into maint
Make git-p4 work on a detached head.

* ld/p4-detached-head:
  git-p4: work with a detached head
  git-p4: add option to system() to return subshell status
  git-p4: add failing test for submit from detached head
2015-12-01 17:21:29 -05:00
Jeff King
978b5760a1 Merge branch 'sg/filter-branch-dwim-ambiguity' into maint
Fix for a corner case in filter-branch.

* sg/filter-branch-dwim-ambiguity:
  filter-branch: deal with object name vs. pathname ambiguity in tree-filter
2015-12-01 17:21:17 -05:00
Jeff King
76fdb0640e Merge branch 'dk/t5813-unc-paths' into maint
Test portability fix for a topic in v2.6.1.

* dk/t5813-unc-paths:
  t5813: avoid creating urls that break on cygwin
2015-12-01 17:20:52 -05:00
Lars Schneider
8bf4becf0c add "ok=sigpipe" to test_must_fail and use it to fix flaky tests
t5516 "75 - deny fetch unreachable SHA1, allowtipsha1inwant=true" is
flaky in the following case:
1. remote upload-pack finds out "not our ref"
2. remote sends a response and closes the pipe
3. fetch-pack still tries to write commands to the remote upload-pack
4. write call in wrapper.c dies with SIGPIPE

The test is flaky because the sending fetch-pack may or may
not have finished writing its output by step (3). If it did,
then we see a closed pipe on the next read() call. If it
didn't, then we get the SIGPIPE from step (4) above. Both
are fine, but the latter fools test_must_fail.

t5504 "9 - push with transfer.fsckobjects" is flaky, too, and returns
SIGPIPE once in a while. I had to remove the final "To dst..." output
check because there is no output if the process dies with SIGPIPE.

Accept such a death-with-sigpipe also as OK when we are expecting a
failure.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-28 12:06:14 -05:00
Lars Schneider
bbfe5302d5 implement test_might_fail using a refactored test_must_fail
Add an (optional) first parameter "ok=<special case>" to test_must_fail
and return success for "<special case>". Add "success" as
"<special case>" and use it to implement "test_might_fail". This removes
redundancies in test-lib-function.sh.

You can pass multiple <special case> arguments divided by comma (e.g.
"test_must_fail ok=success,something")

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-28 12:04:28 -05:00
SZEDER Gábor
4d2a3646d1 filter-branch: deal with object name vs. pathname ambiguity in tree-filter
'git filter-branch' fails complaining about an ambiguous argument, if
a tree-filter renames a path and the new pathname happens to match an
existing object name.

After the tree-filter has been applied, 'git filter-branch' looks for
changed paths by running:

  git diff-index -r --name-only --ignore-submodules $commit

which then, because of the lack of disambiguating double-dash, can't
decide whether to treat '$commit' as revision or path and errors out.

Add that disambiguating double-dash after 'git diff-index's revision
argument to make sure that '$commit' is interpreted as a revision.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-24 18:37:50 -05:00
Jeff King
7cb5f7c44d blame: fix object casting regression
Commit 1b0d400 refactored the prepare_final() function so
that it could be reused in multiple places. Originally, the
loop had two outputs: a commit to stuff into sb->final, and
the name of the commit from the rev->pending array.

After the refactor, that loop is put in its own function
with a single return value: the object_array_entry from the
rev->pending array. This contains both the name and the object,
but with one important difference: the object is the
_original_ object found by the revision parser, not the
dereferenced commit. If one feeds a tag to "git blame", we
end up casting the tag object to a "struct commit", which
causes a segfault.

Instead, let's return the commit (properly casted) directly
from the function, and take the "name" as an optional
out-parameter. This does the right thing, and actually
simplifies the callers, who no longer need to cast or
dereference the object_array_entry themselves.

[test case by Max Kirillov <max@max630.net>]

Signed-off-by: Jeff King <peff@peff.net>
2015-11-24 17:07:04 -05:00
GIRARD Etienne
b7638fed42 git-p4: clean up after p4 submit failure
When "p4 submit" command fails in P4Submit.applyCommit, the
workspace is left with the changes.  We already have code to revert
the changes to the workspace when the user decides to cancel
submission by aborting the editor that edits the change description,
and we should treat the "p4 submit" failure the same way.

Clean the workspace if p4_write_pipe raised SystemExit, so that the
user don't have to do it themselves.

Signed-off-by: GIRARD Etienne <egirard@murex.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-24 15:41:59 -05:00
SZEDER Gábor
c26f70ceb3 bash prompt: indicate dirty index even on orphan branches
__git_ps1() doesn't indicate dirty index while on an orphan branch.

To check the dirtiness of the index, __git_ps1() runs 'git diff-index
--cached ... HEAD', which doesn't work on an orphan branch,
because HEAD doesn't point to a valid commit.

Run 'git diff ... --cached' instead, as it does the right thing both
on valid and invalid HEAD, i.e. compares the index to the existing
HEAD in the former case and to the empty tree in the latter.  This
fixes the two failing tests added in the first commit of this series.

The dirtiness of the worktree is already checked with 'git diff' and
is displayed correctly even on an orphan branch.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-24 15:27:01 -05:00
SZEDER Gábor
a30d11ebdf bash prompt: test dirty index and worktree while on an orphan branch
There is only a single test exercising the dirty state indicator on an
orphan branch, and in that test neither the index nor the worktree are
dirty.

Add two failing tests to check the dirty state indicator while either
the index is dirty or while both the index and the worktree are dirty
on an orphan branch, and to show that the dirtiness of the index is
not displayed in these cases (the fourth combination, i.e. clean index
and dirty worktree are impossible on an orphan branch).  Update the
existing dirty state indicator on clean orphan branch test to match
the style of the two new tests, most importantly to use 'git checkout
--orphan' instead of cd-ing into a repository that just happens to be
empty and clean.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-24 15:27:01 -05:00
Luke Diamand
00ad6e3182 git-p4: work with a detached head
When submitting, git-p4 finds the current branch in
order to know if it is allowed to submit (configuration
"git-p4.allowSubmit").

On a detached head, detecting the branch would fail, and
git-p4 would report a cryptic error.

This change teaches git-p4 to recognise a detached head and
submit successfully.

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-24 15:20:15 -05:00
Luke Diamand
74b6fe9202 git-p4: add failing test for submit from detached head
git-p4 can't submit from a detached head. This test case
demonstrates the problem.

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-24 15:20:15 -05:00
René Scharfe
8a272f291a fsck: treat a NUL in a tag header as an error
We check the return value of verify_header() for commits already, so do
the same for tags as well.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:07 -05:00
René Scharfe
80c7f5a011 t1450: add tests for NUL in headers of commits and tags
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:07 -05:00
Lars Schneider
dfe90e8b52 git-p4: add trap to kill p4d on test exit
Sometimes the "prove" test runner hangs on test exit because p4d is
still running. Add a trap to always kill "p4d" on test exit.

You can reproduce the problem by commenting "P4D_TIMEOUT" in
"lib-git-p4.sh" and running "prove ./t9800-git-p4-basic.sh".

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Johannes Sixt
68297e0fd8 modernize t9300: move test preparations into test_expect_success
Our usual style these days is to execute everything inside
test_expect_success. Make it so.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Jacob Keller
17b7a83244 sendemail: teach git-send-email to dump alias names
Add an option "--dump-aliases" which changes the default behavior of
git-send-email. This mode will simply read the alias files configured by
sendemail.aliasesfile and sendemail.aliasfiletype and dump a list of all
configured aliases, one per line. The intended use case for this option
is the bash-completion script which will use it to autocomplete aliases
on the options which take addresses.

Add some tests for the new option using various alias file formats.

A possible future extension to the alias dump format could be done by
extending the --dump-aliases to take an optional argument defining the
format to display. This has not been done in this patch as no user of
this information has been identified.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Lars Schneider
842addef70 git-p4: add p4d timeout in tests
In rare cases p4d seems to hang. This watchdog will kill the p4d
process after 300s in any case. That means each individual git p4 test
needs to finish before 300s or it will fail.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Acked-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Johannes Sixt
0ca2972345 modernize t9300: mark here-doc words to ignore tab indentation
In the next commit, we will indent test case preparations. This will
require that here-documents ignore the tab indentation. Prepare for
this change by marking the here-doc words accordingly. This does not
have an effect now, but will remove some noise from the git diff -b
output of the next commit.

The change here is entirely automated with this perl command:

  perl -i -lpe 's/(cat.*<<) *((EOF|(EXPECT|INPUT)_END).*$)/$1-$2 &&/' t/t9300-fast-import.sh

i.e., inserts a dash between << and the EOF word (and removes blanks
that our style guide abhors) and appends the && that will become
necessary.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Lars Schneider
23aee4199a git-p4: retry kill/cleanup operations in tests with timeout
In rare cases kill/cleanup operations in tests fail. Retry these
operations with a timeout to make the test less flaky.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Johannes Sixt
93e911f5ae modernize t9300: use test_when_finished for clean-up
A number of clean-ups of test cases are performed outside of
test_expect_success. Replace these cases by using test_when_finished.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Johannes Sixt
ec2c10bef8 modernize t9300: wrap lines after &&
It is customary to have each command in test snippets on its own line.
Fix those instances that do not follow this guideline.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Johannes Sixt
acf3af25fb modernize t9300: use test_must_be_empty
Instead of comparing actual output to an empty file, use
test_must_be_empty. In addition to the better error message provided by
the helper, allocation of an empty file during the setup sequence can be
avoided.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Johannes Sixt
b08d82f0e8 modernize t9300: use test_must_fail
One test case open-codes a test for an expected failure. Replace it by
test_must_fail.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Johannes Sixt
d67824feaa modernize t9300: single-quote placement and indentation
Many test cases do not follow our modern style that places the
single-quotes that surround the shell code snippets before and after
the shell code. Make it so.

Many of the lines changed in this way are indented other than by a
single tab. Change them (and some additional lines) to be indented
with a tab.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 08:02:06 -05:00
Jeff King
dbba85e46b Merge branch 'lf/ref-is-hidden-namespace'
Extend transfer.hideRefs to work better with use of namespaces.

* lf/ref-is-hidden-namespace:
  t5509: add basic tests for hideRefs
  hideRefs: add support for matching full refs
  upload-pack: strip refs before calling ref_is_hidden()
  config.txt: document the semantics of hideRefs with namespaces
2015-11-20 06:56:11 -05:00
Jeff King
45014beac0 Merge branch 'dk/gc-idx-wo-pack'
Having a leftover .idx file without corresponding .pack file in
the repository hurts performance; "git gc" learned to prune them.

* dk/gc-idx-wo-pack:
  gc: remove garbage .idx files from pack dir
  t5304: test cleaning pack garbage
  prepare_packed_git(): refactor garbage reporting in pack directory
2015-11-20 06:55:34 -05:00
Dennis Kaarsemaker
681390b3f6 t5813: avoid creating urls that break on cygwin
When passed an ssh:// url, git strips ssh://host from the url but does
not remove leading slashes from the path. So when this test used
ssh://remote//path/to/pwd, the path accessed by our fake SSH is
//path/to/pwd, which cygwin interprets as a UNC path, causing the test
to fail.

We may want to actually fix this in git itself, making it remove extra
slashes from urls before feeding them to transports or helpers, but
that's for another topic as it could cause regressions.

Signed-off-by: Dennis Kaarsemaker <dennis@kaarsemaker.net>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-20 06:46:48 -05:00
Clemens Buchacher
af65f68cdf allow hooks to ignore their standard input stream
Since ec7dbd145 (receive-pack: allow hooks to ignore its
standard input stream) the pre-receive and post-receive
hooks ignore SIGPIPE. Do the same for the remaining hooks
pre-push and post-rewrite, which read from standard input.
The same arguments for ignoring SIGPIPE apply.

Include test by Jeff King which checks that SIGPIPE does not
cause pre-push hook failure. With the use of git update-ref
--stdin it is fast enough to be enabled by default.

Signed-off-by: Clemens Buchacher <clemens.buchacher@intel.com>
Signed-off-by: Jeff King <peff@peff.net>
2015-11-16 08:59:19 -05:00
Jeff King
348d4f2fc5 filter-branch: skip index read/write when possible
If the user specifies an index filter but not a tree filter,
filter-branch cleverly avoids checking out the tree
entirely. But we don't do the next level of optimization: if
you have no index or tree filter, we do not need to read the
index at all.

This can greatly speed up cases where we are only changing
the commit objects (e.g., cementing a graft into place).
Here are numbers from the newly-added perf test:

  Test                  HEAD^              HEAD
  ---------------------------------------------------------------
  7000.2: noop filter   13.81(4.95+0.83)   5.43(0.42+0.43) -60.7%

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-11-06 09:35:49 -08:00
Junio C Hamano
db43891ce6 Merge branch 'rs/wt-status-detached-branch-fix' into maint
"git status --branch --short" accessed beyond the constant string
"HEAD", which has been corrected.

* rs/wt-status-detached-branch-fix:
  wt-status: use skip_prefix() to get rid of magic string length constants
  wt-status: don't skip a magical number of characters blindly
  wt-status: avoid building bogus branch name with detached HEAD
  wt-status: exit early using goto in wt_shortstatus_print_tracking()
  t7060: add test for status --branch on a detached HEAD
2015-11-05 12:18:15 -08:00
Junio C Hamano
a878e7e62b Merge branch 'jc/add-u-A-default-to-top' into maint
"git --literal-pathspecs add -u/-A" without any command line
argument misbehaved ever since Git 2.0.

* jc/add-u-A-default-to-top:
  add: simplify -u/-A without pathspec
2015-11-05 12:18:12 -08:00
Junio C Hamano
5e6154fb14 Merge branch 'jk/delete-modechange-conflict' into maint
Merging a branch that removes a path and another that changes the
mode bits on the same path should have conflicted at the path, but
it didn't and silently favoured the removal.

* jk/delete-modechange-conflict:
  merge: detect delete/modechange conflict
  t6031: generalize for recursive and resolve strategies
  t6031: move triple-rename test to t3030
2015-11-05 12:18:11 -08:00
Junio C Hamano
4349f597f0 Merge branch 'nd/clone-linked-checkout' into maint
It was not possible to use a repository-lookalike created by "git
worktree add" as a local source of "git clone".

* nd/clone-linked-checkout:
  clone: better error when --reference is a linked checkout
  clone: allow --local from a linked checkout
  enter_repo: allow .git files in strict mode
  enter_repo: avoid duplicating logic, use is_git_directory() instead
  t0002: add test for enter_repo(), non-strict mode
  path.c: delete an extra space
2015-11-05 12:18:08 -08:00
Lukas Fleischer
948bfa2c0f t5509: add basic tests for hideRefs
Test whether regular and full hideRefs patterns work as expected when
namespaces are used.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-11-05 11:25:02 -08:00
Doug Kelly
478f34d2b6 gc: remove garbage .idx files from pack dir
Add a custom report_garbage handler to collect and remove
garbage .idx files from the pack directory.

Signed-off-by: Doug Kelly <dougk.ff7@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-11-04 11:30:22 -08:00