fortrangoingonforty/fuss / 8efca25

Browse files

its extra, but it works (fix command 1 view in history view)

Authored by espadonne
SHA
8efca2543ea34428e4de2d89d11e474152d42e60
Parents
5d65ae2
Tree
f8ff834

1 changed file

StatusFile+-
M src/git_module.f90 18 15
src/git_module.f90modified
@@ -1507,26 +1507,29 @@ contains
15071507
     subroutine git_show_history()
15081508
         integer :: status_code, status
15091509
         character(len=4096) :: command
1510
+        character(len=1) :: q, sq
15101511
 
15111512
         ! Restore terminal for fzf
15121513
         call execute_command_line('stty sane < /dev/tty', exitstat=status)
15131514
 
1515
+        ! Set up quote characters for easier reading
1516
+        q = achar(34)   ! double quote "
1517
+        sq = achar(39)  ! single quote '
1518
+
15141519
         ! 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'
15301533
 
15311534
         call execute_command_line(trim(command), exitstat=status_code)
15321535