@@ -30,22 +30,36 @@ public function register(Doku_Event_Handler $controller) {
3030 $ controller ->register_hook ('DOKUWIKI_DONE ' , 'AFTER ' , $ this , 'handle_periodic_pull ' );
3131 }
3232
33- private function initRepo () {
34- //get path to the repo root (by default DokuWiki's savedir)
35- $ repoPath = GitBackedUtil::getEffectivePath ($ this ->getConf ('repoPath ' ));
33+ private function initRepo ($ initRepo =True , $ filePath ="" ) {
34+ if ($ initRepo ) {
35+ $ repoPath = GitBackedUtil::getEffectivePath ($ this ->getConf ('repoPath ' ));
36+ } else {
37+ $ repoPath = dirname ($ filePath );
38+ }
39+ //set the path to the git binary
3640 $ gitPath = trim ($ this ->getConf ('gitPath ' ));
3741 if ($ gitPath !== '' ) {
3842 Git::set_bin ($ gitPath );
3943 }
40- //init the repo and create a new one if it is not present
41- io_mkdir_p ($ repoPath );
42- $ repo = new GitRepo ($ repoPath , $ this , true , true );
44+ if ($ initRepo ) {
45+ //init the repo and create a new one if it is not present
46+ io_mkdir_p ($ repoPath );
47+ $ repo = new GitRepo ($ repoPath , $ this , true , true );
48+ } else {
49+ new GitRepo ($ repoPath , $ this , false , false );
50+ }
4351 //set git working directory (by default DokuWiki's savedir)
44- $ repoWorkDir = $ this ->getConf ('repoWorkDir ' );
45- if (!empty ($ repoWorkDir )) {
46- $ repoWorkDir = GitBackedUtil::getEffectivePath ($ repoWorkDir );
47- }
52+ if ($ initRepo ) {
53+ $ repoWorkDir = $ this ->getConf ('repoWorkDir ' );
54+ if (!empty ($ repoWorkDir )) {
55+ $ repoWorkDir = GitBackedUtil::getEffectivePath ($ repoWorkDir );
56+ }
57+ } else {
58+ $ repoWorkDir = "" ;
59+ }
60+
4861 Git::set_bin (empty ($ repoWorkDir ) ? Git::get_bin () : Git::get_bin ().' --work-tree ' .escapeshellarg ($ repoWorkDir ));
62+
4963 $ params = str_replace (
5064 array ('%mail% ' ,'%user% ' ),
5165 array ($ this ->getAuthorMail (),$ this ->getAuthor ()),
@@ -73,7 +87,12 @@ private function isIgnored($filePath) {
7387 private function commitFile ($ filePath ,$ message ) {
7488 if (!$ this ->isIgnored ($ filePath )) {
7589 try {
76- $ repo = $ this ->initRepo ();
90+ $ initRepo = $ this ->getConf ('initRepo ' );
91+ if ($ initRepo ) {
92+ $ repo = $ this ->initRepo ();
93+ } else {
94+ $ repo = $ this ->initRepo ($ initRepo , $ filePath );
95+ }
7796
7897 //add the changed file and set the commit message
7998 $ repo ->add ($ filePath );
0 commit comments