#!/bin/sh global USAGE := '"[-a] [-r] [-m] [-t] [-n] [-b ] '" global LONG_USAGE := '"git-resurrect attempts to find traces of a branch tip called , 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 into other/Merge into (respectively) commit subjects, which is rather slow but allows you to resurrect other people's topic branches.'" global OPTIONS_KEEPDASHDASH := '' global OPTIONS_STUCKLONG := '' global OPTIONS_SPEC := ""\ git resurrect $USAGE -- b,branch= save branch as instead of 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 n,dry-run don't recreate the branch"" source git-sh-setup proc search_reflog { sed -ne 's~^\([^ ]*\) .*\tcheckout: moving from '"$1"' .*~\1~p' \ < "$GIT_DIR"/logs/HEAD } proc search_reflog_merges { git rev-parse $[ sed -ne 's~^[^ ]* \([^ ]*\) .*\tmerge '"$1"':.*~\1^2~p' \ < "$GIT_DIR"/logs/HEAD] } global _x40 := '"[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'" global _x40 := ""$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"" proc search_merges { git rev-list --all --grep="Merge branch '$1'" \ --pretty=tformat:"%P %s" | sed -ne "/^$_x40 \($_x40\) Merge .*/ {s//\1/p;$early_exit}" } proc 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} " } global dry_run := '' global early_exit := 'q' global scan_reflog := 't' global scan_reflog_merges := '' global scan_merges := '' global scan_merge_targets := '' global new_name := '' while test "$#" != 0 { matchstr $1 { -b|--branch { shift global new_name := $1 } -n|--dry-run { global dry_run := 't' } --no-dry-run { global dry_run := '' } -k|--keep-going { global early_exit := '' } --no-keep-going { global early_exit := 'q' } -m|--merges { global scan_merges := 't' } --no-merges { global scan_merges := '' } -l|--reflog { global scan_reflog := 't' } --no-reflog { global scan_reflog := '' } -r|--reflog_merges { global scan_reflog_merges := 't' } --no-reflog_merges { global scan_reflog_merges := '' } -t|--merge-targets { global scan_merge_targets := 't' } --no-merge-targets { global scan_merge_targets := '' } -a|--all { global scan_reflog := 't' global scan_reflog_merges := 't' global scan_merges := 't' global scan_merge_targets := 't' } -- { shift break } * { usage } } shift } test "$Argc" = 1 || usage global all_strategies := ""$scan_reflog$scan_reflog_merges$scan_merges$scan_merge_targets"" if test -z $all_strategies { die "must enable at least one of -lrmt" } global branch := $1 test -z $new_name && global new_name := $branch if test ! -z $scan_reflog { if test -r "$GIT_DIR"/logs/HEAD { global candidates := $[search_reflog $branch] } else { die 'reflog scanning requested, but' \ '$GIT_DIR/logs/HEAD not readable' } } if test ! -z $scan_reflog_merges { if test -r "$GIT_DIR"/logs/HEAD { global candidates := ""$candidates $[search_reflog_merges $branch]"" } else { die 'reflog scanning requested, but' \ '$GIT_DIR/logs/HEAD not readable' } } if test ! -z $scan_merges { global candidates := ""$candidates $[search_merges $branch]"" } if test ! -z $scan_merge_targets { global candidates := ""$candidates $[search_merge_targets $branch]"" } global candidates := $[git rev-parse $candidates | sort -u] if test -z $candidates { global hint := '' test "z$all_strategies" != "ztttt" \ && global hint := '" (maybe try again with -a)'" die "no candidates for $branch found$hint" } echo "** Candidates for $branch **" for cmt in [$candidates] { git --no-pager log --pretty=tformat:"%ct:%h [%cr] %s" --abbrev-commit -1 $cmt } \ | sort -n | cut -d: -f2- global newest := $[git rev-list -1 $candidates] if test ! -z $dry_run { printf "** Most recent: " git --no-pager log -1 --pretty=tformat:"%h %s" $newest } elif ! git rev-parse --verify --quiet $new_name >/dev/null { 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" } (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:USAGE) op: Equal rhs: {(DQ ("[-a] [-r] [-m] [-t] [-n] [-b ] "))} spids: [4] ) ] spids: [4] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LONG_USAGE) op: Equal rhs: { (DQ ("git-resurrect attempts to find traces of a branch tip\n") ("called , and tries to resurrect it. Currently, the reflog is\n") ("searched for checkout messages, and with -r also merge messages. With\n") ("-m and -t, the history of all refs is scanned for Merge into\n") ("other/Merge into (respectively) commit subjects, which\n") ("is rather slow but allows you to resurrect other people's topic\n") (branches.) ) } spids: [9] ) ] spids: [9] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:OPTIONS_KEEPDASHDASH) op:Equal rhs:{(SQ )} spids:[21])] spids: [21] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:OPTIONS_STUCKLONG) op:Equal rhs:{(SQ )} spids:[23])] spids: [23] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:OPTIONS_SPEC) op: Equal rhs: { (DQ ("git resurrect ") ($ VSub_Name "$USAGE") ("\n") ("--\n") ("b,branch= save branch as instead of \n") ("a,all same as -l -r -m -t\n") ("k,keep-going full rev-list scan (instead of first match)\n") ("l,reflog scan reflog for checkouts (enabled by default)\n") ("r,reflog-merges scan for merges recorded in reflog\n") ("m,merges scan for merges into other branches (slow)\n") ("t,merge-targets scan for merges of other branches into \n") ("n,dry-run don't recreate the branch") ) } spids: [25] ) ] spids: [25] ) (C {(.)} {(git-sh-setup)}) (FuncDef name: search_reflog body: (BraceGroup children: [ (SimpleCommand words: [ {(sed)} {(-ne)} {(SQ <"s~^\\([^ ]*\\) .*\\tcheckout: moving from ">) (DQ ($ VSub_Number "$1")) (SQ <" .*~\\1~p">) } ] redirects: [ (Redir op_id: Redir_Less fd: -1 arg_word: {(DQ ($ VSub_Name "$GIT_DIR")) (/logs/HEAD)} spids: [72] ) ] ) ] spids: [53] ) spids: [48 52] ) (FuncDef name: search_reflog_merges body: (BraceGroup children: [ (C {(git)} {(rev-parse)} { (CommandSubPart command_list: (CommandList children: [ (SimpleCommand words: [ {(sed)} {(-ne)} {(SQ <"s~^[^ ]* \\([^ ]*\\) .*\\tmerge ">) (DQ ($ VSub_Number "$1")) (SQ <":.*~\\1^2~p">) } ] redirects: [ (Redir op_id: Redir_Less fd: -1 arg_word: {(DQ ($ VSub_Name "$GIT_DIR")) (/logs/HEAD)} spids: [113] ) ] ) ] ) left_token: spids: [94 121] ) } ) ] spids: [87] ) spids: [82 86] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_x40) op: Equal rhs: {(DQ ("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]"))} spids: [126] ) ] spids: [126] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:_x40) op: Equal rhs: { (DQ ($ VSub_Name "$_x40") ($ VSub_Name "$_x40") ($ VSub_Name "$_x40") ($ VSub_Name "$_x40") ($ VSub_Name "$_x40") ($ VSub_Name "$_x40") ($ VSub_Name "$_x40") ($ VSub_Name "$_x40") ) } spids: [131] ) ] spids: [131] ) (FuncDef name: search_merges body: (BraceGroup children: [ (Pipeline children: [ (C {(git)} {(rev-list)} {(--all)} {(--grep) (Lit_Other "=") (DQ ("Merge branch '") ($ VSub_Number "$1") ("'"))} {(--pretty) (Lit_Other "=") (tformat) (Lit_Other ":") (DQ ("%P %s"))} ) (C {(sed)} {(-ne)} { (DQ ("/^") ($ VSub_Name "$_x40") (" ") (EscapedLiteralPart token:) ($ VSub_Name "$_x40") (EscapedLiteralPart token:) (" Merge .*/ {s//") (EscapedLiteralPart token:) ("/p;") ($ VSub_Name "$early_exit") ("}") ) } ) ] negated: False ) ] spids: [149] ) spids: [144 148] ) (FuncDef name: search_merge_targets body: (BraceGroup children: [ (Pipeline children: [ (C {(git)} {(rev-list)} {(--all)} {(--grep) (Lit_Other "=") (DQ ("Merge branch '[^']*' into ") ($ VSub_Name "$branch") (EscapedLiteralPart token:) ) } {(--pretty) (Lit_Other "=") (tformat) (Lit_Other ":") (DQ ("%H %s"))} {(--all)} ) (C {(sed)} {(-ne)} { (DQ ("/^") (EscapedLiteralPart token:) ($ VSub_Name "$_x40") (EscapedLiteralPart token:) (" Merge .*/ {s//") (EscapedLiteralPart token:) ("/p;") ($ VSub_Name "$early_exit") ("} ") ) } ) ] negated: False ) ] spids: [205] ) spids: [200 204] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:dry_run) op:Equal rhs:{(SQ )} spids:[256])] spids: [256] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:early_exit) op:Equal rhs:{(q)} spids:[258])] spids: [258] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:scan_reflog) op:Equal rhs:{(t)} spids:[261])] spids: [261] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:scan_reflog_merges) op:Equal rhs:{(SQ )} spids:[264])] spids: [264] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:scan_merges) op:Equal rhs:{(SQ )} spids:[266])] spids: [266] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:scan_merge_targets) op:Equal rhs:{(SQ )} spids:[268])] spids: [268] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:new_name) op:Equal rhs:{(SQ )} spids:[270])] spids: [270] ) (While cond: [ (Sentence child: (C {(test)} {(DQ ($ VSub_Pound "$#"))} {(KW_Bang "!") (Lit_Other "=")} {(0)}) terminator: ) ] body: (DoGroup children: [ (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list: [{(-b)} {(--branch)}] action: [ (C {(shift)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:new_name) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [308] ) ] spids: [308] ) ] spids: [299 302 314 -1] ) (case_arm pat_list: [{(-n)} {(--dry-run)}] action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:dry_run) op:Equal rhs:{(t)} spids:[323])] spids: [323] ) ] spids: [317 320 327 -1] ) (case_arm pat_list: [{(--no-dry-run)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:dry_run) op: Equal rhs: {(SQ )} spids: [334] ) ] spids: [334] ) ] spids: [330 331 337 -1] ) (case_arm pat_list: [{(-k)} {(--keep-going)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:early_exit) op: Equal rhs: {(SQ )} spids: [346] ) ] spids: [346] ) ] spids: [340 343 349 -1] ) (case_arm pat_list: [{(--no-keep-going)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:early_exit) op: Equal rhs: {(q)} spids: [356] ) ] spids: [356] ) ] spids: [352 353 360 -1] ) (case_arm pat_list: [{(-m)} {(--merges)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_merges) op: Equal rhs: {(t)} spids: [369] ) ] spids: [369] ) ] spids: [363 366 373 -1] ) (case_arm pat_list: [{(--no-merges)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_merges) op: Equal rhs: {(SQ )} spids: [380] ) ] spids: [380] ) ] spids: [376 377 383 -1] ) (case_arm pat_list: [{(-l)} {(--reflog)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_reflog) op: Equal rhs: {(t)} spids: [392] ) ] spids: [392] ) ] spids: [386 389 396 -1] ) (case_arm pat_list: [{(--no-reflog)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_reflog) op: Equal rhs: {(SQ )} spids: [403] ) ] spids: [403] ) ] spids: [399 400 406 -1] ) (case_arm pat_list: [{(-r)} {(--reflog_merges)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_reflog_merges) op: Equal rhs: {(t)} spids: [415] ) ] spids: [415] ) ] spids: [409 412 419 -1] ) (case_arm pat_list: [{(--no-reflog_merges)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_reflog_merges) op: Equal rhs: {(SQ )} spids: [426] ) ] spids: [426] ) ] spids: [422 423 429 -1] ) (case_arm pat_list: [{(-t)} {(--merge-targets)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_merge_targets) op: Equal rhs: {(t)} spids: [438] ) ] spids: [438] ) ] spids: [432 435 442 -1] ) (case_arm pat_list: [{(--no-merge-targets)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_merge_targets) op: Equal rhs: {(SQ )} spids: [449] ) ] spids: [449] ) ] spids: [445 446 452 -1] ) (case_arm pat_list: [{(-a)} {(--all)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_reflog) op: Equal rhs: {(t)} spids: [461] ) ] spids: [461] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_reflog_merges) op: Equal rhs: {(t)} spids: [465] ) ] spids: [465] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_merges) op: Equal rhs: {(t)} spids: [469] ) ] spids: [469] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:scan_merge_targets) op: Equal rhs: {(t)} spids: [473] ) ] spids: [473] ) ] spids: [455 458 477 -1] ) (case_arm pat_list: [{(--)}] action: [(C {(shift)}) (ControlFlow token:)] spids: [480 481 490 -1] ) (case_arm pat_list: [{(Lit_Other "*")}] action: [(C {(usage)})] spids: [493 494 500 -1] ) ] spids: [290 296 503] ) (C {(shift)}) ] spids: [287 508] ) ) (AndOr children: [(C {(test)} {(DQ ($ VSub_Pound "$#"))} {(Lit_Other "=")} {(1)}) (C {(usage)})] op_id: Op_DPipe ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:all_strategies) op: Equal rhs: { (DQ ($ VSub_Name "$scan_reflog") ($ VSub_Name "$scan_reflog_merges") ($ VSub_Name "$scan_merges") ($ VSub_Name "$scan_merge_targets") ) } spids: [526] ) ] spids: [526] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-z)} {(DQ ($ VSub_Name "$all_strategies"))}) terminator: ) ] action: [(C {(die)} {(DQ ("must enable at least one of -lrmt"))})] spids: [-1 545] ) ] spids: [-1 554] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:branch) op: Equal rhs: {(DQ ($ VSub_Number "$1"))} spids: [557] ) ] spids: [557] ) (AndOr children: [ (C {(test)} {(-z)} {(DQ ($ VSub_Name "$new_name"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:new_name) op: Equal rhs: {(DQ ($ VSub_Name "$branch"))} spids: [572] ) ] spids: [572] ) ] op_id: Op_DAmp ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(KW_Bang "!")} {(-z)} {(DQ ($ VSub_Name "$scan_reflog"))}) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-r)} {(DQ ($ VSub_Name "$GIT_DIR")) (/logs/HEAD)}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:candidates) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [(C {(search_reflog)} {($ VSub_Name "$branch")})] ) left_token: spids: [611 615] ) ) } spids: [609] ) ] spids: [609] ) ] spids: [-1 606] ) ] else_action: [ (C {(die)} {(SQ <"reflog scanning requested, but">)} {(SQ <"$GIT_DIR/logs/HEAD not readable">)} ) ] spids: [619 635] ) ] spids: [-1 591] ) ] spids: [-1 637] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(KW_Bang "!")} {(-z)} {(DQ ($ VSub_Name "$scan_reflog_merges"))}) terminator: ) ] action: [ (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-r)} {(DQ ($ VSub_Name "$GIT_DIR")) (/logs/HEAD)}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:candidates) op: Equal rhs: { (DQ ($ VSub_Name "$candidates") (" ") (CommandSubPart command_list: (CommandList children: [(C {(search_reflog_merges)} {($ VSub_Name "$branch")})] ) left_token: spids: [674 678] ) ) } spids: [670] ) ] spids: [670] ) ] spids: [-1 667] ) ] else_action: [ (C {(die)} {(SQ <"reflog scanning requested, but">)} {(SQ <"$GIT_DIR/logs/HEAD not readable">)} ) ] spids: [682 698] ) ] spids: [-1 652] ) ] spids: [-1 700] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(KW_Bang "!")} {(-z)} {(DQ ($ VSub_Name "$scan_merges"))}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:candidates) op: Equal rhs: { (DQ ($ VSub_Name "$candidates") (" ") (CommandSubPart command_list: (CommandList children: [(C {(search_merges)} {($ VSub_Name "$branch")})] ) left_token: spids: [722 726] ) ) } spids: [718] ) ] spids: [718] ) ] spids: [-1 715] ) ] spids: [-1 729] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(KW_Bang "!")} {(-z)} {(DQ ($ VSub_Name "$scan_merge_targets"))}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:candidates) op: Equal rhs: { (DQ ($ VSub_Name "$candidates") (" ") (CommandSubPart command_list: (CommandList children: [(C {(search_merge_targets)} {($ VSub_Name "$branch")})] ) left_token: spids: [751 755] ) ) } spids: [747] ) ] spids: [747] ) ] spids: [-1 744] ) ] spids: [-1 758] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:candidates) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(git)} {(rev-parse)} {($ VSub_Name "$candidates")}) (C {(sort)} {(-u)}) ] negated: False ) ] ) left_token: spids: [763 775] ) ) } spids: [761] ) ] spids: [761] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(-z)} {(DQ ($ VSub_Name "$candidates"))}) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:hint) op:Equal rhs:{(SQ )} spids:[793])] spids: [793] ) (AndOr children: [ (C {(test)} {(DQ (z) ($ VSub_Name "$all_strategies"))} {(KW_Bang "!") (Lit_Other "=")} {(DQ (ztttt))} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:hint) op: Equal rhs: {(DQ (" (maybe try again with -a)"))} spids: [814] ) ] spids: [814] ) ] op_id: Op_DAmp ) (C {(die)} {(DQ ("no candidates for ") ($ VSub_Name "$branch") (" found") ($ VSub_Name "$hint"))} ) ] spids: [-1 790] ) ] spids: [-1 829] ) (C {(echo)} {(DQ ("** Candidates for ") ($ VSub_Name "$branch") (" **"))}) (Pipeline children: [ (ForEach iter_name: cmt iter_words: [{($ VSub_Name "$candidates")}] do_arg_iter: False body: (DoGroup children: [ (C {(git)} {(--no-pager)} {(log)} {(--pretty) (Lit_Other "=") (tformat) (Lit_Other ":") (DQ ("%ct:%h [%cr] %s"))} {(--abbrev-commit)} {(-1)} {($ VSub_Name "$cmt")} ) ] spids: [849 872] ) spids: [845 847] ) (C {(sort)} {(-n)}) (C {(cut)} {(-d) (Lit_Other ":")} {(-f2-)}) ] negated: False ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:newest) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [(C {(git)} {(rev-list)} {(-1)} {($ VSub_Name "$candidates")})] ) left_token: spids: [893 901] ) ) } spids: [891] ) ] spids: [891] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} {(KW_Bang "!")} {(-z)} {(DQ ($ VSub_Name "$dry_run"))}) terminator: ) ] action: [ (C {(printf)} {(DQ ("** Most recent: "))}) (C {(git)} {(--no-pager)} {(log)} {(-1)} {(--pretty) (Lit_Other "=") (tformat) (Lit_Other ":") (DQ ("%h %s"))} {($ VSub_Name "$newest")} ) ] spids: [-1 917] ) (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [{(git)} {(rev-parse)} {(--verify)} {(--quiet)} {($ VSub_Name "$new_name")}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(/dev/null)} spids:[959])] ) ] negated: True ) terminator: ) ] action: [ (C {(printf)} {(DQ ("** Restoring ") ($ VSub_Name "$new_name") (" to "))}) (C {(git)} {(--no-pager)} {(log)} {(-1)} {(--pretty) (Lit_Other "=") (tformat) (Lit_Other ":") (DQ ("%h %s"))} {($ VSub_Name "$newest")} ) (C {(git)} {(branch)} {($ VSub_Name "$new_name")} {($ VSub_Name "$newest")}) ] spids: [945 963] ) ] else_action: [ (C {(printf)} {(DQ ("Most recent: "))}) (C {(git)} {(--no-pager)} {(log)} {(-1)} {(--pretty) (Lit_Other "=") (tformat) (Lit_Other ":") (DQ ("%h %s"))} {($ VSub_Name "$newest")} ) (C {(echo)} {(DQ ("** ") ($ VSub_Name "$new_name") (" already exists, doing nothing"))}) ] spids: [1002 1039] ) ] )