Created
November 25, 2011 09:05
-
-
Save yesmeck/1393094 to your computer and use it in GitHub Desktop.
Git lost found.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
if (!isset($_SERVER['argv'][1])) { | |
exit('参数错误'); | |
} | |
$search = $_SERVER['argv'][1]; | |
$output = shell_exec('git fsck --lost-found | grep commit'); | |
$lines = explode("\n", $output); | |
foreach($lines as $line) { | |
$info = explode(' ', $line); | |
if(isset($info[2])) { | |
$hash = $info[2]; | |
$output = shell_exec('git show ' . $hash); | |
if(strpos($output, $search) !== FALSE) { | |
echo $line . "\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment