This file is indexed.

/usr/share/bibledit-gtk/conflict.php is in bibledit-gtk-data 4.9-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
<?php
/*
Copyright (©) 2003-2013 Teus Benschop.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
  
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
  
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/


/*

Note: This object should not call other objects within the Bibledit-Web source,
because this object is also called from Bibledit-Gtk, and does not have access
to those other objects.
Calling other objects would result in faral errors that break Bibledit-Gtk.

*/


class Filter_Conflict
{

  // This function resolves any conflicts in a git repository.
  // $repository: Path to the repository.
  public static function run ($repository)
  {
    $unmerged_paths = Filter_Conflict::getUnmergedPaths ($repository);
    foreach ($unmerged_paths as $path) {
      Filter_Conflict::mergeUnmergedPath ($repository, $path);
    }
    if (count ($unmerged_paths)) {
      Filter_Conflict::commitMergedData ($repository);
    }
  }
  
  
  private static function getUnmergedPaths ($repository)
  {
    $unmerged_paths = array ();
    $shellrepo = escapeshellarg ($repository);
    $command = "cd $shellrepo; git status 2>&1";
    exec ($command, $output, $exit_code);
    foreach ($output as $line) {
      if (strpos ($line, "both modified:") !== false) {
        $line = trim ($line);
        $line = substr ($line, 20);
        $line = trim ($line);
        $unmerged_paths [] = $line;
      }
    }
    return $unmerged_paths;
  }
  
  
  private static function mergeUnmergedPath ($repository, $path)
  {
    $shellrepo = escapeshellarg ($repository);

    $common_ancestor = uniqid (sys_get_temp_dir () . "/") . "ancestor";
    $argument = escapeshellarg (":1:$path");
    $command = "cd $shellrepo; git show $argument > $common_ancestor";
    exec ($command, $output, $exit_code);
    
    $head_version = uniqid (sys_get_temp_dir () . "/") . "head";
    $argument = escapeshellarg (":2:$path");
    $command = "cd $shellrepo; git show $argument > $head_version";
    exec ($command, $output, $exit_code);
    
    $merge_head_version = uniqid (sys_get_temp_dir () . "/") . "merge_head";
    $argument = escapeshellarg (":3:$path");
    $command = "cd $shellrepo; git show $argument > $merge_head_version";
    exec ($command, $output, $exit_code);

    $mergeBase = file_get_contents ($common_ancestor);
    $userData = file_get_contents ($head_version);
    $serverData = file_get_contents ($merge_head_version);
    
    $mergedData = Filter_Merge::run ($mergeBase, $userData, $serverData);
    
    file_put_contents ("$repository/$path", $mergedData);    

    unlink ($common_ancestor);
    unlink ($head_version);
    unlink ($merge_head_version);
  }
  
  
  private static function commitMergedData ($repository)
  {
    $shellrepo = escapeshellarg ($repository);
    $command = "cd $shellrepo; git commit -a -m FixMergeConflicts 2>&1";
    exec ($command, $output, $exit_code);
  }
  

}


?>