aboutsummaryrefslogtreecommitdiff
path: root/http-push.c
Commit message (Collapse)AuthorAge
* http-push.c: remove duplicated codeJunio C Hamano2008-06-08
| | | | | | | | | | | | | | | | An earlier commit aa1dbc9 (Update http-push functionality, 2006-03-07) borrowed some code from rev-list.c. This copy and paste made sense back then, because mark_edges_uninteresting(), and its helper mark_edge_parents_uninteresting(), accessed a file scope static variable "revs" in rev-list.c, and http-push.c did not have nor care about such a variable. But these days they are already properly libified and live in list-objects.c and they take "revs" as as an argument. Make use of them and lose 20 or so lines. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* rollback lock files on more signals than just SIGINTPaolo Bonzini2008-05-31
| | | | | | | | | Other signals are also common, for example SIGTERM and SIGHUP. This patch modifies the lock file mechanism to catch more signals. It also modifies http-push.c which was missing SIGTERM. Signed-off-by: Paolo Bonzini <bonzini@gnu.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* http-push: remove remote locks on exit signalsClemens Buchacher2008-05-25
| | | | | | | If locks are not cleaned up the repository is inaccessible for 10 minutes. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* alloc_ref_from_str(): factor out a common pattern of alloc_ref from stringKrzysztof Kowalczyk2008-05-11
| | | | | | | Also fix an underallocation in walker.c::interpret_target(). Signed-off-by: Krzysztof Kowalczyk <kkowalczyk@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make walker.fetch_ref() take a struct ref.Daniel Barkalow2008-04-26
| | | | | | | | | | | | | | | | This simplifies a few things, makes a few things slightly more complicated, but, more importantly, allows that, when struct ref can represent a symref, http_fetch_ref() can return one. Incidentally makes the string that http_fetch_ref() gets include "refs/" (if appropriate), because that's how the name field of struct ref works. As far as I can tell, the usage in walker:interpret_target() wouldn't have worked previously, if it ever would have been used, which it wouldn't (since the fetch process uses the hash instead of the name of the ref there). Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'mh/maint-http-proxy-fix'Junio C Hamano2008-03-02
|\ | | | | | | | | * mh/maint-http-proxy-fix: Set proxy override with http_init()
| * Set proxy override with http_init()Mike Hommey2008-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In transport.c, proxy setting (the one from the remote conf) was set through curl_easy_setopt() call, while http.c already does the same with the http.proxy setting. We now just use this infrastructure instead, and make http_init() now take the struct remote as argument so that it can take the http_proxy setting from there, and any other property that would be added later. At the same time, we make get_http_walker() take a struct remote argument too, and pass it to http_init(), which makes remote defined proxy be used for more than get_refs_via_curl(). We leave out http-fetch and http-push, which don't use remotes for the moment, purposefully. Signed-off-by: Mike Hommey <mh@glandium.org> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'cb/http-test'Junio C Hamano2008-03-02
|\ \ | | | | | | | | | | | | | | | * cb/http-test: http-push: add regression tests http-push: push <remote> :<branch> deletes remote branch
| * | http-push: push <remote> :<branch> deletes remote branchClemens Buchacher2008-02-27
| | | | | | | | | | | | | | | | | | | | | This mirrors current ssh/git push syntax. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Avoid unnecessary "if-before-free" tests.Jim Meyering2008-02-22
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change removes all obvious useless if-before-free tests. E.g., it replaces code like this: if (some_expression) free (some_expression); with the now-equivalent: free (some_expression); It is equivalent not just because POSIX has required free(NULL) to work for a long time, but simply because it has worked for so long that no reasonable porting target fails the test. Here's some evidence from nearly 1.5 years ago: http://www.winehq.org/pipermail/wine-patches/2006-October/031544.html FYI, the change below was prepared by running the following: git ls-files -z | xargs -0 \ perl -0x3b -pi -e \ 's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+(free\s*\(\s*\1\s*\))/$2/s' Note however, that it doesn't handle brace-enclosed blocks like "if (x) { free (x); }". But that's ok, since there were none like that in git sources. Beware: if you do use the above snippet, note that it can produce syntactically invalid C code. That happens when the affected "if"-statement has a matching "else". E.g., it would transform this if (x) free (x); else foo (); into this: free (x); else foo (); There were none of those here, either. If you're interested in automating detection of the useless tests, you might like the useless-if-before-free script in gnulib: [it *does* detect brace-enclosed free statements, and has a --name=S option to make it detect free-like functions with different names] http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=build-aux/useless-if-before-free Addendum: Remove one more (in imap-send.c), spotted by Jean-Luc Herren <jlh@gmx.ch>. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'js/maint-http-push'Junio C Hamano2008-02-20
|\ \ | | | | | | | | | | | | | | | | | | * js/maint-http-push: http-push: avoid a needless goto http-push: do not get confused by submodules http-push: avoid invalid memory accesses
| * | http-push: avoid a needless gotoJohannes Schindelin2008-02-15
| | | | | | | | | | | | | | | | | | | | | | | | There was a goto, and while it is not half as harmful as some people believe, it was unnecessary here. So remove it for readability. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | http-push: do not get confused by submodulesJohannes Schindelin2008-02-15
| | | | | | | | | | | | | | | | | | | | | | | | When encountering submodules in a tree, http-push should not try sending the respective object. Instead, it should ignore it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | http-push: avoid invalid memory accessesJohannes Schindelin2008-02-15
| |/ | | | | | | | | | | | | | | | | | | Before objects are sent, the respective ref is locked. However, without this patch, the lock is lifted before the last object for that ref was sent. As a consequence, the lock data was accessed after the lock structure was free()d. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | check return code of prepare_revision_walkMartin Koegler2008-02-17
|/ | | | | | | | A failure in prepare_revision_walk can be caused by a not parseable object. Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* http-push and http-fetch: handle URLs without trailing /Grégoire Barbier2008-01-20
| | | | | | | | The URL to a repository http-push and http-fetch takes should have a trailing slash. Instead of failing the request, add it ourselves before attempting such a request. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* http-push: clarify the reason of error from the initial PROPFIND requestJunio C Hamano2008-01-20
| | | | | | | | | | | | | | | | | | The first thing http-push does is a PROPFIND to see if the other end supports locking. The failure message we give is always reported as "no DAV locking support at the remote repository", regardless of the reason why we ended up not finding the locking support on the other end. This moves the code to report "no DAV locking support" down the codepath so that the message is issued only when we successfully get a response to PROPFIND and the other end say it does not support locking. Other failures, such as connectivity glitches and credential mismatches, have their own error message issued and we will not issue "no DAV locking" error (we do not even know if the remote end supports it). Signed-off-by: Junio C Hamano <gitster@pobox.com>
* http-push: fail when info/refs exists and is already lockedGrégoire Barbier2008-01-20
| | | | | | | | | | | | | | Failing instead of silently not updating remote refs makes the things clearer for the user when trying to push on a repository while another person do (or while a dandling locks are waiting for a 10 minutes timeout). When silently not updating remote refs, the user does not even know that git has pushed the objects but leaved the refs as they were before (e.g. a new bunch of commits on branch "master" is uploaded, however the branch by itsel still points on the previous head commit). Signed-off-by: Junio C Hamano <gitster@pobox.com>
* http-push: fix webdav lock leak.Grégoire Barbier2008-01-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Releasing webdav lock even if push fails because of bad (or no) reference on command line. To reproduce the issue that this patch fixes, prepare a test repository availlable over http+webdav, say at http://myhost/myrepo.git/ Then: $ git clone http://myhost/myrepo.git/ $ cd myrepo $ git push http Fetching remote heads... refs/ refs/heads/ refs/tags/ No refs in common and none specified; doing nothing. $ git push http Fetching remote heads... refs/ refs/heads/ refs/tags/ No refs in common and none specified; doing nothing. $ Finally, you look at the web server logs, and will find one LOCK query and no UNLOCK query, of course the second one will be in 423 return code instead of 200: 1.2.3.4 - gb [19/Jan/2008:14:24:56 +0100] "LOCK /myrepo.git/info/refs HTTP/1.1" 200 465 (...) 1.2.3.4 - gb [19/Jan/2008:14:25:10 +0100] "LOCK /myrepo.git/info/refs HTTP/1.1" 423 363 With this patch, there would have be two UNLOCKs in addition of the LOCKs From the user's point of view: - If you realize that you should have typed e.g. "git push http master" instead of "git push http", you will have to wait for 10 minutes for the lock to expire by its own. - Furthermore, if somebody else is dumb enough to type "git push http" while you need to push "master" branch, then you'll need too to wait for 10 minutes too. Signed-off-by: Gr.ANigoire Barbier <gb@gbarbier.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* http-push: disable http-push without USE_CURL_MULTIGrégoire Barbier2008-01-18
| | | | | | | | Make http-push always fail when not compiled with USE_CURL_MULTI, since otherwise it corrupts the remote repository (and then fails anyway). Signed-off-by: Grégoire Barbier <gb@gbarbier.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix double-free() in http-push.c:remote_exists()Grégoire Barbier2007-12-30
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Move fetch_ref from http-push.c and http-walker.c to http.cMike Hommey2007-12-14
| | | | | | | | Make the necessary changes to be ok with their difference, and rename the function http_fetch_ref. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix various memory leaks in http-push.c and http-walker.cMike Hommey2007-12-14
| | | | | Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Use strbuf in http codeMike Hommey2007-12-14
| | | | | | | Also, replace whitespaces with tabs in some places Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Remove the default_headers variable from http-push.cMike Hommey2007-12-14
| | | | | | | It appears that despite being initialized, it was never used. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix random sha1 in error message in http-fetch and http-pushMike Hommey2007-12-14
| | | | | | | | | | When a downloaded ref doesn't contain a sha1, the error message displays a random sha1 because of uninitialized memory. This happens when cloning a repository that is already a clone of another one, in which case refs/remotes/origin/HEAD is a symref. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix some more memory leaks in http-push.cMike Hommey2007-12-14
| | | | | Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Fix XML parser leaks in http-pushMike Hommey2007-12-12
| | | | | | | | XML_Parser were never freed. While at it, move the parser initialization to right before it is needed. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Print the real filename that we failed to open.André Goddard Rosa2007-11-25
| | | | | | | | | When we fail to open a temporary file to be renamed to something else, we reported the final filename, not the temporary file we failed to open. Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Teach send-pack a mirror modeAndy Whitcroft2007-11-09
| | | | | | | | | | | | | | | | | | Existing "git push --all" is almost perfect for backing up to another repository, except that "--all" only means "all branches" in modern git, and it does not delete old branches and tags that exist at the back-up repository that you have removed from your local repository. This teaches "git-send-pack" a new "--mirror" option. The difference from the "--all" option are that (1) it sends all refs, not just branches, and (2) it deletes old refs you no longer have on the local side from the remote side. Original patch by Junio C Hamano. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge master into aw/mirror-pushJunio C Hamano2007-11-09
|\
| * errors: "strict subset" -> "ancestor"J. Bruce Fields2007-11-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The term "ancestor" is a bit more intuitive (and more consistent with the documentation) than the term "strict subset". Also, remove superfluous "ref", capitalize, and add some carriage returns, changing: error: remote 'refs/heads/master' is not a strict subset of local ref 'refs/heads/master'. maybe you are not up-to-date and need to pull first? error: failed to push to 'ssh://linux-nfs.org/~bfields/exports/git.git' to: error: remote 'refs/heads/master' is not an ancestor of local 'refs/heads/master'. Maybe you are not up-to-date and need to pull first? error: failed to push to 'ssh://linux-nfs.org/~bfields/exports/git.git' Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Miscellaneous const changes and utilitiesDaniel Barkalow2007-11-02
|/ | | | | | | | | | | | | | | | | | | | | | The list of remote refs in struct transport should be const, because builtin-fetch will get confused if it changes. The url in git_connect should be const (and work on a copy) instead of requiring the caller to copy it. match_refs doesn't modify the refspecs it gets. get_fetch_map and get_remote_ref don't change the list they get. Allow transport get_refs_list methods to modify the struct transport. Add a function to copy a list of refs, when a function needs a mutable copy of a const list. Add a function to check the type of a ref, as per the code in connect.c Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Support 'push --dry-run' for http transportShawn O. Pearce2007-10-16
| | | | | | | | If the end-user requested a dry-run push we need to pass that flag over to http-push and additionally make sure it does not actually upload any changes to the remote server. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* Merge branch 'master' into db/fetch-packShawn O. Pearce2007-10-16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a number of tricky conflicts between master and this topic right now due to the rewrite of builtin-push. Junio must have handled these via rerere; I'd rather not deal with them again so I'm pre-merging master into the topic. Besides this topic somehow started to depend on the strbuf series that was in next, but is now in master. It no longer compiles on its own without the strbuf API. * master: (184 commits) Whip post 1.5.3.4 maintenance series into shape. Minor usage update in setgitperms.perl manual: use 'URL' instead of 'url'. manual: add some markup. manual: Fix example finding commits referencing given content. Fix wording in push definition. Fix some typos, punctuation, missing words, minor markup. manual: Fix or remove em dashes. Add a --dry-run option to git-push. Add a --dry-run option to git-send-pack. Fix in-place editing functions in convert.c instaweb: support for Ruby's WEBrick server instaweb: allow for use of auto-generated scripts Add 'git-p4 commit' as an alias for 'git-p4 submit' hg-to-git speedup through selectable repack intervals git-svn: respect Subversion's [auth] section configuration values gtksourceview2 support for gitview fix contrib/hooks/post-receive-email hooks.recipients error message Support cvs via git-shell rebase -i: use diff plumbing instead of porcelain ... Conflicts: Makefile builtin-push.c rsh.c
| * Use xmemdupz() in many places.Pierre Habouzit2007-09-18
| | | | | | | | | | Signed-off-by: Pierre Habouzit <madcoder@debian.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Modularize commit-walkerDaniel Barkalow2007-09-19
| | | | | | | | | | | | | | | | | | | | | | | | This turns the extern functions to be provided by the backend into a struct of pointers, renames the functions to be more namespace-friendly, and updates http-fetch to this interface. It removes the unused include from http-push.c. It makes git-http-fetch a builtin (with the implementation a separate file, accessible directly). Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Make function to refill http queue a callbackDaniel Barkalow2007-09-19
| | | | | | | | | | | | | | | | | | | | | | This eliminates the last function provided by the code using http.h as a global symbol, so it should be possible to have multiple programs using http.h in the same executable, and it also adds an argument to that callback, so that info can be passed into the callback without being global. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Refactor http.h USE_CURL_MULTI fill_active_slots().Daniel Barkalow2007-09-19
|/ | | | | | | | This removes all of the boilerplate and http-internal stuff from fill_active_slots() and makes it easy to turn into a callback. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* War on whitespaceJunio C Hamano2007-06-07
| | | | | | | | | This uses "git-apply --whitespace=strip" to fix whitespace errors that have crept in to our source files over time. There are a few files that need to have trailing whitespaces (most notably, test vectors). The results still passes the test, and build result in Documentation/ area is unchanged. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Move refspec parser from connect.c and cache.h to remote.{c,h}Daniel Barkalow2007-05-20
| | | | | Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Fix lseek(2) calls with args 2 and 3 swappedDana How2007-04-05
| | | | Signed-off-by: Junio C Hamano <junkio@cox.net>
* Initialize tree descriptors with a helper function rather than by hand.Linus Torvalds2007-03-21
| | | | | | | | | | | | | This removes slightly more lines than it adds, but the real reason for doing this is that future optimizations will require more setup of the tree descriptor, and so we want to do it in one place. Also renamed the "desc.buf" field to "desc.buffer" just to trigger compiler errors for old-style manual initializations, making sure I didn't miss anything. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* Merge branch 'maint'Junio C Hamano2007-03-02
|\ | | | | | | | | | | | | | | | | | | * maint: Another memory overrun in http-push.c fetch.o depends on the headers, too. Documentation: Correct minor typo in git-add documentation. Documentation/git-send-email.txt: Fix labeled list formatting Documentation/git-quiltimport.txt: Fix labeled list formatting Documentation/build-docdep.perl: Fix dependencies for included asciidoc files
| * Another memory overrun in http-push.cEygene Ryabinkin2007-03-02
| | | | | | | | | | Use of strlcpy() are wrong, as the source buffer at these locations may not be NUL-terminated.
* | Merge branch 'maint'Junio C Hamano2007-02-28
|\ \ | |/ | | | | | | | | | | | | | | | | | | * maint: Start preparing Release Notes for 1.5.0.3 Documentation: git-remote add [-t <branch>] [-m <branch>] [-f] name url Include config.mak in doc/Makefile git.el: Set the default commit coding system from the repository config. git-archimport: support empty summaries, put summary on a single line. http-push.c::lock_remote(): validate all remote refs. git-cvsexportcommit: don't cleanup .msg if not yet committed to cvs.
| * http-push.c::lock_remote(): validate all remote refs.Eygene Ryabinkin2007-02-28
| | | | | | | | | | | | | | | | Starting from offset 11 might have been good back when it was only used for updating "refs/heads/*", but it is used to update "info/refs" and "refs/tags/*" as well. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | convert object type handling from a string to a numberNicolas Pitre2007-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently have two parallel notation for dealing with object types in the code: a string and a numerical value. One of them is obviously redundent, and the most used one requires more stack space and a bunch of strcmp() all over the place. This is an initial step for the removal of the version using a char array found in object reading code paths. The patch is unfortunately large but there is no sane way to split it in smaller parts without breaking the system. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
* | prefixcmp(): fix-up leftover strncmp().Junio C Hamano2007-02-20
| | | | | | | | | | | | | | | | | | There were instances of strncmp() that were formatted improperly (e.g. whitespace around parameter before closing parenthesis) that caused the earlier mechanical conversion step to miss them. This step cleans them up. Signed-off-by: Junio C Hamano <junkio@cox.net>
* | Mechanical conversion to use prefixcmp()Junio C Hamano2007-02-20
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This mechanically converts strncmp() to use prefixcmp(), but only when the parameters match specific patterns, so that they can be verified easily. Leftover from this will be fixed in a separate step, including idiotic conversions like if (!strncmp("foo", arg, 3)) => if (!(-prefixcmp(arg, "foo"))) This was done by using this script in px.perl #!/usr/bin/perl -i.bak -p if (/strncmp\(([^,]+), "([^\\"]*)", (\d+)\)/ && (length($2) == $3)) { s|strncmp\(([^,]+), "([^\\"]*)", (\d+)\)|prefixcmp($1, "$2")|; } if (/strncmp\("([^\\"]*)", ([^,]+), (\d+)\)/ && (length($1) == $3)) { s|strncmp\("([^\\"]*)", ([^,]+), (\d+)\)|(-prefixcmp($2, "$1"))|; } and running: $ git grep -l strncmp -- '*.c' | xargs perl px.perl Signed-off-by: Junio C Hamano <junkio@cox.net>