[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: use NULL commit callback in svn_repos_get_commit_editor5?

From: David Glasser <glasser_at_davidglasser.net>
Date: Wed, 4 Jun 2008 23:03:35 -0700

On Wed, Jun 4, 2008 at 10:24 PM, Karl Fogel <kfogel_at_red-bean.com> wrote:
> Neels Janosch Hofmeyr <neels_at_elego.de> writes:
>> I see that it is mandatory to pass a non-NULL commit callback function
>> for svn_repos_get_commit_editor5, since otherwise a
>> editor->close_edit(..) aborts with a segmentation fault :(
>>
>> Writing a C test, I just wanted nothing to happen when the commit is
>> done, but still had to write a dummy commit callback that does nothing
>> to avoid the segmentation fault.
>>
>> Am I not getting something?
>
> I think it would be an improvement to the API to allow the callback to
> be NULL, sure. Does the (completely untested) patch below work?

I dunno, but looking at the original code it looks like there's an
error leak if either svn_fs_revision_prop call fails. And the call to
svn_error_clear(err), as well as the final "return err;", seem wrong,
since err should be guaranteed to be SVN_NO_ERROR by that point. Am I
missing something?

--dave

> [[[
> Improve an API by allowing a callback to be null.
>
> Suggested by: Neels Janosch Hofmeyr <neels_at_elego.de>
>
> * subversion/include/svn_repos.h
> (svn_repos_get_commit_editor5): Document that callback can be null.
> Also, fix up some obsolete documentation: the modern callback type
> takes a struct instead of separate parameters.
>
> * subversion/libsvn_repos/commit.c
> (close_edit): Test callback before calling.
> ]]]
>
> Index: subversion/include/svn_repos.h
> ===================================================================
> --- subversion/include/svn_repos.h (revision 31587)
> +++ subversion/include/svn_repos.h (working copy)
> @@ -938,15 +938,16 @@
> * due to authz will return SVN_ERR_AUTHZ_UNREADABLE or
> * SVN_ERR_AUTHZ_UNWRITABLE.
> *
> - * Calling @a (*editor)->close_edit completes the commit. Before
> - * @c close_edit returns, but after the commit has succeeded, it will
> - * invoke @a callback with the new revision number, the commit date (as a
> - * <tt>const char *</tt>), commit author (as a <tt>const char *</tt>), and
> - * @a callback_baton as arguments. If @a callback returns an error, that
> - * error will be returned from @c close_edit, otherwise if there was a
> - * post-commit hook failure, then that error will be returned and will
> - * have code SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED.
> + * Calling @a (*editor)->close_edit completes the commit.
> *
> + * If @a callback is non-NULL, then before @c close_edit returns (but
> + * after the commit has succeeded) @c close_edit will invoke
> + * @a callback with a filled-in @c svn_commit_info_t *, @a callback_baton,
> + * and @a pool or some subpool thereof as arguments. If @a callback
> + * returns an error, that error will be returned from @c close_edit,
> + * otherwise if there was a post-commit hook failure, then that error
> + * will be returned with code SVN_ERR_REPOS_POST_COMMIT_HOOK_FAILED.
> + *
> * Calling @a (*editor)->abort_edit aborts the commit, and will also
> * abort the commit transaction unless @a txn was supplied (not @c
> * NULL). Callers who supply their own transactions are responsible
> Index: subversion/libsvn_repos/commit.c
> ===================================================================
> --- subversion/libsvn_repos/commit.c (revision 31587)
> +++ subversion/libsvn_repos/commit.c (working copy)
> @@ -713,7 +713,7 @@
> new_revision, SVN_PROP_REVISION_AUTHOR,
> pool);
>
> - if (! err2)
> + if (eb->commit_callback && (! err2))
> {
> commit_info = svn_create_commit_info(pool);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
> For additional commands, e-mail: dev-help_at_subversion.tigris.org
>
>

-- 
David Glasser | glasser@davidglasser.net | http://www.davidglasser.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-06-05 08:04:15 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.