@@ -1507,26 +1507,29 @@ contains |
| 1507 | 1507 | subroutine git_show_history() |
| 1508 | 1508 | integer :: status_code, status |
| 1509 | 1509 | character(len=4096) :: command |
| 1510 | + character(len=1) :: q, sq |
| 1510 | 1511 | |
| 1511 | 1512 | ! Restore terminal for fzf |
| 1512 | 1513 | call execute_command_line('stty sane < /dev/tty', exitstat=status) |
| 1513 | 1514 | |
| 1515 | + ! Set up quote characters for easier reading |
| 1516 | + q = achar(34) ! double quote " |
| 1517 | + sq = achar(39) ! single quote ' |
| 1518 | + |
| 1514 | 1519 | ! Start with detailed view, allow switching with 1/2 |
| 1515 | | - ! Use --bind to reload with different git log format |
| 1516 | | - write(command, '(A)') & |
| 1517 | | - 'git log --graph --color=always --all --date=relative ' // & |
| 1518 | | - '--pretty=format:"%C(yellow)%h%C(reset) - %C(green)(%ar)%C(reset) %s %C(blue)<%an>%C(reset)" | ' // & |
| 1519 | | - 'fzf --ansi --height=100% --border=rounded ' // & |
| 1520 | | - '--border-label=" History - Press 1:detailed 2:oneline ESC:close " ' // & |
| 1521 | | - '--prompt="Commit: " ' // & |
| 1522 | | - '--header="Switch views: 1=detailed 2=oneline" ' // & |
| 1523 | | - '--preview="echo {} | grep -o ''[0-9a-f]\{7,\}'' | head -1 | ' // & |
| 1524 | | - 'xargs git show --color=always" ' // & |
| 1525 | | - '--preview-window=right:60% ' // & |
| 1526 | | - '--bind ''1:reload(git log --graph --color=always --all --date=relative ' // & |
| 1527 | | - '--pretty=format:\"%C(yellow)%h%C(reset) - %C(green)(%ar)%C(reset) %s %C(blue)<%an>%C(reset)\")'' ' // & |
| 1528 | | - '--bind ''2:reload(git log --oneline --graph --color=always --all)'' ' // & |
| 1529 | | - '> /dev/null' |
| 1520 | + ! Build command carefully to avoid quote hell |
| 1521 | + ! Detailed format: hash - relative date - message <author> |
| 1522 | + command = 'git log --graph --color=always --all --pretty=' // sq // '%h - %ar - %s <%an>' // sq // ' | ' // & |
| 1523 | + 'fzf --ansi --height=100% --border=rounded ' // & |
| 1524 | + '--border-label=' // q // ' History - Press 1:detailed 2:oneline ESC:close ' // q // ' ' // & |
| 1525 | + '--prompt=' // q // 'Commit: ' // q // ' ' // & |
| 1526 | + '--header=' // q // 'Switch views: 1=detailed 2=oneline' // q // ' ' // & |
| 1527 | + '--preview=' // q // 'echo {} | grep -o ' // sq // '[0-9a-f]\{7,\}' // sq // & |
| 1528 | + ' | head -1 | xargs git show --color=always' // q // ' ' // & |
| 1529 | + '--preview-window=right:60% ' // & |
| 1530 | + '--bind=' // q // '1:reload(git log --graph --color=always --all --pretty=' // sq // '%h - %ar - %s <%an>' // sq // ')' // q // ' ' // & |
| 1531 | + '--bind=' // q // '2:reload(git log --oneline --graph --color=always --all)' // q // ' ' // & |
| 1532 | + '> /dev/null' |
| 1530 | 1533 | |
| 1531 | 1534 | call execute_command_line(trim(command), exitstat=status_code) |
| 1532 | 1535 | |