summaryrefslogtreecommitdiff
path: root/http-push.c
AgeCommit message (Collapse)Author
2009-06-06http*: add http_get_info_packsTay Ray Chuan
http-push.c and http-walker.c no longer have to use fetch_index or setup_index; they simply need to use http_get_info_packs, a new http method, in their fetch_indices implementations. Move fetch_index() and rename to fetch_pack_index() in http.c; this method is not meant to be used outside of http.c. It invokes end_url_with_slash with base_url; apart from that change, the code is identical. Move setup_index() and rename to fetch_and_setup_pack_index() in http.c; this method is not meant to be used outside of http.c. Do not immediately set ret to 0 in http-walker.c::fetch_indices(); instead do it in the HTTP_MISSING_TARGET case, to make it clear that the HTTP_OK and HTTP_MISSING_TARGET cases both return 0. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06http-push.c::fetch_symref(): use the new http APIMike Hommey
Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06http-push.c::remote_exists(): use the new http APIMike Hommey
Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06http*: move common variables and macros to http.[ch]Tay Ray Chuan
Move RANGE_HEADER_SIZE to http.h. Create no_pragma_header, the curl header list containing the header "Pragma:" in http.[ch]. It is allocated in http_init, and freed in http_cleanup. This replaces the no_pragma_header in http-push.c, and the no_pragma_header member in walker_data in http-walker.c. Create http_is_verbose. It is to be used by methods in http.c, and is modified at the entry points of http.c's users, namely http-push.c (when parsing options) and http-walker.c (in get_http_walker). Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06http-push: do not SEGV after fetching a bad pack idx fileTay Ray Chuan
In a70c232 ("http-fetch: do not SEGV after fetching a bad pack idx file"), changes were made to the setup_index method in http-fetch.c (known in its present form as http-walker.c after 30ae764 ("Modularize commit-walker")). Since http-push.c has similar similar code for processing index files, these changes should apply to http-push.c's implementation of setup_index as well. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06http*: copy string returned by sha1_to_hexTay Ray Chuan
In the fetch_index implementations in http-push.c and http-walker.c, the string returned by sha1_to_hex is assumed to stay immutable. This patch ensures that hex stays immutable by copying the string returned by sha1_to_hex (via xstrdup) and frees it subsequently. It also refactors free()'s and fclose()'s with labels. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06http-push, http-walker: style fixesTay Ray Chuan
- Use tabs to indent, instead of spaces. - Do not use curly-braces around a single statement body in if/while statement; - Do not start multi-line comment with description on the first line after "/*", i.e. /* * We prefer this over... */ /* comments like * this (notice the first line) */ Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06http-push: fix missing "#ifdef USE_CURL_MULTI" around "is_running_queue"Tay Ray Chuan
As it is breaking the build when USE_CURL_MULTI is not defined. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06http-push: send out fetch requests on queueTay Ray Chuan
Previously, requests for remote files were simply added to the queue (pointed to by request_queue_head) and no transfer actually takes place (the fill function add_fill_function() is not added until line 2441), even though code that followed may rely on these remote files to be present (eg. the setup_revisions invocation). The code that sends out the requests on the request queue is refactored into the method run_request_queue. After the get_dav_remote_heads invocation (ie. after fetch requests are added to the queue), the requests on the queue are sent out through an invocation to run_request_queue. This invocation to run_request_queue entails adding a fill function before pushing checks take place, which may lead to accidental, unwanted pushes previously. The flag is_running_queue is introduced to prevent this from occurring. fill_active_slot is made to check the flag is_running_queue before the sending of the requests proceeds. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-06Merge branch 'rc/maint-http-local-slot-fix' into rc/http-pushJunio C Hamano
* rc/maint-http-local-slot-fix: http*: cleanup slot->local after fclose
2009-06-06http*: cleanup slot->local after fcloseTay Ray Chuan
Set slot->local to NULL after doing a fclose() on the file it points to. This prevents the passing of a FILE* pointer to a fclose()'d file to ftell() in http.c::run_active_slot(). This issue was raised by Clemens Buchacher on 30th May 2009: http://www.spinics.net/lists/git/msg104623.html Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-02match_refs: search ref list tail internallyClemens Buchacher
Avoid code duplication by moving list tail search to match_refs(). This does not change the semantics, except for http-push, which now inserts to the front of the ref list in order to get rid of the global remote_tail. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-31http-push: reuse existing is_null_refClemens Buchacher
Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-26Merge branch 'ar/unlink-err' into maintJunio C Hamano
* ar/unlink-err: print unlink(2) errno in copy_or_link_directory replace direct calls to unlink(2) with unlink_or_warn Introduce an unlink(2) wrapper which gives warning if unlink failed
2009-05-24Merge branch 'maint'Junio C Hamano
* maint: http-push.c::remove_locks(): fix use after free
2009-05-24Merge branch 'maint-1.6.2' into maintJunio C Hamano
* maint-1.6.2: http-push.c::remove_locks(): fix use after free
2009-05-24Merge branch 'maint-1.6.1' into maint-1.6.2Junio C Hamano
* maint-1.6.1: http-push.c::remove_locks(): fix use after free
2009-05-24Merge branch 'maint-1.6.0' into maint-1.6.1Junio C Hamano
* maint-1.6.0: http-push.c::remove_locks(): fix use after free
2009-05-24http-push.c::remove_locks(): fix use after freeAlex Riesen
Noticed and reported by Serhat Şevki Dinçer. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Acked-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-05-21Terminate argv with NULL before calling setup_revisions()Nguyễn Thái Ngọc Duy
It is convention that argv should be terminated with NULL, even if argc is used to specify the size of argv. setup_revisions() requires this and may segfault otherwise. This patch makes sure that all argv (that I can find) is NULL terminated. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-30replace direct calls to unlink(2) with unlink_or_warnAlex Riesen
This helps to notice when something's going wrong, especially on systems which lock open files. I used the following criteria when selecting the code for replacement: - it was already printing a warning for the unlink failures - it is in a function which already printing something or is called from such a function - it is in a static function, returning void and the function is only called from a builtin main function (cmd_) - it is in a function which handles emergency exit (signal handlers) - it is in a function which is obvously cleaning up the lockfiles Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-12Replace ",<,>,& with their respective XML entities in DAV requestsMike Hommey
If the repo url or the user email contain XML special characters, the remote DAV server is likely to reject the LOCK requests because the XML is then malformed. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-08Merge branch 'ms/http-auth'Junio C Hamano
* ms/http-auth: Allow curl to rewind the read buffers
2009-04-06Merge branch 'jc/shared-literally'Junio C Hamano
* jc/shared-literally: t1301: loosen test for forced modes set_shared_perm(): sometimes we know what the final mode bits should look like move_temp_to_file(): do not forget to chmod() in "Coda hack" codepath Move chmod(foo, 0444) into move_temp_to_file() "core.sharedrepository = 0mode" should set, not loosen
2009-04-02Allow curl to rewind the read buffersMartin Storsjö
When using multi-pass authentication methods, the curl library may need to rewind the read buffers (depending on how much already has been fed to the server) used for providing data to HTTP PUT, POST or PROPFIND, and in order to allow the library to do so, we need to tell it how by providing either an ioctl callback or a seek callback. This patch adds an ioctl callback, which should be usable on older curl versions (since 7.12.3) than the seek callback (introduced in curl 7.18.0). Some HTTP servers (such as Apache) give an 401 error reply immediately after receiving the headers (so no data has been read from the read buffers, and thus no rewinding is needed), but other servers (such as Lighttpd) only replies after the whole request has been sent and all data has been read from the read buffers, making rewinding necessary. Signed-off-by: Martin Storsjo <martin@martin.st> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-28Move chmod(foo, 0444) into move_temp_to_file()Johan Herland
When writing out a loose object or a pack (index), move_temp_to_file() is called to finalize the resulting file. These files (loose files and packs) should all have permission mode 0444 (modulo adjust_shared_perm()). Therefore, instead of doing chmod(foo, 0444) explicitly from each callsite (or even forgetting to chmod() at all), do the chmod() call from within move_temp_to_file(). Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-26Merge branch 'mg/http-auth'Junio C Hamano
* mg/http-auth: http-push.c: use a faux remote to pass to http_init Do not name "repo" struct "remote" in push_http.c http.c: CURLOPT_NETRC_OPTIONAL is not available in ancient versions of cURL http authentication via prompts http_init(): Fix config file parsing http.c: style cleanups Conflicts: http-push.c
2009-03-24http-push: using error() and warning() as appropriateMiklos Vajna
Change three occurences of using inconsistent error/warning reporting by using the relevant error() / warning() calls to be consitent with the rest of the code. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-19http-push.c: use a faux remote to pass to http_initAmos King
This patch allows http_push to use http authentication via prompts. You may notice that there is a remote struct that only contains the url from the repo struct. This struct is a temporary fix for a larger issue, but gets http authentication via prompts out the door, and keeps users from having to store passwords in plain text files. Signed-off-by: Amos King <amos.l.king@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-19Do not name "repo" struct "remote" in push_http.cAmos King
This patch is a first step in getting http-push to use http authentication via prompts. The patch renames remote to repo so that it doesn't get confusing with the same remote that is passed around when using http. Signed-off-by: Amos King <amos.l.king@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-18Merge branch 'js/remote-improvements'Junio C Hamano
* js/remote-improvements: (23 commits) builtin-remote.c: no "commented out" code, please builtin-remote: new show output style for push refspecs builtin-remote: new show output style remote: make guess_remote_head() use exact HEAD lookup if it is available builtin-remote: add set-head subcommand builtin-remote: teach show to display remote HEAD builtin-remote: fix two inconsistencies in the output of "show <remote>" builtin-remote: make get_remote_ref_states() always populate states.tracked builtin-remote: rename variables and eliminate redundant function call builtin-remote: remove unused code in get_ref_states builtin-remote: refactor duplicated cleanup code string-list: new for_each_string_list() function remote: make match_refs() not short-circuit remote: make match_refs() copy src ref before assigning to peer_ref remote: let guess_remote_head() optionally return all matches remote: make copy_ref() perform a deep copy remote: simplify guess_remote_head() move locate_head() to remote.c move duplicated ref_newer() to remote.c move duplicated get_local_heads() to remote.c ... Conflicts: builtin-clone.c
2009-03-16Fix various dead stores found by the clang static analyzerBenjamin Kramer
http-push.c::finish_request(): request is initialized by the for loop index-pack.c::free_base_data(): b is initialized by the for loop merge-recursive.c::process_renames(): move compare to narrower scope, and remove unused assignments to it remove unused variable renames2 xdiff/xdiffi.c::xdl_recs_cmp(): remove unused variable ec xdiff/xemit.c::xdl_emit_diff(): xche is always overwritten Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-26move duplicated ref_newer() to remote.cJay Soffian
ref_newer() appears to have been copied from builtin-send-pack.c to http-push.c via cut and paste. This patch moves the function and its helper unmark_and_free() to remote.c. There was a slight difference between the two implementations, one used TMP_MARK for the mark, the other used 1. Per Jeff King, I went with TMP_MARK as more correct. This is in preparation for being able to call it from builtin-remote.c Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-26move duplicated get_local_heads() to remote.cJay Soffian
get_local_heads() appears to have been copied from builtin-send-pack.c to http-push.c via cut and paste. This patch moves the function and its helper one_local_ref() to remote.c. The two copies of one_local_ref() were not identical. I used the more recent version from builtin-send-pack.c after confirming with Jeff King that it was an oversight that commit 30affa1e did not update both copies. This is in preparation for being able to call it from builtin-remote.c Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-15Merge branch 'rc/http-push'Junio C Hamano
* rc/http-push: use a hash of the lock token as the suffix for PUT/MOVE
2009-02-15use a hash of the lock token as the suffix for PUT/MOVETay Ray Chuan
After 753bc91 ("Remove the requirement opaquelocktoken uri scheme"), lock tokens are in the URI forms in which they are received from the server, eg. 'opaquelocktoken:', 'urn:uuid:'. However, "start_put" (and consequently "start_move"), which attempts to create a unique temporary file using the UUID of the lock token, inadvertently uses the lock token in its URI form. These file operations on the server may not be successful (specifically, in Windows), due to the colon ':' character from the URI form of the lock token in the file path. This patch uses a hash of the lock token instead, guaranteeing only "safe" characters (a-f, 0-9) are used in the file path. The token's hash is generated when the lock token is received from the server in handle_new_lock_ctx, minimizing the number of times of hashing. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-06Merge branch 'rc/http-push'Junio C Hamano
* rc/http-push: http-push: wrap signature of get_remote_object_url http-push: add back underscore separator before lock token http-push.c: get_remote_object_url() is only used under USE_CURL_MULTI http-push: refactor request url creation
2009-02-06Merge branch 'lt/maint-wrap-zlib' into maintJunio C Hamano
* lt/maint-wrap-zlib: Wrap inflate and other zlib routines for better error reporting Conflicts: http-push.c http-walker.c sha1_file.c
2009-02-04http-push: wrap signature of get_remote_object_urlTay Ray Chuan
The signature of get_remote_object_url stands at 96 characters (as pointed out by Dscho); this patch wraps it so that it conforms to the 80 characters guideline. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-04http-push: add back underscore separator before lock tokenTay Ray Chuan
817d14a (http-push: refactor request url creation, 2009-01-31) removed the underscore separator between the object path and the appended lock token. This patch adds it back. This would be keeping in line with the aforementioned patch's objective of refactoring, without changing the behaviour and effect, of the code. This would also be useful for testing if the lock token has been indeed appended to the object url. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-03http-push.c: get_remote_object_url() is only used under USE_CURL_MULTIJunio C Hamano
Otherwise -Wunused-function (which is implied by -Wall) triggers. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-02-01Merge branch 'sp/runtime-prefix'Junio C Hamano
* sp/runtime-prefix: Windows: Revert to default paths and convert them by RUNTIME_PREFIX Compute prefix at runtime if RUNTIME_PREFIX is set Modify setup_path() to only add git_exec_path() to PATH Add calls to git_extract_argv0_path() in programs that call git_config_* git_extract_argv0_path(): Move check for valid argv0 from caller to callee Refactor git_set_argv0_path() to git_extract_argv0_path() Move computation of absolute paths from Makefile to runtime (in preparation for RUNTIME_PREFIX)
2009-02-01Merge branch 'jk/signal-cleanup'Junio C Hamano
* jk/signal-cleanup: t0005: use SIGTERM for sigchain test pager: do wait_for_pager on signal death refactor signal handling for cleanup functions chain kill signals for cleanup functions diff: refactor tempfile cleanup handling Windows: Fix signal numbers
2009-02-01http-push: refactor request url creationTay Ray Chuan
Introduce two helper functions append_remote_object_url() and get_remote_object_url() and use them to remove various places that allocate and format the URL by hand. These functions generate a URL that point at the fan-out directory inside the remote object store (e.g. http://host/path/to/repo/objects/a1/) or at an individual loose object file. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-26Add calls to git_extract_argv0_path() in programs that call git_config_*Steffen Prohaska
Programs that use git_config need to find the global configuration. When runtime prefix computation is enabled, this requires that git_extract_argv0_path() is called early in the program's main(). This commit adds the necessary calls. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-25http-push.c: style fixesJunio C Hamano
b1c7d4a (http-push: refactor lock-related headers creation for curl requests, 2009-01-24) had many style violations that slipped through. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-24http-push: refactor lock-related headers creation for curl requestsRay Chuan
DAV-related headers (more specifically, headers related to the lock token, namely, If, Lock-Token, and Timeout) for curl requests are created and allocated individually, eg a "if_header" variable for the "If: " header, a "timeout_header" variable for the "Timeout: " header. This patch provides a new function ("get_dav_token_headers") that creates these header, saving methods from allocating memory, and from issuing a "curl_slist_append()" call. The temporary string storage given to curl_slist_append() is freed much earlier than the previous code with this patch, but this change is safe, because curl_slist_append() keeps a copy of the given string. In part, this patch also addresses the fact that commit 753bc91 (Remove the requirement opaquelocktoken uri scheme) did not update memory allocations for DAV-related headers. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-22refactor signal handling for cleanup functionsJeff King
The current code is very inconsistent about which signals are caught for doing cleanup of temporary files and lock files. Some callsites checked only SIGINT, while others checked a variety of death-dealing signals. This patch factors out those signals to a single function, and then calls it everywhere. For some sites, that means this is a simple clean up. For others, it is an improvement in that they will now properly clean themselves up after a larger variety of signals. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-22chain kill signals for cleanup functionsJeff King
If a piece of code wanted to do some cleanup before exiting (e.g., cleaning up a lockfile or a tempfile), our usual strategy was to install a signal handler that did something like this: do_cleanup(); /* actual work */ signal(signo, SIG_DFL); /* restore previous behavior */ raise(signo); /* deliver signal, killing ourselves */ For a single handler, this works fine. However, if we want to clean up two _different_ things, we run into a problem. The most recently installed handler will run, but when it removes itself as a handler, it doesn't put back the first handler. This patch introduces sigchain, a tiny library for handling a stack of signal handlers. You sigchain_push each handler, and use sigchain_pop to restore whoever was before you in the stack. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-01-22Merge branch 'lt/maint-wrap-zlib'Junio C Hamano
* lt/maint-wrap-zlib: Wrap inflate and other zlib routines for better error reporting Conflicts: http-push.c http-walker.c sha1_file.c