From: bob bazo <bbazso22_at_yahoo.ca>
Date: 2005-03-09 13:56:37 CET
I'm having a problem trying to get a simple example of the commit operation working using the client API.
Here is a part of the code that I'm currently debugging:
apr_array_header_t *targets = apr_array_make (pool, 1, sizeof (char *));
/* item is a const char* comming from my main program arguments */
(*((const char **) apr_array_push (targets))) = item;
ctx->log_msg_func = commit_log_callback;
/* log_entry is a const char* comming from my main program arguments - the log message */
ctx->log_msg_baton = (void *) log_entry;
err = svn_client_commit (&commit_info, targets, TRUE, ctx, pool);
if (err) handle_error (err);
printf ("revision %" SVN_REVNUM_T_FMT " committed at %s by %s\n", commit_info->revision, commit_info->date, commit_info->author);
I have implemented a log_msg_func and baton to take care of the log message that goes with the commit and I basically followed the examples in the Practical Subversion book. Please note that both ctx and pool in the small piece of code above have been declared and filled in correctly. I used the minimal_client.c (http://svn.collab.net/repos/svn/trunk/tools/examples) example for these and I've tested them with several other Subversion operations and they work fine.
I have also implemented a simple notification callback function that simply prints the path when it is called.
Now for the PROBLEM:
What happens with this code is that I have a small main program commiting a single file (the repository is valid) to a repository. The program executes the code above and everything goes smoothly until it hits the svn_client_commit function. At this point, the file is actually committed to the file repository, the log message is correctly committed as well, I see that the notification callback function gets called back twice (once printing the repository path and the other time the actual path that I'm sending the file from - Is this normal?) and then the program crashes with a segmentation fault. The program never gets out of the svn_client_commit function. The repository remains in a Locked stated and I have to do a svn cleanup to get rid of this. Note that I do nothing with commit_info.
Note: if I try this operation while the repository is locked or the file in the repository is out of date then I actually do get an error message back from the svn_client_commit function and I do not get a segmentation fault.
In order to verify that the file was actually committed, I did and update and on a remote PC I did a checkout and both had the newly committed file and the correct log message.
Therefore to summarize, the commit actually works but the program crashes just after. The svn_client_commit function does not return an error.
Any help concerning this matter would be greatly appreciated.
Thank you in advance,
This is an archived mail posted to the Subversion Dev mailing list.