Commit Graph

34379 Commits

Author SHA1 Message Date
Jeff King
2af037bc0b send-pack: show progress when isatty(2)
The send_pack_args struct has two verbosity flags: "quiet"
and "progress". Originally, if "quiet" was set, we would
tell pack-objects explicitly to be quiet, and if "progress"
was set, we would tell it to show progress. Otherwise, we
told it neither, and it relied on isatty(2) to make the
decision itself.

However, commit 01fdc21 changed the meaning of these
variables. Now both "quiet" and "!progress" instruct us to
tell pack-objects to be quiet (and a non-zero "progress"
means the same as before). This works well for transports
which call send_pack directly, as the transport code copies
transport->progress into send_pack_args->progress, and they
both have the same meaning.

However, the code path of calling "git send-pack" was left
behind. It always sets "progress" to 0, and thus always
tells pack-objects to be quiet.  We can work around this by
checking isatty(2) ourselves in the cmd_send_pack code path,
restoring the original behavior of the send-pack command.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-05-02 03:00:52 +02:00
Johannes Schindelin
aa4aafb7da Merge remote-tracking branch 'kblees/kb/fix-broken-pipe-detection-v2' into devel 2012-04-09 21:19:40 -05:00
Johannes Schindelin
d084f44fb6 Windows: make sure that merge-octopus only outputs LF line endings
This happens to shut up t7602 on Windows which would otherwise take
the different line endings for a sign that the merge failed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-09 21:14:50 -05:00
Johannes Schindelin
77f5ee0d66 fast-export: report SHA-1 instead of gibberish when marks exist already
Cc: Pieter de Bie <pdebie@ai.rug.nl>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-09 16:38:31 -05:00
Johannes Schindelin
3c85385aaa squash! remote-hg: do not interfer with hg's revs() method
FIXUP: the field is called 'revs_' now, Sverre likes that better.
2012-04-09 15:44:14 -05:00
Johannes Schindelin
de09888e88 fixup! remote-hg: do not interfer with hg's revs() method 2012-04-09 14:47:14 -05:00
Johannes Schindelin
6a78c1cc84 Always auto-gc after calling a fast-import transport
After importing anything with fast-import, we should always let the
garbage collector do its job, since the objects are written to disk
inefficiently.

This brings down an initial import of http://selenic.com/hg from about
230 megabytes to about 14.

In the future, we may want to make this configurable on a per-remote
basis, or maybe teach fast-import about it in the first place.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-09 13:04:39 -05:00
Heiko Voigt
64a8a034d2 Windows: Always normalize paths to Windows-style
It appears that `pwd` returns the POSIX-style or the DOS-style path
depending which style the previous `cd` used. To normalize, enforce `pwd
-W` in scripts.

From the original e-mail exchange:

On Thu, Mar 22, 2012 at 11:13:37AM +0100, Sebastian Schuberth wrote:
> On Wed, Mar 21, 2012 at 22:21, Johannes Sixt <j6t@kdbg.org> wrote:
>
> > I build git and run its tests outside the msysgit environment. Does that
> > explain the difference? (And I use CMD.)
>
> It does not make a difference for me. I started cmd.exe at
> c:\msysgit\git\t, added c:\msysgit\bin temporarily to PATH, and ran
> "sh t5526-fetch-submodules.sh -i -v", and the test still fails.

Yes it probably does. Johannes said that he runs the tests outside of
the msysgit folder. That way there is only one path the submodule script
gets reported and not two like '/c/msysgit/git' and '/git'.

That would explain to me why it is passing.

I am afraid that the only solution is to patch msys itself to report the
long absolute path when passing window style paths to cd. Currently when
I do

	cd c:/msysgit/git

I will end up in '/git' instead of the long path.

I found that there is a -W option to pwd in msys bash which makes it
always return the real windows path. A normalization in that direction
is unique and thus might be more robust. Have a look at the attached
patch. With this at least t5526 passes. I was not able to run the whole
testsuite properly at the moment. I can have a look at that tomorrow.

What do you think?

