subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Sperling <s...@elego.de>
Subject Re: [PATCH] Remove unnecessary code in libsvn_ra_git
Date Wed, 11 Jun 2014 07:58:56 GMT
On Tue, Jun 10, 2014 at 04:55:47PM +0200, Carlos Martín Nieto wrote:
> Hi,
> 
> stsp mentioned that this code might actually be useful for externals
> that are kept in Git, so I've been looking more closely at the code and
> found a quick fix I could make.
> 
> [[[
> On the 'ra-git' branch: Remove unnecessary code in libsvn_ra_git
> 
> * subversion/libsvn_ra_git/ra_plugin.c
>   (do_git_fetch): no need for explicit connect before fetching
>   (svn_ra_git__stat): look up the bob/tree as a generic object, which is
>   what map_obj_to_direct() wants.
> ]]]
> 
> Cheers,
>    cmn

> Index: subversion/libsvn_ra_git/ra_plugin.c
> ===================================================================
> --- subversion/libsvn_ra_git/ra_plugin.c	(revision 1601633)
> +++ subversion/libsvn_ra_git/ra_plugin.c	(working copy)
> @@ -203,13 +203,6 @@ do_git_fetch(svn_ra_git__session_baton_t *sess)
>    if (sess->fetch_done)
>      return SVN_NO_ERROR;
>  
> -  if (!git_remote_connected(sess->remote))
> -    {
> -      git_err = git_remote_connect(sess->remote, GIT_DIRECTION_FETCH);
> -      if (git_err)
> -        return svn_error_trace(svn_ra_git__wrap_git_error());
> -    }
> -
>    SVN_DBG(("fetching from %s\n", git_remote_url(sess->remote)));
>  
>    git_err = git_remote_fetch(sess->remote);
> @@ -1974,11 +1967,10 @@ svn_ra_git__stat(svn_ra_session_t *session,
>          }
>  
>        type = git_tree_entry_type(entry);
> -      if (type == GIT_OBJ_TREE) 
> -        {
> -          git_tree *this_tree;
> -
> -          git_err = git_tree_lookup(&this_tree, sess->repos, git_tree_entry_id(entry));
> +      if (type == GIT_OBJ_TREE || type == GIT_OBJ_BLOB)
> +	{
> +	  git_object *object;
> +          git_err = git_object_lookup(&object, sess->repos, git_tree_entry_id(entry),
type);

We usually put a blank line between variable declarations and code.
Also, we don't use tabs for indentation. You might find this useful:
https://svn.apache.org/repos/asf/subversion/trunk/tools/dev/svn-dev.el

The above should have been intended like this (using spaces, not tabs):

> +      if (type == GIT_OBJ_TREE || type == GIT_OBJ_BLOB)
> +        {
> +          git_object *object;


>            if (git_err)
>              {
>                git_tree_entry_free(entry);
> @@ -1989,25 +1981,9 @@ svn_ra_git__stat(svn_ra_session_t *session,
>              }
>  
>            SVN_ERR(map_obj_to_dirent(dirent, sess->revmap, path, revision, SVN_DIRENT_ALL,
> -                                    sess->repos, commit, (git_object *)this_tree,
pool));
> -          git_tree_free(this_tree);
> -        }
> -      else if (type == GIT_OBJ_BLOB)
> -        {
> -          git_blob *blob;
> -
> -          git_err = git_blob_lookup(&blob, sess->repos, git_tree_entry_id(entry));
> -          if (git_err)
> -            {
> -              git_tree_free(tree);
> -              git_commit_free(commit);
> -              return svn_error_trace(svn_ra_git__wrap_git_error());
> -            }
> -
> -          SVN_ERR(map_obj_to_dirent(dirent, sess->revmap, path, revision, SVN_DIRENT_ALL,
> -                                    sess->repos, commit, (git_object *)blob, pool));
> -          git_blob_free(blob);
> -        }
> +                                    sess->repos, commit, object, pool));
> +          git_object_free(object);
> +	}

Tab here, too.

I've resolved these formatting issues and committed your changes as r1601823.

Thanks!

>        else
>          {
>            git_tree_entry_free(entry);


Mime
View raw message