jonas / tig

Text-mode interface for git
https://jonas.github.io/tig/
GNU General Public License v2.0
12.48k stars 611 forks source link

[Bug] `tig blame --reverse` get the wrong revision of file #1300

Closed liming01 closed 1 year ago

liming01 commented 1 year ago

When I use tig blame --reverse to find which commit deleted a line?, I found that tig gets the wrong file revision. e.g.

git blame --reverse START_SHA..HEAD file.ext can get file.ext @ START_SHA, while tig blame --reverse START_SHA..HEAD file.ext can get file.ext @ HEAD

koutcher commented 1 year ago

--reverse is swallowed by command line parsing, we need to add it back in blame arguments. Would this work for you ?

diff --git a/src/blame.c b/src/blame.c
index b9e15314..43af804f 100644
--- a/src/blame.c
+++ b/src/blame.c
@@ -90,6 +90,9 @@ blame_open(struct view *view, enum open_flags flags)
                        opt_cmdline_args = NULL;
                }

+               if (opt_commit_order == COMMIT_ORDER_REVERSE)
+                       argv_append(&opt_blame_options, "--reverse");
+
                /*
                 * flags (like "--max-age=123") and bottom limits (like "^foo")
                 * will be passed as-is, and retained even if we re-blame from
liming01 commented 1 year ago

Hi @koutcher,

This fix works fine in this case.
Thanks a lot!