Fetch the recent refs from the remotes.

        Unless git-up.fetch.all is set to true, all remotes with
        locally existent branches will be fetched.
349098
def fetch(self):
        
        fetch_kwargs = {'multiple': True}
        fetch_args = []

        if self.is_prune():
            fetch_kwargs['prune'] = True

        if self.settings['fetch.all']:
            fetch_kwargs['all'] = True
        else:
            if '.' in self.remotes:
                self.remotes.remove('.')

                if not self.remotes:
                    # Only local target branches,
                    # `git fetch --multiple` will fail
                    return

            fetch_args.append(self.remotes)

        try:
            self.git.fetch(*fetch_args, **fetch_kwargs)
        except GitError as error:
            error.message = "`git fetch` failed"
            raise error
463061
protected void pullBulkRevisions(List<RevisionInternal> bulkRevs) {

        int nRevs = bulkRevs.size();
        if (nRevs == 0) {
            return;
        }
        Log.d(TAG, "%s bulk-fetching %d remote revisions...", this, nRevs);
        Log.d(TAG, "%s bulk-fetching remote revisions: %s", this, bulkRevs);

        if (!canBulkGet) {
            pullBulkWithAllDocs(bulkRevs);
            return;
        }

        Log.v(TAG, "%s: POST _bulk_get", this);
        final List<RevisionInternal> remainingRevs = new ArrayList<RevisionInternal>(bulkRevs);

        ++httpConnectionCount;

        final RemoteBulkDownloaderRequest downloader;
        try {
            downloader = new RemoteBulkDownloaderRequest(
                    clientFactory,
                    remote,
                    true,
                    bulkRevs,
                    db,
                    this.requestHeaders,
                    new RemoteBulkDownloaderRequest.BulkDownloaderDocument() {
                        public void onDocument(Map<String, Object> props, long size) {
                            // Got a revision!
                            // Find the matching revision in 'remainingRevs' and get its sequence:
                            RevisionInternal rev;
                            if (props.get("_id") != null) {
                                rev = new RevisionInternal(props, size);
                            } else {
                                rev = new RevisionInternal((String) props.get("id"),
                                        (String) props.get("rev"), false);
                            }

                            int pos = remainingRevs.indexOf(rev);
                            if (pos > -1) {
                                rev.setSequence(remainingRevs.get(pos).getSequence());
                                remainingRevs.remove(pos);
                            } else {
                                Log.w(TAG, "%s : Received unexpected rev rev", this);
                            }

                            if (props.get("_id") != null) {
                                // Add to batcher ... eventually it will be fed to -insertRevisions:.
                                queueDownloadedRevision(rev);
                            } else {
                                Status status = statusFromBulkDocsResponseItem(props);
                                Throwable err = new CouchbaseLiteException(status);
                                revisionFailed(rev, err);
                            }
                        }
                    },
                    new RemoteRequestCompletion() {
                        public void onCompletion(RemoteRequest remoteRequest, Response httpResponse, Object result, Throwable e) {
                            // The entire _bulk_get is finished:
                            if (e != null) {
                                setError(e);
                                completedChangesCount.addAndGet(remainingRevs.size());
                            }
                            --httpConnectionCount;
                            // Start another task if there are still revisions waiting to be pulled:
                            pullRemoteRevisions();

                            if (cancellables != null && cancellables.values() != null && remoteRequest != null)
                                cancellables.values().remove(remoteRequest);
                        }
                    }
            );
        } catch (Exception e) {
            Log.e(TAG, "%s: pullBulkRevisions Exception: %s", this, e);
            return;
        }

        downloader.setAuthenticator(getAuthenticator());
        // set compressed request - gzip
        downloader.setCompressedRequest(canSendCompressedRequests());

        synchronized (remoteRequestExecutor) {
            if (!remoteRequestExecutor.isShutdown()) {
                Future future = remoteRequestExecutor.submit(downloader);
                pendingFutures.add(future);
                cancellables.put(future, downloader);
            }
        }
    }
300013
def get_branches(self):
        
        return github.PaginatedList.PaginatedList(
            github.Branch.Branch,
            self._requester,
            self.url + "/branches",
            None
        )
1121471
def _get_upstream(self):
    """"""
    if not self._remote or not self._branch:
      branch = self.branch_name
      if not branch:
        raise Scm.LocalException('Failed to determine local branch')

      def get_local_config(key):
        value = self._check_output(['config', '--local', '--get', key],
                                   raise_type=Scm.LocalException)
        return value.strip()

      self._remote = self._remote or get_local_config('branch.{}.remote'.format(branch))
      self._branch = self._branch or get_local_config('branch.{}.merge'.format(branch))
    return self._remote, self._branch
298628
def refs(self):
        
        out_refs = IterableList(RemoteReference._id_attribute_, "%s/" % self.name)
        out_refs.extend(RemoteReference.list_items(self.repo, remote=self.name))
        return out_refs
