Skip to content

Commit

Permalink
Do not expand --all when parsing %(revargs)
Browse files Browse the repository at this point in the history
Passing `--all` to `git-rev-parse --revs-only` will expand it to all
revs in the repository, which causes Tig to exit with the error:

    tig: No revisions match the given argument.

if a revision is deleted or added and the view is reloaded. In addition,
it also causes problems in repositories with many revs.

Fixes #442 and fixes #462.
  • Loading branch information
jonas committed Jan 5, 2016
1 parent 2ea054b commit 786a028
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Bug fixes:
- Add currently checked out branch to `%(branch)` (GH #416)
- Fix segfault when hitting return in empty file search (GH #464)
- Remove separator on horizontal split when switching from vertical split
- Do not expand `--all` when parsing `%(revargs)` (GH #442, #462)

tig-2.1.1
---------
Expand Down
8 changes: 3 additions & 5 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf
{
bool ok;

if (silent) {
if (silent || is_script_executing()) {
ok = io_run_bg(argv, dir);

} else {
Expand All @@ -62,10 +62,8 @@ open_external_viewer(const char *argv[], const char *dir, bool silent, bool conf
if (confirm || !ok) {
if (!ok && *notice)
fprintf(stderr, "%s", notice);
if (!is_script_executing()) {
fprintf(stderr, "Press Enter to continue");
getc(opt_tty);
}
fprintf(stderr, "Press Enter to continue");
getc(opt_tty);
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/tig.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,17 @@ filter_options(const char *argv[], bool rev_parse)
opt_cmdline_args = flags;
}

for (next = flags_pos = 0; argv[next]; next++) {
const char *arg = argv[next];

if (!strcmp(arg, "--all"))
argv_append(&opt_rev_args, arg);
else
argv[flags_pos++] = arg;
}

argv[flags_pos] = NULL;

filter_rev_parse(&opt_rev_args, "--symbolic", "--revs-only", argv);
}

Expand Down
41 changes: 41 additions & 0 deletions test/main/all-arg-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

. libtest.sh
. libgit.sh
. "$source_dir/util.sh"

export LINES=16

steps '
:set line-graphics = ascii
:exec !assert-var "%(revargs)" == "--all"
:exec !git branch -D mp/feature
:save-display final.screen
'

in_work_dir create_repo_from_tgz "$base_dir/files/refs-repo.tgz"

test_tig --all

assert_vars

assert_equals stderr <<EOF
EOF

assert_equals 'final.screen' <<EOF
2009-02-13 23:31 Max Power * {max-power/mp/feature} WIP: feature
2010-04-07 05:37 Max Power * [master] {origin/master} {max-power/mas
2010-03-29 17:15 Jørgen Thygesen Brahe * Commit 10 D
2010-03-21 04:53 作者 * Commit 10 C
2010-03-12 16:31 René Lévesque * <v2.0.1> Commit 10 B
2010-03-04 04:09 A. U. Thor * <v2.0> Commit 10 A
2010-02-23 15:46 Max Power * Commit 9 E
2010-02-15 03:24 Jørgen Thygesen Brahe * Commit 9 D
2010-02-06 15:02 作者 * Commit 9 C
2010-01-29 02:40 René Lévesque * Commit 9 B
2010-01-20 14:18 A. U. Thor * <v1.1.1> Commit 9 A
2010-01-12 01:56 Max Power * <mp/good> Commit 8 E
2010-01-03 13:33 Jørgen Thygesen Brahe * Commit 8 D
2009-12-26 01:11 作者 * [r1.1.2] [r1.1.x] <v1.1> Commit 8 C
[main] 042f71a7592228ae84cbb3642c2666dcd35aa527 - commit 1 of 51 27%
EOF
11 changes: 9 additions & 2 deletions test/tools/libtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,15 @@ executable 'assert-var' <<EOF
#!/bin/sh
mkdir -p "$(dirname "$expected_var_file")"
echo "\$1" >> "$expected_var_file"
echo "\$3" >> "$HOME/$vars_file"
while [ \$# -gt 1 ]; do
arg="\$1"; shift
case "\$arg" in
==) break ;;
*) echo "\$arg" >> "$HOME/$vars_file" ;;
esac
done
echo "\$@" >> "$expected_var_file"
EOF

assert_vars()
Expand Down

0 comments on commit 786a028

Please sign in to comment.