aboutsummaryrefslogtreecommitdiff
path: root/connect.c
Commit message (Collapse)AuthorAge
* Make sure git_connect() always give two file descriptors.Junio C Hamano2007-01-21
| | | | | | | | | | | | | | | | | | | | | | Earlier, git_connect() returned the same fd twice or two separate fds, depending on the way the connection was made (when we are talking to the other end over a single socket, we used the same fd twice, and when our end is connected to a pipepair we used two). This forced callers who do close() and dup() to really care which was which, and most of the existing callers got this wrong, although without much visible ill effect. Many were closing the same fd twice when we are talking over a single socket, and one was leaking a fd. This fixes it to uniformly use two separate fds, so if somebody wants to close only reader side can just do close() on it without worrying about it accidentally also closing the writer side or vice versa. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* simplify inclusion of system header files.Junio C Hamano2006-12-20
| | | | | | | | | | | | | | | | | | | | This is a mechanical clean-up of the way *.c files include system header files. (1) sources under compat/, platform sha-1 implementations, and xdelta code are exempt from the following rules; (2) the first #include must be "git-compat-util.h" or one of our own header file that includes it first (e.g. config.h, builtin.h, pkt-line.h); (3) system headers that are included in "git-compat-util.h" need not be included in individual C source files. (4) "git-compat-util.h" does not have to include subsystem specific header files (e.g. expat.h). Signed-off-by: Junio C Hamano <junkio@cox.net>
* Allow git push to delete remote ref.Junio C Hamano2006-11-24
| | | | | | | | | | | | | This allows you to say git send-pack $URL :refs/heads/$branch to delete the named remote branch. The refspec $src:$dst means replace the destination ref with the object known as $src on the local side, so this is a natural extension to make an empty $src mean "No object" to delete the target. Signed-off-by: Junio C Hamano <junkio@cox.net>
* refs outside refs/{heads,tags} match less strongly.Junio C Hamano2006-11-23
| | | | | | | | | | | | | | | | | | | | | This changes the refname matching logic used to decide which ref is updated with git-send-pack. We used to error out when pushing 'master' when the other end has both 'master' branch and a tracking branch 'remotes/$name/master' but with this, 'master' matches only 'refs/heads/master' when both and no other 'master' exist. Pushing 'foo' when both heads/foo and tags/foo exist at the remote end is still considered an error and you would need to disambiguate between them by being more explicit. When neither heads/foo nor tags/foo exists at the remote, pushing 'foo' when there is only remotes/origin/foo is not ambiguous, while it still is ambiguous when there are more than one such weaker match (remotes/origin/foo and remotes/alt/foo, for example). Signed-off-by: Junio C Hamano <junkio@cox.net>
* connect.c: finish_connect(): allow null pid parameterFranck Bui-Huu2006-09-12
| | | | | | | | | | | | | | git_connect() can return 0 if we use git protocol for example. Users of this function don't know and don't care if a process had been created or not, and to avoid them to check it before calling finish_connect() this patch allows finish_connect() to take a null pid. And in that case return 0. [jc: updated function signature of git_connect() with a comment on its return value. ] Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix a memory leak in "connect.c" and die if command too long.Christian Couder2006-09-10
| | | | | | | | | | | Use "add_to_string" instead of "sq_quote" and "snprintf", so that there is no memory allocation and no memory leak. Also check if the command is too long to fit into the buffer and die if this is the case, instead of truncating it to the buffer size. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* send-pack: remove remote reference limitAndy Whitcroft2006-09-05
| | | | | | | | | | | | | | | | When build a pack for a push we query the remote copy for existant heads. These are used to prune unnecessary objects from the pack. As we receive the remote references in get_remote_heads() we validate the reference names via check_ref() which includes a length check; rejecting those >45 characters in size. This is a miss converted change, it was originally designed to reject messages which were less than 45 characters in length (a 40 character sha1 and refs/) to prevent comparing unitialised memory. check_ref() now gets the raw length so check for at least 5 characters. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Replace uses of strdup with xstrdup.Shawn Pearce2006-09-02
| | | | | | | | | | | | | | | | Like xmalloc and xrealloc xstrdup dies with a useful message if the native strdup() implementation returns NULL rather than a valid pointer. I just tried to use xstrdup in new code and found it to be missing. However I expected it to be present as xmalloc and xrealloc are already commonly used throughout the code. [jc: removed the part that deals with last_XXX, which I am finding more and more dubious these days.] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Convert memcpy(a,b,20) to hashcpy(a,b).Shawn Pearce2006-08-23
| | | | | | | | | | | | | | | | | | | | | | | This abstracts away the size of the hash values when copying them from memory location to memory location, much as the introduction of hashcmp abstracted away hash value comparsion. A few call sites were using char* rather than unsigned char* so I added the cast rather than open hashcpy to be void*. This is a reasonable tradeoff as most call sites already use unsigned char* and the existing hashcmp is also declared to be unsigned char*. [jc: Splitted the patch to "master" part, to be followed by a patch for merge-recursive.c which is not in "master" yet. Fixed the cast in the latter hunk to combine-diff.c which was wrong in the original. Also converted ones left-over in combine-diff.c, diff-lib.c and upload-pack.c ] Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* remove unnecessary initializationsDavid Rientjes2006-08-15
| | | | | | | | [jc: I needed to hand merge the changes to the updated codebase, so the result needs to be checked.] Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* finish_connect(): thinkofixJunio C Hamano2006-08-15
| | | | | | | | | | | | | All but one callers have ignore the return value from this function, but the only caller, builtin-tar-tree.c::remote_tar(), assumed it returns non-zero on failure and zero on success. The implementation however was returning either the waited pid (which must be the same as its input) or -1 (an error). Fix this thinko, while getting rid of an assignment of return value from waitpid() into a variable of type int. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Improve git-peek-remoteLinus Torvalds2006-07-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes git-peek-remote able to basically do everything that git-ls-remote does (but obviously just for the native protocol, so no http[s]: or rsync: support). The default behaviour is the same, but you can now give a mixture of "--refs", "--tags" and "--heads" flags, where "--refs" forces git-peek-remote to only show real refs (ie none of the fakey tag lookups, but also not the special pseudo-refs like HEAD and MERGE_HEAD). The "--tags" and "--heads" flags respectively limit the output to just regular tags and heads, of course. You can still also ask to limit them by name too. You can combine the flags, so git peek-remote --refs --tags . will show all local _true_ tags, without the generated tag lookups (compare the output without the "--refs" flag). And "--tags --heads" will show both tags and heads, but will avoid (for example) any special refs outside of the standard locations. I'm also planning on adding a "--ignore-local" flag that allows us to ask it to ignore any refs that we already have in the local tree, but that's an independent thing. All this is obviously gearing up to making "git fetch" cheaper. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix errno usage in connect.cPetr Baudis2006-07-01
| | | | | | | | errno was used after it could've been modified by a subsequent library call. Spotted by Morten Welinder. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
* connect.c: remove unused parameters from tcp_connect and proxy_connectJunio C Hamano2006-06-28
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* Make some strings constTimo Hirvonen2006-06-28
| | | | | Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Solaris needs inclusion of signal.h for signal()Dennis Stosberg2006-06-26
| | | | | | Currently the compilation fails in connect.c and merge-index.c Signed-off-by: Junio C Hamano <junkio@cox.net>
* Restore SIGCHLD to SIG_DFL where we care about waitpid().Junio C Hamano2006-06-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | It was reported that under one implementation of socks client "git clone" fails with "error: waitpid failed (No child processes)", because "git" is spawned after setting SIGCHLD to SIG_IGN. Arguably it may be a broken setting, but we should protect ourselves so that we can get reliable results from waitpid() for the children we care about. This patch resets SIGCHLD to SIG_DFL in three places: - connect.c::git_connect() - initiators of git native protocol transfer are covered with this. - daemon.c::main() - obviously. - merge-index.c::main() - obviously. There are other programs that do fork() but do not waitpid(): http-push, imap-send. upload-pack does not either, but in the case of that program, each of the forked halves runs exec() another program, so this change would not have much effect there. Signed-off-by: Junio C Hamano <junkio@cox.net>
* check for error return from fork()Paul T Darga2006-06-08
| | | | | | | Trivial fixup for fork() callsites which do not check for errors. Signed-off-by: Paul T Darga <pdarga@umich.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Refactor git_tcp_connect() functions a little.Jon Loeliger2006-06-06
| | | | | | | | Add client side sending of "\0host=%s\0" extended arg for git native protocol, backwards compatibly. Signed-off-by: Jon Loeliger <jdl@jdl.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* fetch-pack: output refs in the order they were given on the command line.Junio C Hamano2006-05-22
| | | | | | | | | | | Currently, fetched refs are output in the order the remote side happened to send them. This changes the order to match the order of refs that were given on the command line. To the existing core callers (git-fetch and git-clone) this does not make any difference, but for other Porcelain use, it would be more intuitive. Signed-off-by: Junio C Hamano <junkio@cox.net>
* cleanups: Fix potential bugs in connect.cSerge E. Hallyn2006-04-17
| | | | | | | | | | | The strncmp for ACK was ACK does not include the final space. Presumably either we should either remove the trailing space, or compare 4 chars (as this patch does). 'path' is sometimes strdup'ed, but never freed. Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Add compat/unsetenv.c .Jason Riedy2006-01-25
| | | | | | | Implement a (slow) unsetenv() for older systems. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
* local push/pull env cleanupMatt Draisey2006-01-25
| | | | | | | | | | | remove environment variables relating to the current repository before execing the 'remote' half of a local push or pull operation [jc: the original from Matt spelled out the environment variable names, which I changed to the preprocessor symbols defined in cache.h. Also it missed GRAFT_ENVIRONMENT.] Signed-off-by: Junio C Hamano <junkio@cox.net>
* send-pack/receive-pack: allow errors to be reported back to pusher.Junio C Hamano2005-12-27
| | | | | | | | | | | This updates the protocol between git-send-pack/git-receive-pack in a backward compatible way to allow failures at the receiving end to be propagated back to the sender. Most notably, versions of git-push before this could not notice if the update hook on the receiving end refused to update the ref for its own policy reasons. Signed-off-by: Junio C Hamano <junkio@cox.net>
* GIT: Support [address] in URLsYOSHIFUJI Hideaki / 吉藤英明2005-12-21
| | | | | | | | | | Allow IPv6address/IPvFuture enclosed by [] in URLs, like: git push '[3ffe:ffff:...:1]:GIT/git' or git push 'ssh://[3ffe:ffff:...:1]/GIT/git' Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fixed git:// IPv4 address problem when compiled with -DNO_IPV6.Paul Serice2005-11-22
| | | | | | | | | | | | Failure to dereference a pointer caused incorrect initialization of the IPv4 address when calling connect() when compiled with -DNO_IPV6. With this patch and yesterday's patch for git-daemon, it should now be possible to use the native git protocol for both the client and server on Cygwin. Signed-off-by: Paul Serice <paul@serice.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
* GIT: Fix compilation error in connect.cYOSHIFUJI Hideaki / 吉藤英明2005-11-21
| | | | | | | Fix compilation error for gcc-2.95. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-proxy updates.Junio C Hamano2005-11-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This builds on top of the git-proxy mechanism Paul Collins did, and updates its configuration mechanism. * GIT_PROXY_COMMAND environment variable is used as the catch-all fallback, as in the original. This has not changed. * Renames proxy configuration variables to core.gitproxy; this has become a multi-value variable per list discussion, most notably from suggestion by Linus. [core] ;# matches www.kernel.org as well gitproxy = netcatter for kernel.org gitproxy = netscatter for sample.xz gitproxy = none for mydomain.xz gitproxy = netcatter-default The values are command names, followed by an optional " for " and domainname; the first tail-match of the domainname determines which proxy command is used. An entry without " for " matches any domain and can be used as the default. The command name "none" is special -- it tells the mechanism not to use any proxy command and use the native git:// connection. Signed-off-by: Junio C Hamano <junkio@cox.net>
* proxy-command support for git://Paul Collins2005-11-21
| | | | | | | | | | | | | | | | | | Here is an updated patch that first looks for GIT_PROXY_COMMAND in the environment and then git.proxycommand in the repository's configuration file. I have left the calling convention the same argv[1] is the host and argv[2] is the port. I've taken the hostname parsing verbatim from git_tcp_connect(), so it should now support an explicit port number and whatever that business with the square brackets is. (Should I move this to a helper function?) Regarding internal vs. external hosts, the proxy command can simply run netcat locally to internal hosts, so perhaps that is sufficient. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Client side support for user-relative paths.Andreas Ericsson2005-11-19
| | | | | | | | | With this patch, the client side passes identical paths for these two: ssh://host.xz/~junio/repo host.xz:~junio/repo Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Junio C Hamano <junkio@cox.net>
* fix multi_ack.Johannes Schindelin2005-10-28
| | | | | Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-fetch-pack: Support multi_ack extensionJohannes Schindelin2005-10-28
| | | | | | | The client side support for multi_ack. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Support receiving server capabilitiesJohannes Schindelin2005-10-28
| | | | | | | | | | | | | | | | | | This patch implements the client side of backward compatible upload-pack protocol extension, <20051027141619.0e8029f2.vsu@altlinux.ru> by Sergey. The updated server can append "server_capabilities" which is supposed to be a string containing space separated features of the server, after one of elements in the initial list of SHA1-refname line, hidden with an embedded NUL. After get_remote_heads(), check if the server supports the feature like if (server_supports("multi_ack")) do_something(); Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Revert recent fetch-pack/upload-pack updates.Junio C Hamano2005-10-25
| | | | | | | Let's have it simmer a bit longer in the proposed updates branch and shake the problems out. Signed-off-by: Junio C Hamano <junkio@cox.net>
* git-fetch-pack: Implement client part of the multi_ack extensionJohannes Schindelin2005-10-24
| | | | | | | | | | This patch concludes the series, which makes git-fetch-pack/git-upload-pack negotiate a potentially better set of common revs. It should make a difference when fetching from a repository with a few branches. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Squelch compiler warnings from connect.cJunio C Hamano2005-10-16
| | | | | | Forgot to include necessary header file to get the function declaration. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Ignore funny refname sent from remoteJunio C Hamano2005-10-15
| | | | | | | | | This allows the remote side (most notably, upload-pack) to show additional information without affecting the downloader. Peek-remote does not ignore them -- this is to make it useful for Pasky's automatic tag following. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Support git+ssh:// and ssh+git:// URLLinus Torvalds2005-10-14
| | | | | | | | | | | It seemed to be such a stupid syntax. It's both what "ssh://" means, and it's what not specifying a protocol at _all_ means. But hey, since we already have two ways of saying "use ssh with pack-files", here's two more. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* NO_IPV6 support for git daemonPeter Anvin2005-09-28
|
* Call it NO_IPV6 rather than hard-coding __CYGWIN__hpa2005-09-28
|
* Cygwin doesn't support IPv6 or getaddrinfo()hpa2005-09-28
|
* Merge refs/heads/portable from http://www.cs.berkeley.edu/~ejr/gits/git.git Junio C Hamano2005-08-28
|\
| * Fix ?: statements.Jason Riedy2005-08-23
| | | | | | | | | | | | | | | | | | Omitting the first branch in ?: is a GNU extension. Cute, but not supported by other compilers. Replaced mostly by explicit tests. Calls to getenv() simply are repeated on non-GNU compilers. Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
* | Support +<src>:<dst> format in push as well.Junio C Hamano2005-08-24
|/ | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* Use GIT_SSH environment to specify alternate ssh binary.Martin Sivak2005-08-09
| | | | | | | | | [jc: I ended up rewriting Martin's patch due to whitespace breakage, but the credit goes to Martin for doing the initial patch to identify what needs to be changed.] Signed-off-by: Martin Sivak <mars@nomi.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] -Werror fixesTimo Sirainen2005-08-09
| | | | | | GCC's format __attribute__ is good for checking errors, especially with -Wformat=2 parameter. This fixes most of the reported problems against 2005-08-09 snapshot.
* send-pack: allow generic sha1 expression on the source side.Junio C Hamano2005-08-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This extends the source side semantics to match what Linus suggested. An example: $ git-send-pack kernel.org:/pub/scm/git/git.git pu^^:master pu would allow me to push the current pu into pu, and the commit two commits before it into master, on my public repository. The revised rule for updating remote heads is as follows. $ git-send-pack [--all] <remote> [<ref>...] - When no <ref> is specified: - with '--all', it is the same as specifying the full refs/* path for all local refs; - without '--all', it is the same as specifying the full refs/* path for refs that exist on both ends; - When one or more <ref>s are specified: - a single token <ref> (i.e. no colon) must be a pattern that tail-matches refs/* path for an existing local ref. It is an error for the pattern to match no local ref, or more than one local refs. The matching ref is pushed to the remote end under the same name. - <src>:<dst> can have different cases. <src> is first tried as the tail-matching pattern for refs/* path. - If more than one matches are found, it is an error. - If one match is found, <dst> must either match no remote ref and start with "refs/", or match exactly one remote ref. That remote ref is updated with the sha1 value obtained from the <src> sha1. - If no match is found, it is given to get_extended_sha1(); it is an error if get_extended_sha1() does not find an object name. If it succeeds, <dst> must either match no remote ref and start with "refs/" or match exactly one remote ref. That remote ref is updated with the sha1 value. Signed-off-by: Junio C Hamano <junkio@cox.net>
* send-pack: allow the same source to be pushed more than once.Junio C Hamano2005-08-06
| | | | | | | | The revised code accidentally inherited the restriction that a reference can be pushed only once, only because the original did not allow renaming. This is no longer necessary so lift it. Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix refname termination.Junio C Hamano2005-08-05
| | | | | | | When a new ref is being pushed, the name of it was not terminated properly. Signed-off-by: Junio C Hamano <junkio@cox.net>
* [PATCH] Fix sparse warningsAlecs King2005-08-03
| | | | | | | | fix one 'should it be static?' warning and two 'mixing declarations and code' warnings. Signed-off-by: Alecs King <alecsk@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>