831097
def get_git_refs(repopath):
    
    tags = []
    branches = []
    branch = ''
    files_modifed = []

    if os.path.isfile(repopath):
        repopath = os.path.dirname(repopath)

    try:

        git = programs.find_program('git')

        # Files modified
        out, err = programs.run_program(
            git, ['status', '-s'],
            cwd=repopath,
        ).communicate()

        if PY3:
            out = out.decode(sys.getdefaultencoding())
        files_modifed = [line.strip() for line in out.split('\n') if line]

        # Tags
        out, err = programs.run_program(
            git, ['tag'],
            cwd=repopath,
        ).communicate()

        if PY3:
            out = out.decode(sys.getdefaultencoding())
        tags = [line.strip() for line in out.split('\n') if line]

        # Branches
        out, err = programs.run_program(
            git, ['branch', '-a'],
            cwd=repopath,
        ).communicate()

        if PY3:
            out = out.decode(sys.getdefaultencoding())

        lines = [line.strip() for line in out.split('\n') if line]
        for line in lines:
            if line.startswith('*'):
                line = line.replace('*', '').strip()
                branch = line

            branches.append(line)

    except (subprocess.CalledProcessError, AttributeError, OSError):
        pass

    return branches + tags, branch, files_modifed
1041716
def fetch_all(options = {})
      options = { :prune => false }.merge(options)
      git_args = ['--all']
      git_args << '--prune' if options[:prune]
      fetch(git_args)
      fetch('--tags')  # need a separate call for tags or else you don't get all the tags
      true
    end
547960
private function fetchAllFilesUnderGit()
  {
    $command = "git ls-files";
    exec($command, $output, $return);
    if ($return!=0) $this->logError("Can not execute command %s in exec", $command);

    foreach ($output as $filename)
    {
      $this->myLastCommitTimes[$filename] = 0;
    }
  }
116419
def get_relative_to_remote(self):
        
        s = self.git("status", "--short", "-b")[0]
        r = re.compile("\[([^\]]+)\]")
        toks = r.findall(s)
        if toks:
            try:
                s2 = toks[-1]
                adj, n = s2.split()
                assert(adj in ("ahead", "behind"))
                n = int(n)
                return -n if adj == "behind" else n
            except Exception as e:
                raise ReleaseVCSError(
                    ("Problem parsing first line of result of 'git status "
                     "--short -b' (%s):\n%s") % (s, str(e)))
        else:
            return 0
1301433
def pull_all_repos():
    """"""
    repos = ClonedRepo.objects.all()
    for repo in repos:
        if repo.origin is not None:
            pull_repo.delay(repo_name=repo.name)
1035150
def find_branches_raw(self):
        """"""
        listing = self.context.capture('git', 'for-each-ref', '--format=%(refname)\t%(objectname)')
        for line in listing.splitlines():
            match = FOR_EACH_REF_PATTERN.match(line)
            if match and match.group('name') != 'HEAD':
                yield (match.group('prefix'),
                       match.group('name'),
                       match.group('revision_id'))
241395
def get_git_ref(self, ref):
        
        prefix = "/git/refs/"
        if not self._requester.FIX_REPO_GET_GIT_REF:
            prefix = "/git/"
        assert isinstance(ref, (str, unicode)), ref
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + prefix + ref
        )
        return github.GitRef.GitRef(self._requester, headers, data, completed=True)
867300
def _get_branches(self, closed=False):
        

        if self._empty:
            return {}

        def _branchtags(localrepo):
            """
            Patched version of mercurial branchtags to not return the closed
            branches

            :param localrepo: locarepository instance
            """

            bt = {}
            bt_closed = {}
            for bn, heads in localrepo.branchmap().iteritems():
                tip = heads[-1]
                if 'close' in localrepo.changelog.read(tip)[5]:
                    bt_closed[bn] = tip
                else:
                    bt[bn] = tip

            if closed:
                bt.update(bt_closed)
            return bt

        sortkey = lambda ctx: ctx[0]  # sort by name
        _branches = [(safe_unicode(n), hex(h),) for n, h in
                     _branchtags(self._repo).items()]

        return OrderedDict(sorted(_branches, key=sortkey, reverse=False))
784283
def smart_pull(self):
        
        branch = self.get_current_branch_name()

        self.git_exec(['fetch', self.remote.name])

        return self.smart_merge('{0}/{1}'.format(self.remote.name, branch),
                                self.smart_merge_enabled())
62913
def checkout_with_fetch(git_folder, refspec, repository="origin"):
    
    _LOGGER.info("Trying to fetch and checkout %s", refspec)
    repo = Repo(str(git_folder))
    repo.git.fetch(repository, refspec)  # FETCH_HEAD should be set
    repo.git.checkout("FETCH_HEAD")
    _LOGGER.info("Fetch and checkout success for %s", refspec)
1302870
def fetch(name = remote.name)
      logger.info 'Fetching the latest changes from the server'
      output = self.command(:fetch, ['-p', name])

      log_fetch_changes(fetch_changes(output))

      return output
    end
273354
def clean_stale_refs(self, local_refs=None):  # pylint: disable=arguments-differ
        '''
        
        '''
        try:
            if pygit2.GIT_FETCH_PRUNE:
                # Don't need to clean anything, pygit2 can do it by itself
                return []
        except AttributeError:
            # However, only in 0.26.2 and newer
            pass
        if self.credentials is not None:
            log.debug(
                'The installed version of pygit2 (%s) does not support '
                'detecting stale refs for authenticated remotes, saltenvs '
                'will not reflect branches/tags removed from remote \'%s\'',
                PYGIT2_VERSION, self.id
            )
            return []
        return super(Pygit2, self).clean_stale_refs()