aboutsummaryrefslogtreecommitdiff
path: root/remote.c
Commit message (Collapse)AuthorAge
* remote.c: do not trigger remote.<name>.<var> codepath for two-level namesJohannes Sixt2009-04-24
| | | | | | | | | | | | | | | | | | | | | | If the config file contains a section like this: [remote] default = foo (it should be '[remotes]') then commands like git status git checkout git branch -v fail even though they are not obviously related to remotes. (These commands write "ahead, behind" information and, therefore, access the per-remote information). Unknown configuration keys should be ignored, not trigger errors. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Revert "stat_tracking_info(): only count real commits"Junio C Hamano2009-04-21
| | | | | This reverts commit 19de5d6913b9681d2bde533bccc8445c9236a648. It produces a misleading output to decide if a merge can fast-forward.
* Merge branch 'bw/short-ref-strict'Junio C Hamano2009-04-17
|\ | | | | | | | | | | | | | | * bw/short-ref-strict: remote.c: use shorten_unambiguous_ref rev-parse: --abbrev-ref option to shorten ref name for-each-ref: utilize core.warnAmbiguousRefs for :short-format shorten_unambiguous_ref(): add strict mode
| * remote.c: use shorten_unambiguous_refMichael J Gruber2009-04-17
| | | | | | | | | | | | | | | | Use the new shorten_unambiguous_ref() for simplifying the output of upstream branch names. This affects status and checkout. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | get_local_heads(): do not return random pointer if there is no headNguyễn Thái Ngọc Duy2009-04-17
|/ | | | | | | | | | | it's silly to do this: mkdir foo && cd foo && git init && git push somewhere.git but segfault should not happen even in that case. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'fg/remote-prune'Junio C Hamano2009-04-12
|\ | | | | | | | | | | | | | | | | | | * fg/remote-prune: add tests for remote groups git remote update: Fallback to remote if group does not exist remote: New function remote_is_configured() git remote update: Report error for non-existing groups git remote update: New option --prune builtin-remote.c: Split out prune_remote as a separate function.
| * remote: New function remote_is_configured()Finn Arne Gangstad2009-04-07
| | | | | | | | | | | | | | | | | | | | | | Previously, there was no easy way to check for the existence of a configured remote. remote_get for example would always create the remote "on demand". This new function returns 1 if the remote is configured, 0 otherwise. Signed-off-by: Finn Arne Gangstad <finnag@pvv.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'mg/tracked-local-branches'Junio C Hamano2009-04-06
|\ \ | |/ |/| | | | | | | * mg/tracked-local-branches: Make local branches behave like remote branches when --tracked Test for local branches being followed with --track
| * Make local branches behave like remote branches when --trackedMichael J Gruber2009-04-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes sure that local branches, when followed using --track, behave the same as remote ones (e.g. differences being reported by git status and git checkout). This fixes 1 known failure. The fix is done within branch_get(): The first natural candidate, namely remote_find_tracking(), does not have all the necessary info because in general there is no remote struct for '.', and we don't want one because it would show up in other places as well. branch_get(), on the other hand, has access to merge_names[] (in addition to merge[]) and therefore can set up the followed branch easily. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'kb/tracking-count-no-merges'Junio C Hamano2009-04-01
|\ \ | |/ |/| | | | | * kb/tracking-count-no-merges: stat_tracking_info(): only count real commits
| * stat_tracking_info(): only count real commitsKjetil Barvik2009-03-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | stat_tracking_info() in remote.c is used to collect the statistics to be able to say (for instance) from the output of "git checkout': Your branch and 'foo' have diverged, and have X and Y different commit(s) each, respectively. Currently X and Y also includes the count of merges. This patch excludes the merges from being counted. Signed-off-by: Kjetil Barvik <barvik@broadpark.no> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'xx/db-refspec-vs-js-remote'Junio C Hamano2009-03-20
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | * xx/db-refspec-vs-js-remote: Support '*' in the middle of a refspec Keep '*' in pattern refspecs Use the matching function to generate the match results Use a single function to match names against patterns Make clone parse the default refspec with the normal code
| * \ Adjust js/remote-improvements and db/refspec-wildcard-in-the-middleJunio C Hamano2009-03-08
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The latter topic changes the definition of how refspec's src and dst side is stored in-core; it used to be that the asterisk for pattern was omitted, but now it is included. The former topic handcrafts an old style refspec to feed the refspec matching machinery that lacks the asterisk and triggers an error. This resolves the semantic clash between the two topics early before they need to be merged to integration branches. Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | Support '*' in the middle of a refspecDaniel Barkalow2009-03-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to keep the requirements strict, each * has to be a full path component, and there may only be one * per side. This requirement is enforced entirely by check_ref_format(); the matching implementation will substitute the whatever matches the * in the lhs for the * in the rhs. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | Keep '*' in pattern refspecsDaniel Barkalow2009-03-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to do anything more capable with refspecs, the first step is to keep the entire input. Additionally, validate patterns by checking for the ref matching the rules for a pattern as given by check_ref_format(). This requires a slight change to check_ref_format() to make it enforce the requirement that the '*' immediately follow a '/'. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | Use the matching function to generate the match resultsDaniel Barkalow2009-03-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This puts all of the interpretation of the pattern representation in a single function for easy manipulation. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | Use a single function to match names against patternsDaniel Barkalow2009-03-07
| | |/ | |/| | | | | | | | | | | | | | | | This will help when the matching changes. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'db/maint-missing-origin'Junio C Hamano2009-03-17
|\ \ \ | | | | | | | | | | | | | | | | | | | | * db/maint-missing-origin: Remove total confusion from git-fetch and git-push Give error when no remote is configured
| * | | Remove total confusion from git-fetch and git-pushJunio C Hamano2009-03-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The config file is not the only place remotes are defined, and without consulting .git/remotes and .git/branches, you won't know if "origin" is configured by the user. Don't give up too early and insult the user with a wisecrack "Where do you want to fetch from today?" The only thing the previous patch seems to want to prevent from happening is a lazy "git fetch/push" that does not say where-from/to to produce an error message 'origin not found', and we can do that by not letting add_url_alias() to turn a nickname "origin" literally into a pathname "origin" without changing the rest of the logic. Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | Give error when no remote is configuredDaniel Barkalow2009-03-10
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When there's no explicitly-named remote, we use the remote specified for the current branch, which in turn defaults to "origin". But it this case should require the remote to actually be configured, and not fall back to the path "origin". Possibly, the config file's "remote = something" should require the something to be a configured remote instead of a bare repository URL, but we actually test with a bare repository URL. In fetch, we were giving the sensible error message when coming up with a URL failed, but this wasn't actually reachable, so move that error up and use it when appropriate. In push, we need a new error message, because the old one (formerly unreachable without a lot of help) used the repo name, which was NULL. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'js/remote-improvements'Junio C Hamano2009-03-17
|\ \ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
| * | remote: make guess_remote_head() use exact HEAD lookup if it is availableJeff King2009-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our usual method for determining the ref pointed to by HEAD is to compare HEAD's sha1 to the sha1 of all refs, trying to find a unique match. However, some transports actually get to look at HEAD directly; we should make use of that information when it is available. Currently, only http remotes support this feature. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | remote: make match_refs() not short-circuitJay Soffian2009-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | match_refs() returns non-zero if there is an error in match_explicit_refs(), without handling any remaining pattern ref specs. Its existing callers exit upon receiving non-zero, so a partial result is of no consequence to them; however a new caller, builtin-remote, is interested in the complete result even if there are errors in match_explicit_refs(). Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | remote: make match_refs() copy src ref before assigning to peer_refJay Soffian2009-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some instances, match_refs() sets the peer_ref field of refs in the dst list such that it points to a ref in the src list. This prevents callers from freeing both the src and dst lists, as doing so would cause a double-free since free_refs() frees the peer_ref. As well, the following configuration causes two refs in the dst list to have the same peer_ref, which can also lead to a double-free: push = refs/heads/master:refs/heads/backup push = refs/heads/master:refs/heads/master Existing callers of match_heads() call it only once and then terminate, w/o ever bothering to free the src or dst lists, so this is not currently a problem. This patch modifies match_refs() to first copy any refs it plucks from the src list before assigning them as a peer_ref. This allows builtin-remote, a future caller, to free the src and dst lists. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | remote: let guess_remote_head() optionally return all matchesJay Soffian2009-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Determining HEAD is ambiguous since it is done by comparing SHA1s. In the case of multiple matches we return refs/heads/master if it matches, else we return the first match we encounter. builtin-remote needs all matches returned to it, so add a flag for it to request such. To be simple and consistent, the return value is now a copy (including peer_ref) of the matching refs. Originally contributed by Jeff King along with the prior commit as a single patch. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | remote: make copy_ref() perform a deep copyJay Soffian2009-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To ensure that copied refs can always be freed w/o causing a double-free, make copy_ref() perform a deep copy. Also have copy_ref() return NULL if asked to copy NULL to simplify things for the caller. Background: currently copy_ref() performs a shallow copy. This is fine for current callers who never free the result and/or only copy refs which contain NULL pointers. But copy_ref() is about to gain a new caller (guess_remote_head()) which copies refs where peer_ref is not NULL and the caller of guess_remote_head() will want to free the result. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | remote: simplify guess_remote_head()Jay Soffian2009-02-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function had complications which made it hard to extend. - It used to do two things: find the HEAD ref, and then find a matching ref, optionally returning the former via assignment to a passed-in pointer. Since finding HEAD is a one-liner, just have a caller do it themselves and pass it as an argument. - It used to manually search through the ref list for refs/heads/master; this can be a one-line call to find_ref_by_name. Originally contributed by Jeff King along with the next commit as a single patch. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | move locate_head() to remote.cJay Soffian2009-02-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Move locate_head() to remote.c and rename it to guess_remote_head() to more accurately reflect what it does. 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>
| * | move duplicated ref_newer() to remote.cJay Soffian2009-02-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * | move duplicated get_local_heads() to remote.cJay Soffian2009-02-26
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Remove unused assignmentsBenjamin Kramer2009-03-14
|/ | | | | | | | | | | | | | | | | These variables were always overwritten or the assigned value was unused: builtin-diff-tree.c::cmd_diff_tree(): nr_sha1 builtin-for-each-ref.c::opt_parse_sort(): sort_tail builtin-mailinfo.c::decode_header_bq(): in builtin-shortlog.c::insert_one_record(): len connect.c::git_connect(): path imap-send.c::v_issue_imap_cmd(): n pretty.c::pp_user_info(): filler remote::parse_refspec_internal(): llen Signed-off-by: Benjamin Kramer <benny.kra@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* add is_dot_or_dotdot inline functionAlexander Potashev2009-01-11
| | | | | | | | | | A new inline function is_dot_or_dotdot is used to check if the directory name is either "." or "..". It returns a non-zero value if the given string is "." or "..". It's applicable to a lot of Git source code. Signed-off-by: Alexander Potashev <aspotashev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'mk/maint-cg-push'Junio C Hamano2008-11-12
|\ | | | | | | | | | | | | | | * mk/maint-cg-push: git push: Interpret $GIT_DIR/branches in a Cogito compatible way Conflicts: t/t5516-fetch-push.sh
| * git push: Interpret $GIT_DIR/branches in a Cogito compatible wayMartin Koegler2008-11-11
| | | | | | | | | | | | | | | | | | | | | | | | Current git versions ignore everything after # (called <head> in the following) when pushing. Older versions (before cf818348f1ab57), interpret #<head> as part of the URL, which make git bail out. As branches origin from Cogito, it is the best to correct this by using the behaviour of cg-push, that is to push HEAD to remote refs/heads/<head>. Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | remote: add a new 'origin' variable to the structMiklos Vajna2008-11-11
| | | | | | | | | | | | | | | | | | This allows one to track where was the remote's original source, so that it's possible to decide if it makes sense to migrate it to the config format or not. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | make alloc_ref_from_str() the new alloc_ref()René Scharfe2008-10-18
| | | | | | | | | | | | | | | | | | | | | | With all calls to alloc_ref() gone, we can remove it and then we're free to give alloc_ref_from_str() the shorter name. It's a much nicer interface, as the callers always need to have a name string when they allocate a ref anyway and don't need to calculate and pass its length+1 any more. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | use alloc_ref_from_str() everywhereRené Scharfe2008-10-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace pairs of alloc_ref() and strcpy() with alloc_ref_from_str(), simplifying the code. In connect.c, also a pair of alloc_ref() and memcpy() is replaced -- the additional cost of a strlen() call should not have too much of an impact. Consistency and simplicity are more important. In remote.c, the code was allocating 11 bytes more than needed for the name part, but I couldn't see them being used for anything. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | add alloc_ref_with_prefix()René Scharfe2008-10-18
| | | | | | | | | | | | | | | | | | | | | | | | | | In three cases in remote.c, a "raw" ref is allocated using alloc_ref() and then its is constructed using sprintf(). Clean it up by adding a helper function, alloc_ref_with_prefix(), which creates a composite name. Use it in alloc_ref_from_str(), too, as it simplifies the code. Open code alloc_ref() in alloc_ref_with_prefix(), as the former is going to be removed in the patch after the next. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'maint'Junio C Hamano2008-10-17
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | * maint: t1301-shared-repo.sh: don't let a default ACL interfere with the test git-check-attr(1): add output and example sections xdiff-interface.c: strip newline (and cr) from line before pattern matching t4018-diff-funcname: demonstrate end of line funcname matching flaw t4018-diff-funcname: rework negated last expression test Typo "does not exists" when git remote update remote. remote.c: correct the check for a leading '/' in a remote name Add testcase to ensure merging an early part of a branch is done properly Conflicts: t/t7600-merge.sh
| * remote.c: correct the check for a leading '/' in a remote nameBrandon Casey2008-10-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test is supposed to disallow remote entries in the config file of the form: [remote "/foobar"] ... The leading slash in '/foobar' is not acceptable. Instead it was incorrectly testing that the subkey had no leading '/', which had no effect since the subkey pointer was made to point at a '.' in the preceding lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializerBrandon Casey2008-10-12
| | | | | | | | | | | | | | | | | | | | | | Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Replace xmalloc/memset(0) pairs with xcallocBrandon Casey2008-10-08
| | | | | | | | | | | | | | | | | | Many call sites immediately initialize allocated memory with zero after calling xmalloc. A single call to xcalloc can replace this two-call sequence. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | remote.c: make free_ref(), parse_push_refspec() and free_refspecs() static.Nanako Shiraishi2008-09-25
| | | | | | | | | | | | | | These functions are not used by any other file. Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
* | Use xmalloc() and friends to catch allocation failuresDotan Barak2008-09-09
| | | | | | | | | | | | | | | | | | Some places use the standard malloc/strdup without checking if the allocation was successful; they should use xmalloc/xstrdup that check the memory allocation result. Signed-off-by: Dotan Barak <dotanba@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | remote.c: add a function for deleting a refspec array and use it (twice)Brandon Casey2008-08-22
|/ | | | | | | | | | | | | | A number of call sites allocate memory for a refspec array, populate its members with heap memory, and then free only the refspec pointer while leaking the memory allocated for the member elements. Provide a function for freeing the elements of a refspec array and the array itself. Caution to callers: code paths must be checked to ensure that the refspec members "src" and "dst" can be passed to free. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* remote.c: remove useless if-before-free testJim Meyering2008-08-19
| | | | | | | | We removed a handful of these useless if-before-free tests several months ago. This change removes a new one that snuck back in. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* make sure parsed wildcard refspec ends with slashJunio C Hamano2008-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | A wildcard refspec is internally parsed into a refspec structure with src and dst strings. Many parts of the code assumed that these do not include the trailing "/*" when matching the wildcard pattern with an actual ref we see at the remote. What this meant was that we needed to make sure not just that the prefix matched, and also that a slash followed the part that matched. But a codepath that scans the result from ls-remote and finds matching refs forgot to check the "matching part must be followed by a slash" rule. This resulted in "refs/heads/b1" from the remote side to mistakenly match the source side of "refs/heads/b/*:refs/remotes/b/*" refspec. Worse, the refspec crafted internally by "git-clone", and a hardcoded preparsed refspec that is used to implement "git-fetch --tags", violated this "parsed widcard refspec does not end with slash" rule; simply adding the "matching part must be followed by a slash" rule then would have broken codepaths that use these refspecs. This commit changes the rule to require a trailing slash to parsed wildcard refspecs. IOW, "refs/heads/b/*:refs/remotes/b/*" is parsed as src = "refs/heads/b/" and dst = "refs/remotes/b/". This allows us to simplify the matching logic because we only need to do a prefixcmp() to notice "refs/heads/b/one" matches and "refs/heads/b1" does not. Acked-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Reword "your branch has diverged..." lines to reduce line lengthAvery Pennarun2008-07-16
| | | | | | | | | | | | | The message length depends on the length of the branch name. In my case, the branch name "origin/add-chickens2" put the first line of the "your branch has diverged" message over 80 characters, which triggered "less -FS" to not exit automatically as expected. This patch rewords the messages to make the lines generally shorter, so that you'd need a significantly longer branch name to trigger the problem. Signed-off-by: Avery Pennarun <apenwarr@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* stat_tracking_info(): clear object flags used during countingJunio C Hamano2008-07-03
| | | | | | | | | When left-right traversal counts the commits in a diverged history, it leaves the flags in the commits smudged, and we need to clear them before we return. Otherwise the caller cannot inspect other branches with this function again. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Refactor "tracking statistics" code used by "git checkout"Junio C Hamano2008-07-02
| | | | | | | | | | | | | | | | | | | | People seem to like "Your branch is ahead by N commit" report made by "git checkout", but the interface into the statistics function was a bit clunky. This splits the function into three parts: * The core "commit counting" function that takes "struct branch" and returns number of commits to show if we are ahead, behind or forked; * Convenience "stat formating" function that takes "struct branch" and formats the report into a given strbuf, using the above function; * "checkout" specific function that takes "branch_info" (type that is internal to checkout implementation), calls the above function and print the formatted result. in the hope that the former two can be more easily reusable. Signed-off-by: Junio C Hamano <gitster@pobox.com>