Cheers Heiko

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-07 14:44:52 -05:00
Johannes Schindelin
1729079df8 fixup! Mark all remote-hg push tests as broken
This reverts that. With the next rebasing merge, just 'git rebase
--continue'.
2012-04-07 02:18:31 -05:00
Johannes Schindelin
8b89e59b73 remote-hg: do not interfer with hg's revs() method
Matt Mackall introduced a revs() method to the localrepo class on Wed
Nov 2 13:37:34 2011 in the commit 'localrepo: add revs helper method'.
It is used when constructing a commit in memory.

If we store the set of revs we want to handle under the same name, it
overrides that method, resulting in an unpleasant 'TypeError: 'set'
object is not callable' whenever we want to push (as we are constructing
commits in memory, then).

So let's work around that by renaming our field to 'revs2' and hope that
upstream Mercurial does not introduce a field of that name, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-07 02:12:55 -05:00
Johannes Schindelin
699dee3664 Mark all remote-hg push tests as broken
For now, remote-hg cannot be used for pushing. The respective tests fail
thusly:

warning: non-alnum alias 'remote:///git/t/trash directory.t5801-remote-hg/empty'
transaction abort!
rollback completed
Traceback (most recent call last):
  File "/git/git-remote-hg", line 101, in <module>
    sys.exit(HgRemoteHelper().main(sys.argv))
  File ".../lib/git_remote_helpers/helper.py", line 197, in main
    more = self.read_one_line(repo)
  File ".../lib/git_remote_helpers/helper.py", line 163, in read_one_line
    func(repo, cmdline)
  File ".../lib/git_remote_helpers/helper.py", line 121, in do_export
    localrepo.importer.do_import(localrepo.gitdir)
  File ".../lib/git_remote_helpers/hg/importer.py", line 27, in do_import
    processor.parseMany(sources, parser.ImportParser, procc)
  File ".../lib/git_remote_helpers/fastimport/processor.py", line 219,
        in parseMany
    processor.process(parser.parse())
  File ".../lib/git_remote_helpers/fastimport/processor.py", line 76,
        in process
    handler(self, cmd)
  File ".../lib/git_remote_helpers/hg/hgimport.py", line 262,
        in commit_handler
    self.idmap[cmd.id] = self.putcommit(modified, modes, copies, cmt)
  File ".../lib/git_remote_helpers/hg/hgimport.py", line 294, in putcommit
    self.repo.commitctx(ctx)
  File "/lib/python/mercurial/localrepo.py", line 1315, in commitctx
    phases.retractboundary(self, targetphase, [n])
  File "/lib/python/mercurial/phases.py", line 201, in retractboundary
    currentroots.intersection_update(ctx.node() for ctx in ctxs)
  File "/lib/python/mercurial/phases.py", line 201, in <genexpr>
    currentroots.intersection_update(ctx.node() for ctx in ctxs)
  File "/lib/python/mercurial/localrepo.py", line 264, in set
    for r in self.revs(expr, *args):
TypeError: 'set' object is not callable

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-07 01:05:52 -05:00
Johannes Schindelin
dfcd9fdf22 remote-hg: handle another funny author line from http://scelenic.com/hg
In this case: David Soria Parra <dsp <at> php.net>.

With this last of three Postel patches, remote-hg can import the
Mercurial repository completely.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-07 01:05:52 -05:00
Johannes Schindelin
649a45202b remote-hg: another case of Postel's law
This change allows invalid input from Mercurial repositories where the
author is recorded as 'Name <email@blah' (missing the closing '>').

