summaryrefslogtreecommitdiff
path: root/remote.c
AgeCommit message (Collapse)Author
2013-01-12Merge branch 'jc/fetch-ignore-symref' into maintJunio C Hamano
"git fetch --mirror" and fetch that uses other forms of refspec with wildcard used to attempt to update a symbolic ref that match the wildcard on the receiving end, which made little sense (the real ref that is pointed at by the symbolic ref would be updated anyway). Symbolic refs no longer are affected by such a fetch. * jc/fetch-ignore-symref: fetch: ignore wildcarded refspecs that update local symbolic refs
2012-12-11fetch: ignore wildcarded refspecs that update local symbolic refsJunio C Hamano
In a repository cloned from somewhere else, you typically have a symbolic ref refs/remotes/origin/HEAD pointing at the 'master' remote-tracking ref that is next to it. When fetching into such a repository with "git fetch --mirror" from another repository that was similarly cloned, the implied wildcard refspec refs/*:refs/* will end up asking to update refs/remotes/origin/HEAD with the object at refs/remotes/origin/HEAD at the remote side, while asking to update refs/remotes/origin/master the same way. Depending on the order the two updates happen, the latter one would find that the value of the ref before it is updated has changed from what the code expects. When the user asks to update the underlying ref via the symbolic ref explicitly without using a wildcard refspec, e.g. "git fetch $there refs/heads/master:refs/remotes/origin/HEAD", we should still let him do so, but when expanding wildcard refs, it will result in a more intuitive outcome if we simply ignore local symbolic refs. As the purpose of the symbolic ref refs/remotes/origin/HEAD is to follow the ref it points at (e.g. refs/remotes/origin/master), its value would change when the underlying ref is updated. Earlier commit da3efdb (receive-pack: detect aliased updates which can occur with symrefs, 2010-04-19) fixed a similar issue for "git push". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-03Merge branch 'mm/status-push-pull-advise'Junio C Hamano
Finishing touch to allow the new advice message squelched with an advice.* configuration variable. * mm/status-push-pull-advise: status: respect advice.statusHints for ahead/behind advice
2012-12-03status: respect advice.statusHints for ahead/behind adviceJeff King
If the user has unset advice.statusHints, we already suppress the "use git reset to..." hints in each stanza. The new "use git push to publish..." hint is the same type of hint. Let's respect statusHints for it, rather than making the user set yet another advice flag. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-28Merge branch 'mm/status-push-pull-advise'Junio C Hamano
* mm/status-push-pull-advise: status: add advice on how to push/pull to tracking branch
2012-11-16status: add advice on how to push/pull to tracking branchMatthieu Moy
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-15Merge branch 'jc/maint-fetch-tighten-refname-check'Junio C Hamano
For a fetch refspec (or the result of applying wildcard on one), we always want the RHS to map to something inside "refs/" hierarchy. This was split out from discarded jc/maint-push-refs-all topic. * jc/maint-fetch-tighten-refname-check: get_fetch_map(): tighten checks on dest refs
2012-10-19get_fetch_map(): tighten checks on dest refsJunio C Hamano
The code to check the refname we store the fetched result locally did not bother checking the first 5 bytes of it, presumably assuming that it always begin with "refs/". For a fetch refspec (or the result of applying wildcard on one), we always want the RHS to map to something inside "refs/" hierarchy, so let's spell that rule out in a more explicit way. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-14Merge branch 'jk/push-delete-ref-error-message'Junio C Hamano
The error message from "git push $there :bogo" mentioned we tried and failed to guess what ref is being deleted based on the LHS of the refspec, which we don't. # By Jeff King * jk/push-delete-ref-error-message: push: don't guess at qualifying remote refs on deletion
2012-07-03push: don't guess at qualifying remote refs on deletionJeff King
When we try to push a ref and the right-hand side of the refspec does not find a match, we try to create it. If it is not fully qualified, we try to guess where it would go in the refs hierarchy based on the left-hand source side. If the source side is not a ref, then we give up and give a long explanatory message. For deletions, however, this doesn't make any sense. We would never want to create on the remote side, and if an unqualified ref can't be matched, it is simply an error. The current code handles this already because the left-hand side is empty, and therefore does not give us a hint as to where the right-hand side should go, and we properly error out. Unfortunately, the error message is the long "we tried to qualify this, but the source side didn't let us guess" message, which is quite confusing. Instead, we can just be more succinct and say "we can't delete this because we couldn't find it". So before: $ git push origin :bogus error: unable to push to unqualified destination: bogus The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. error: failed to push some refs to '$URL' and now: $ git push origin :bogus error: unable to delete 'bogus': remote ref does not exist error: failed to push some refs to '$URL' It is tempting to also catch a fully-qualified ref like "refs/heads/bogus" and generate the same error message. However, that currently does not error out at all, and instead gets sent to the remote side, which typically generates a warning: $ git push origin:refs/heads/bogus remote: warning: Deleting a non-existent ref. To $URL - [deleted] bogus While it would be nice to catch this error early, a client-side error would mean aborting the push entirely and changing push's exit code. For example, right now you can do: $ git push origin refs/heads/foo refs/heads/bar and end up in a state where "foo" and "bar" are deleted, whether both of them currently exist or not (and see an error only if we actually failed to contact the server). Generating an error would cause a regression for this use case. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-22add sorting infrastructure for list refsJeff King
Since we store lists of refs as linked lists, we can use llist_mergesort to efficiently sort them. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-23push: add '--prune' optionFelipe Contreras
When pushing groups of refs to a remote, there is no simple way to remove old refs that still exist at the remote that is no longer updated from us. This will allow us to remove such refs from the remote. With this change, running this command $ git push --prune remote refs/heads/*:refs/remotes/laptop/* removes refs/remotes/laptop/foo from the remote if we do not have branch "foo" locally anymore. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-23remote: refactor code into alloc_delete_ref()Felipe Contreras
Will be useful in next patches. No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-23remote: reorganize check_pattern_match()Felipe Contreras
The function match_name_with_pattern() is called twice, once to see if a pattern matches with the name, and again to learn what the matched pattern maps the name to. Since check_pattern_match() is only used in one place, we can just reorganize it to make a single call and fetch the values at the same time. This changes the meaning of check_pattern_match() that used to check which pattern in the array of refspecs matched the given ref, to return the name of the remote ref the given ref is mapped to. Rename it to get_ref_match() which actually describes more closely what it's actually doing now. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-22remote: use a local variable in match_push_refs()Felipe Contreras
So that we can reuse src later on. No functional changes. Will be useful in next patches. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-02-02i18n: format_tracking_info "Your branch is behind" messageJiang Xin
Function format_tracking_info in remote.c is called by wt_status_print_tracking in wt-status.c, which will print branch tracking message in git-status. git-checkout also show these messages through it's report_tracking function. Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-12-13Rename resolve_ref() to resolve_ref_unsafe()Nguyễn Thái Ngọc Duy
resolve_ref() may return a pointer to a shared buffer and can be overwritten by the next resolve_ref() calls. Callers need to pay attention, not to keep the pointer when the next call happens. Rename with "_unsafe" suffix to warn developers (or reviewers) before introducing new call sites. This patch is generated using the following command git grep -l 'resolve_ref(' -- '*.[ch]'|xargs sed -i 's/resolve_ref(/resolve_ref_unsafe(/g' Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-11-13Convert many resolve_ref() calls to read_ref*() and ref_exists()Nguyễn Thái Ngọc Duy
resolve_ref() may return a pointer to a static buffer, which is not safe for long-term use because if another resolve_ref() call happens, the buffer may be changed. Many call sites though do not care about this buffer. They simply check if the return value is NULL or not. Convert all these call sites to new wrappers to reduce resolve_ref() calls from 57 to 34. If we change resolve_ref() prototype later on to avoid passing static buffer out, this helps reduce changes. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-26Merge branch 'cn/fetch-prune'Junio C Hamano
* cn/fetch-prune: fetch: treat --tags like refs/tags/*:refs/tags/* when pruning fetch: honor the user-provided refspecs when pruning refs remote: separate out the remote_find_tracking logic into query_refspecs t5510: add tests for fetch --prune fetch: free all the additional refspecs Conflicts: remote.c
2011-10-21Merge branch 'jc/match-refs-clarify'Junio C Hamano
* jc/match-refs-clarify: rename "match_refs()" to "match_push_refs()" send-pack: typofix error message
2011-10-16fetch: honor the user-provided refspecs when pruning refsCarlos Martín Nieto
If the user gave us refspecs on the command line, we should use those when deciding whether to prune a ref instead of relying on the refspecs in the config. Previously, running git fetch --prune origin refs/heads/master:refs/remotes/origin/master would delete every other ref under the origin namespace because we were using the refspec to filter the available refs but using the configured refspec to figure out if a ref had been deleted on the remote. This is clearly the wrong thing to do. Change prune_refs and get_stale_heads to simply accept a list of references and a list of refspecs. The caller of either function needs to decide what refspecs should be used to decide whether a ref is stale. Signed-off-by: Carlos Martín Nieto <cmn@elego.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-16remote: separate out the remote_find_tracking logic into query_refspecsCarlos Martín Nieto
Move the body of remote_find_tracking() to a new helper query_refspecs() that finds a refspec that matches and applies the transformation, but explicitly takes the list of refspecs, and make remote_find_tracking() a thin wrapper of it. Make apply_refspecs() also use query_refspecs(). Signed-off-by: Carlos Martín Nieto <cmn@elego.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-05remote: use xstrdup() instead of strdup()Michael Haggerty
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-05Change check_ref_format() to take a flags argumentMichael Haggerty
Change check_ref_format() to take a flags argument that indicates what is acceptable in the reference name (analogous to "git check-ref-format"'s "--allow-onelevel" and "--refspec-pattern"). This is more convenient for callers and also fixes a failure in the test suite (and likely elsewhere in the code) by enabling "onelevel" and "refspec-pattern" to be allowed independently of each other. Also rename check_ref_format() to check_refname_format() to make it obvious that it deals with refnames rather than references themselves. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-09-12rename "match_refs()" to "match_push_refs()"Junio C Hamano
Yes, there is a warning that says the function is only used by push in big red letters in front of this function, but it didn't say a more important thing it should have said: what the function is for and what it does. Rename it and document it to avoid future confusion. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-07make copy_ref globally availableJeff King
This is a useful function, and we have already made the similar alloc_ref and copy_ref_list available. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-06-06consider only branches in guess_remote_headJeff King
The guess_remote_head function tries to figure out where a remote's HEAD is pointing by comparing the sha1 of the remote's HEAD with the sha1 of various refs found on the remote. However, we were too liberal in matching refs, and would match tags or remote tracking branches, even though these things could not possibly be referenced by the HEAD symbolic ref (since git will detach when checking them out). As a result, a clone of a remote repository with a detached HEAD might write "refs/tags/*" into our local HEAD, which is bogus. The resulting HEAD should be detached. The other related code path is remote.c's get_head_names() (which is used for, among other things, "set-head -a"). This was not affected, however, as that function feeds only refs from refs/heads to guess_remote_head. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-11-03Change "tracking branch" to "remote-tracking branch"Matthieu Moy
One more step towards consistancy. We change the documentation and the C code in a single patch, since the only instances in the C code are in comment and usage strings. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-07-05string_list: Add STRING_LIST_INIT macro and make use of it.Thiago Farina
Acked-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Thiago Farina <tfransosi@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-30Merge branch 'jp/string-list-api-cleanup'Junio C Hamano
* jp/string-list-api-cleanup: string_list: Fix argument order for string_list_append string_list: Fix argument order for string_list_lookup string_list: Fix argument order for string_list_insert_at_index string_list: Fix argument order for string_list_insert string_list: Fix argument order for for_each_string_list string_list: Fix argument order for print_string_list
2010-06-27string_list: Fix argument order for string_list_appendJulian Phillips
Update the definition and callers of string_list_append to use the string_list as the first argument. This helps make the string_list API easier to use by being more consistent. Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-27string_list: Fix argument order for string_list_lookupJulian Phillips
Update the definition and callers of string_list_lookup to use the string_list as the first argument. This helps make the string_list API easier to use by being more consistent. Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-27string_list: Fix argument order for string_list_insertJulian Phillips
Update the definition and callers of string_list_insert to use the string_list as the first argument. This helps make the string_list API easier to use by being more consistent. Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-21Merge branch 'gv/portable'Junio C Hamano
* gv/portable: test-lib: use DIFF definition from GIT-BUILD-OPTIONS build: propagate $DIFF to scripts Makefile: Tru64 portability fix Makefile: HP-UX 10.20 portability fixes Makefile: HPUX11 portability fixes Makefile: SunOS 5.6 portability fix inline declaration does not work on AIX Allow disabling "inline" Some platforms lack socklen_t type Make NO_{INET_NTOP,INET_PTON} configured independently Makefile: some platforms do not have hstrerror anywhere git-compat-util.h: some platforms with mmap() lack MAP_FAILED definition test_cmp: do not use "diff -u" on platforms that lack one fixup: do not unconditionally disable "diff -u" tests: use "test_cmp", not "diff", when verifying the result Do not use "diff" found on PATH while building and installing enums: omit trailing comma for portability Makefile: -lpthread may still be necessary when libc has only pthread stubs Rewrite dynamic structure initializations to runtime assignment Makefile: pass CPPFLAGS through to fllow customization Conflicts: Makefile wt-status.h
2010-06-08Merge branch 'maint'Junio C Hamano
* maint: Change C99 comments to old-style C comments
2010-06-07Change C99 comments to old-style C commentsTor Arntsen
Signed-off-by: Tor Arntsen <tor@spacetec.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-05-31Rewrite dynamic structure initializations to runtime assignmentGary V. Vaughan
Unfortunately, there are still plenty of production systems with vendor compilers that choke unless all compound declarations can be determined statically at compile time, for example hpux10.20 (I can provide a comprehensive list of our supported platforms that exhibit this problem if necessary). This patch simply breaks apart any compound declarations with dynamic initialisation expressions, and moves the initialisation until after the last declaration in the same block, in all the places necessary to have the offending compilers accept the code. Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-04-19Honor "tagopt = --tags" configuration optionSamuel Tardieu
If the "tagopt = --tags" option of a remote is set, all tags will be fetched as in "git fetch --tags". Signed-off-by: Samuel Tardieu <sam@rfc1149.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-10refactor ref status logic for pushingTay Ray Chuan
Move the logic that detects up-to-date and non-fast-forward refs to a new function in remote.[ch], set_ref_status_for_push(). Make transport_push() invoke set_ref_status_for_push() before invoking the push_refs() implementation. (As a side-effect, the push_refs() implementation in transport-helper.c now knows of non-fast-forward pushes.) Removed logic for detecting up-to-date refs from the push_refs() implementation in transport-helper.c, as transport_push() has already done so for it. Make cmd_send_pack() invoke set_ref_status_for_push() before invoking send_pack(), as transport_push() can't do it for send_pack() here. Mark the test on the return status of non-fast-forward push to fail. Git now exits with success, as transport.c::transport_push() does not check for refs with status REF_STATUS_REJECT_NONFASTFORWARD nor does it indicate rejected pushes with its return value. Mark the test for ref status to succeed. As mentioned earlier, refs might be marked as non-fast-forwards, triggering the push status printing mechanism in transport.c. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-12-26Merge branch 'sr/vcs-helper'Junio C Hamano
* sr/vcs-helper: tests: handle NO_PYTHON setting builtin-push: don't access freed transport->url Add Python support library for remote helpers Basic build infrastructure for Python scripts Allow helpers to report in "list" command that the ref is unchanged Fix various memory leaks in transport-helper.c Allow helper to map private ref names into normal names Add support for "import" helper command Allow specifying the remote helper in the url Add a config option for remotes to specify a foreign vcs Allow fetch to modify refs Use a function to determine whether a remote is valid Allow programs to not depend on remotes having urls Fix memory leak in helper method for disconnect Conflicts: Documentation/git-remote-helpers.txt Makefile builtin-ls-remote.c builtin-push.c transport-helper.c
2009-11-23Merge branch 'bg/fetch-multi'Junio C Hamano
* bg/fetch-multi: Re-implement 'git remote update' using 'git fetch' builtin-fetch: add --dry-run option builtin-fetch: add --prune option teach warn_dangling_symref to take a FILE argument remote: refactor some logic into get_stale_heads() Add missing test for 'git remote update --prune' Add the configuration option skipFetchAll Teach the --multiple option to 'git fetch' Teach the --all option to 'git fetch'
2009-11-18Allow helper to map private ref names into normal namesDaniel Barkalow
This allows a helper to say that, when it handles "import refs/heads/topic", the script it outputs will actually write to refs/svn/origin/branches/topic; therefore, transport-helper should read it from the latter location after git-fast-import completes. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-18Add a config option for remotes to specify a foreign vcsDaniel Barkalow
If this is set, the url is not required, and the transport always uses a helper named "git-remote-<value>". It is a separate configuration option in order to allow a sensible configuration for foreign systems which either have no meaningful urls for repositories or which require urls that do not specify the system used by the repository at that location. However, this only affects how the name of the helper is determined, not anything about the interaction with the helper, and the contruction is such that, if the foreign scm does happen to use a co-named url method, a url with that method may be used directly. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-18Use a function to determine whether a remote is validDaniel Barkalow
Currently, it only checks url, but it will allow other things in the future. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-15remote: fix use-after-free error detected by glibc in ref_remove_duplicatesJulian Phillips
In ref_remove_duplicates, when we encounter a duplicate and remove it from the list we need to make sure that the prev pointer stays pointing at the last entry and also skip over adding the just freed entry to the string_list. Previously fetch could crash with: *** glibc detected *** git: corrupted double-linked list: ... Also add a test to try and catch problems with duplicate removal in the future. Acked-by: Nicolas Pitre <nico@fluxnic.net> Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-10remote: refactor some logic into get_stale_heads()Jay Soffian
Move the logic in builtin-remote.c which determines which local heads are stale to remote.c so it can be used by other builtins. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-10Add the configuration option skipFetchAllBjörn Gustavsson
Implement the configuration skipFetchAll option to allow certain remotes to be skipped when doing 'git fetch --all' and 'git remote update'. The existing skipDefaultUpdate variable is still honored (by 'git fetch --all' and 'git remote update'). (If both are set in the configuration file with different values, the value of the last occurrence will be used.) Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-10-28remote: Make ref_remove_duplicates faster for large numbers of refsJulian Phillips
The ref_remove_duplicates function was very slow at dealing with very large numbers of refs. This is because it was using a linear search through all remaining refs to find any duplicates of the current ref. Rewriting it to use a string list to keep track of which refs have already been seen and removing duplicates when they are found is much more efficient. Signed-off-by: Julian Phillips <julian@quantumfyre.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-08Add url.<base>.pushInsteadOf: URL rewriting for push onlyJosh Triplett
This configuration option allows systematically rewriting fetch-only URLs to push-capable URLs when used with push. For instance: [url "ssh://example.org/"] pushInsteadOf = "git://example.org/" This will allow clones of "git://example.org/path/to/repo" to subsequently push to "ssh://example.org/path/to/repo", without manually configuring pushurl for that remote. Includes documentation for the new option, bash completion updates, and test cases (both that pushInsteadOf applies to push, that it does not apply to fetch, and that it is ignored when pushURL is already defined). Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-07Wrap rewrite globals in a struct in preparation for adding another setJosh Triplett
remote.c has a global set of URL rewrites, accessed by alias_url and make_rewrite. Wrap them in a new "struct rewrites", passed to alias_url and make_rewrite. This allows adding other sets of rewrites. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>