Server IP : 103.119.228.120 / Your IP : 3.144.89.152 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/share/doc/git-1.8.3.1/contrib/ |
Upload File : |
#!/bin/sh USAGE="[-a] [-r] [-m] [-t] [-n] [-b <newname>] <name>" LONG_USAGE="git-resurrect attempts to find traces of a branch tip called <name>, and tries to resurrect it. Currently, the reflog is searched for checkout messages, and with -r also merge messages. With -m and -t, the history of all refs is scanned for Merge <name> into other/Merge <other> into <name> (respectively) commit subjects, which is rather slow but allows you to resurrect other people's topic branches." OPTIONS_KEEPDASHDASH= OPTIONS_SPEC="\ git resurrect $USAGE -- b,branch= save branch as <newname> instead of <name> a,all same as -l -r -m -t k,keep-going full rev-list scan (instead of first match) l,reflog scan reflog for checkouts (enabled by default) r,reflog-merges scan for merges recorded in reflog m,merges scan for merges into other branches (slow) t,merge-targets scan for merges of other branches into <name> n,dry-run don't recreate the branch" . git-sh-setup search_reflog () { sed -ne 's~^\([^ ]*\) .*\tcheckout: moving from '"$1"' .*~\1~p' \ < "$GIT_DIR"/logs/HEAD } search_reflog_merges () { git rev-parse $( sed -ne 's~^[^ ]* \([^ ]*\) .*\tmerge '"$1"':.*~\1^2~p' \ < "$GIT_DIR"/logs/HEAD ) } _x40="[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]" _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" search_merges () { git rev-list --all --grep="Merge branch '$1'" \ --pretty=tformat:"%P %s" | sed -ne "/^$_x40 \($_x40\) Merge .*/ {s//\1/p;$early_exit}" } search_merge_targets () { git rev-list --all --grep="Merge branch '[^']*' into $branch\$" \ --pretty=tformat:"%H %s" --all | sed -ne "/^\($_x40\) Merge .*/ {s//\1/p;$early_exit} " } dry_run= early_exit=q scan_reflog=t scan_reflog_merges= scan_merges= scan_merge_targets= new_name= while test "$#" != 0; do case "$1" in -b|--branch) shift new_name="$1" ;; -n|--dry-run) dry_run=t ;; --no-dry-run) dry_run= ;; -k|--keep-going) early_exit= ;; --no-keep-going) early_exit=q ;; -m|--merges) scan_merges=t ;; --no-merges) scan_merges= ;; -l|--reflog) scan_reflog=t ;; --no-reflog) scan_reflog= ;; -r|--reflog_merges) scan_reflog_merges=t ;; --no-reflog_merges) scan_reflog_merges= ;; -t|--merge-targets) scan_merge_targets=t ;; --no-merge-targets) scan_merge_targets= ;; -a|--all) scan_reflog=t scan_reflog_merges=t scan_merges=t scan_merge_targets=t ;; --) shift break ;; *) usage ;; esac shift done test "$#" = 1 || usage all_strategies="$scan_reflog$scan_reflog_merges$scan_merges$scan_merge_targets" if test -z "$all_strategies"; then die "must enable at least one of -lrmt" fi branch="$1" test -z "$new_name" && new_name="$branch" if test ! -z "$scan_reflog"; then if test -r "$GIT_DIR"/logs/HEAD; then candidates="$(search_reflog $branch)" else die 'reflog scanning requested, but' \ '$GIT_DIR/logs/HEAD not readable' fi fi if test ! -z "$scan_reflog_merges"; then if test -r "$GIT_DIR"/logs/HEAD; then candidates="$candidates $(search_reflog_merges $branch)" else die 'reflog scanning requested, but' \ '$GIT_DIR/logs/HEAD not readable' fi fi if test ! -z "$scan_merges"; then candidates="$candidates $(search_merges $branch)" fi if test ! -z "$scan_merge_targets"; then candidates="$candidates $(search_merge_targets $branch)" fi candidates="$(git rev-parse $candidates | sort -u)" if test -z "$candidates"; then hint= test "z$all_strategies" != "ztttt" \ && hint=" (maybe try again with -a)" die "no candidates for $branch found$hint" fi echo "** Candidates for $branch **" for cmt in $candidates; do git --no-pager log --pretty=tformat:"%ct:%h [%cr] %s" --abbrev-commit -1 $cmt done \ | sort -n | cut -d: -f2- newest="$(git rev-list -1 $candidates)" if test ! -z "$dry_run"; then printf "** Most recent: " git --no-pager log -1 --pretty=tformat:"%h %s" $newest elif ! git rev-parse --verify --quiet $new_name >/dev/null; then printf "** Restoring $new_name to " git --no-pager log -1 --pretty=tformat:"%h %s" $newest git branch $new_name $newest else printf "Most recent: " git --no-pager log -1 --pretty=tformat:"%h %s" $newest echo "** $new_name already exists, doing nothing" fi