With this change, importing http://scelenic.com/hg itself no longer fails
with:

	fatal: Missing > in ident string: Benoit Boissinot
	<benoit.boissinot@ens-lyon.org <none@none> 1129685868 -0700

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-07 01:05:52 -05:00
Johannes Schindelin
5a0ff88aba remote-hg: Postel's law dictates we should handle Author<author@mail>
We should handle a missing space before the email part of an author ident
gracefully. See for example the icedtea6 repository.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2012-04-06 17:14:12 -05:00
Michael J Gruber
d0a618b421 t5801: skip without hg
The tests for remote-hg require hg, so skip them all when there is no
hg available.
2012-04-06 17:14:12 -05:00
Michael J Gruber
1d49c1b174 t5800: clarify skip message
The skip message takes about remote-hg while the tests are about the
general remote helper framework (and don't require hg). Correct the
message.
2012-04-06 17:14:12 -05:00
Sverre Rabbelier
31470d459c git-remote-hg: add tests 2012-04-06 17:14:12 -05:00
Sverre Rabbelier
2ec3a3e945 git-remote-hg: add the helper
The helper uses the previously added infrastructure.
2012-04-06 17:14:12 -05:00
Michael J Gruber
a5cc7703e7 remote-hg: adjust to hg 1.9
hg 1.0 changed the signature of hg.clone(). Adjust to it.

A real fix would need to check the hg version or try/catch.
2012-04-06 17:14:12 -05:00
Sverre Rabbelier
82b1c41b46 git-remote-hg: add GitExporter/GitImporter/NonLocalGit
This is inftrastructure required to implement git-remote-hg.
2012-04-06 17:14:12 -05:00
Sverre Rabbelier
c680182d66 git-remote-hg: add hgexport, an hg-fast-export equivalent
This class will be used by git-remote-hg to do the heavy lifting.
2012-04-06 17:14:12 -05:00
Sverre Rabbelier
7ae2109f76 git-remote-hg: add GitHg, a helper class for converting hg commits to git
This class will be used by HgExport.
2012-04-06 17:14:12 -05:00
Sverre Rabbelier
f75cf8d753 git-remote-hg: add hgimport, an hg-fast-import equivalent
This class will be used by git-remote-hg to do the heavy lifting.
2012-04-06 17:14:12 -05:00
Sverre Rabbelier
654506ab38 git_remote_helpers: add fastimport library 2012-04-06 17:14:12 -05:00
Sverre Rabbelier
70c5519b8f git-remote-testgit: make local a function
Other helpers (such as git-remote-hg) require that 'self.local' is a
function, rather than a variable.
2012-04-06 17:14:12 -05:00
Sverre Rabbelier
701ba60ebf remote-testgit: factor out RemoteHelper class
Facilitate writing import-export based helpers in python by
refactoring common code to a base class.

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-04-06 17:14:12 -05:00
Johannes Schindelin
864dd1be86 Rebasing merge to junio/next (554fe20f)
Previous rebasing merge: d6892ddb40
2012-04-06 16:50:24 -05:00
Sverre Rabbelier
91bff21ed0 remote-helper: check helper status after import/export
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-04-06 16:50:10 -05:00
Sverre Rabbelier
ce0854042b transport-helper: add trailing -- 2012-04-06 16:50:09 -05:00
Sverre Rabbelier
62f33cc14e t5800: point out that deleting branches does not work
This test actually breaks the repositories involved somehow, so it is
not enabled by default.
2012-04-06 16:50:08 -05:00
Sverre Rabbelier
05c850e702 t5800: test pushing a new branch with old content
This works now that fast-export has been fixed to properly handle
refs that point to a commit that was not exported during the current
fast-export run.
2012-04-06 16:50:07 -05:00
Johannes Schindelin
aa1863f305 setup_revisions: remember whether a ref was positive or not
This will be required by fast-export, when no commits were
exported, but the refs should be set, of course.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-04-06 16:49:56 -05:00
Johannes Schindelin
a5bddec59c fast-export: do not export negative refs
When calling `git fast-export master..next` we want to export
refs/heads/next, but not refs/heads/master.

Currently this is not a problem, because negative refs' commits
are never shown. In the next commit this will be changed in order
to make sure that 'master..master' does export master. I.e. even
refs whose commits are not shown are exported.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-04-06 16:49:54 -05:00
Johannes Schindelin
21e75dfc8e setup_revisions: remember whether a ref was positive or not
This will be required by fast-export, when no commits were
exported, but the refs should be set, of course.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-04-06 16:49:53 -05:00
Johannes Schindelin
5c1c7a4867 fast-export: do not refer to non-existing marks
When calling `git fast-export a..a b` when a and b refer to the same
commit, nothing would be exported, and an incorrect reset line would
be printed for b ('from :0').

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-04-06 16:49:52 -05:00
Sverre Rabbelier
6d24bb3c35 t9350: point out that refs are not updated correctly
This happens only when the corresponding commits are not exported in
the current fast-export run. This can happen either when the relevant
commit is already marked, or when the commit is explicitly marked
as UNINTERESTING with a negative ref by another argument.

This breaks fast-export basec remote helpers.

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
2012-04-06 16:49:51 -05:00
Sebastian Schuberth
4fb5d255c8 am: Use cat instead of echo to avoid DOS line-endings (fixes t4150)
Along the lines of 05d0e3b and f33946d, use cat instead of echo to avoid
line ending mismatches in the test result of "am empty-file does not
infloop" which make the test fail.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
2012-04-06 16:49:50 -05:00
Karsten Blees
45b57ae862 Win32: fix detection of empty directories in is_dir_empty
On Windows XP (not Win7), directories cannot be deleted while a find handle
is open, causing "Deletion of directory '...' failed. Should I try again?"
prompts.

Prior to 19d1e75d "Win32: Unicode file name support (except dirent)",
these failures were silently ignored due to strbuf_free in is_dir_empty
resetting GetLastError to ERROR_SUCCESS.

Close the find handle in is_dir_empty so that git doesn't block deletion
of the directory even after all other applications have released it.

Reported-by: John Chen <john0312@gmail.com>
Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:48 -05:00
Karsten Blees
78a40cbaae Win32: patch Windows environment on startup
Fix Windows specific environment settings on startup rather than checking
for special values on every getenv call.

As a side effect, this makes the patched environment (i.e. with properly
initialized TMPDIR and TERM) available to child processes.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:47 -05:00
Karsten Blees
255e00b146 Win32: keep the environment sorted
The Windows environment is sorted, keep it that way for O(log n)
environment access.

Change compareenv to compare only the keys, so that it can be used to
find an entry irrespective of the value.

Change lookupenv to binary seach for an entry. Return one's complement of
the insert position if not found (libc's bsearch returns NULL).

Replace MSVCRT's getenv with a minimal do_getenv based on the binary search
function.

Change do_putenv to insert new entries at the correct position. Simplify
the function by swapping if conditions and using memmove instead of for
loops.

Move qsort from make_environment_block to mingw_startup. We still need to
sort on startup to make sure that the environment is sorted according to
our compareenv function (while Win32 / CreateProcess requires the
environment block to be sorted case-insensitively, CreateProcess currently
doesn't enforce this, and some applications such as bash just don't care).

Note that environment functions are _not_ thread-safe and are not required
to be so by POSIX, the application is responsible for synchronizing access
to the environment. MSVCRT's getenv and our new getenv implementation are
better than that in that they are thread-safe with respect to other getenv
calls as long as the environment is not modified. Git's indiscriminate use
of getenv in background threads currently requires this property.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:46 -05:00
Karsten Blees
7a70420455 Win32: use low-level memory allocation during initialization
As of d41489a6 "Add more large blob test cases", git's high-level memory
allocation functions (xmalloc, xmemdupz etc.) access the environment to
simulate limited memory in tests (see 'getenv("GIT_ALLOC_LIMIT")' in
memory_limit_check()). These functions should not be used before the
environment is fully initialized (particularly not to initialize the
environment itself).

The current solution ('environ = NULL; ALLOC_GROW(environ...)') only works
because MSVCRT's getenv() reinitializes environ when it is NULL (i.e. it
leaves us with two sets of unusabe (non-UTF-8) and unfreeable (CRT-
allocated) environments).

Add our own set of malloc-or-die functions to be used in startup code.

Also check the result of __wgetmainargs, which may fail if there's not
enough memory for wide-char arguments and environment.

This patch is in preparation of the sorted environment feature, which
completely replaces MSVCRT's getenv() implementation.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:42 -05:00
Karsten Blees
1a44adcd0f Win32: reduce environment array reallocations
Move environment array reallocation from do_putenv to the respective
callers. Keep track of the environment size in a global variable. Use
ALLOC_GROW in mingw_putenv to reduce reallocations. Allocate a
sufficiently sized environment array in make_environment_block to prevent
reallocations.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:41 -05:00
Karsten Blees
b2c76b0bc9 Win32: don't copy the environment twice when spawning child processes
When spawning child processes via start_command(), the environment and all
environment entries are copied twice. First by make_augmented_environ /
copy_environ to merge with child_process.env. Then a second time by
make_environment_block to create a sorted environment block string as
required by CreateProcess.

Move the merge logic to make_environment_block so that we only need to copy
the environment once. This changes semantics of the env parameter: it now
expects a delta (such as child_process.env) rather than a full environment.
This is not a problem as the parameter is only used by start_command()
(all other callers previously passed char **environ, and now pass NULL).

The merge logic no longer xstrdup()s the environment strings, so do_putenv
must not free them. Add a parameter to distinguish this from normal putenv.

Remove the now unused make_augmented_environ / free_environ API.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:40 -05:00
Karsten Blees
93c712cdb5 Win32: factor out environment block creation
Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:39 -05:00
Karsten Blees
3f5e24c74b Win32: unify environment function names
Environment helper functions use random naming ('env' prefix or suffix or
both, with or without '_'). Change to POSIX naming scheme ('env' suffix,
no '_').

Env_setenv has more in common with putenv than setenv. Change to do_putenv.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:38 -05:00
Karsten Blees
17bc7bc5f6 Win32: move environment functions
Move environment helper functions up so that they can be reused by
mingw_getenv and mingw_spawnve_fd in subsequent patches.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:36 -05:00
Karsten Blees
5fd9cab8ff Win32: simplify internal mingw_spawn* APIs
The only public spawn function that needs to tweak the environment is
mingw_spawnvpe (called from start_command). Nevertheless, all internal
spawn* functions take an env parameter and needlessly pass the global
char **environ around. Remove the env parameter where it's not needed.

This removes the internal mingw_execve abstraction, which is no longer
needed.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:35 -05:00
Karsten Blees
98bcd7008e Win32: unify environment case-sensitivity
The environment on Windows is case-insensitive. Some environment functions
(such as unsetenv and make_augmented_environ) have always used case-
sensitive comparisons instead, while others (getenv, putenv, sorting in
spawn*) were case-insensitive.

Prevent potential inconsistencies by using case-insensitive comparison in
lookup_env (used by putenv, unsetenv and make_augmented_environ).

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:34 -05:00
Karsten Blees
0839172027 Win32: fix environment memory leaks
All functions that modify the environment have memory leaks.

Disable gitunsetenv in the Makefile and use env_setenv (via mingw_putenv)
instead (this frees removed environment entries).

Move xstrdup from env_setenv to make_augmented_environ, so that
mingw_putenv no longer copies the environment entries (according to POSIX
[1], "the string [...] shall become part of the environment"). This also
fixes the memory leak in gitsetenv, which expects a POSIX compliant putenv.

[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/putenv.html

Note: This patch depends on taking control of char **environ and having
our own mingw_putenv (both introduced in "Win32: Unicode environment
(incoming)").

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:33 -05:00
Karsten Blees
58430e14d6 MinGW: disable legacy encoding tests
On Windows, all native APIs are Unicode-based. It is impossible to pass
legacy encoded byte arrays to a process via command line or environment
variables. Disable the tests that try to do so.

In t3901, most tests still work if we don't mess up the repository encoding
in setup, so don't switch to ISO-8859-1 on MinGW.

Note that i18n tests that do their encoding tricks via encoded files (such
as t3900) are not affected by this.

Signed-off-by: Karsten Blees <blees@dcon.de>
2012-04-06 16:49:31 -05:00