diff options
author | Roland Walker <walker@pobox.com> | 2018-05-20 00:06:49 -0400 |
---|---|---|
committer | Jonas Fonseca <jonas.fonseca@gmail.com> | 2018-05-20 00:06:49 -0400 |
commit | 539ccbc5f2713177997df85b1175789a008b423f (patch) | |
tree | 50fbff1a031028b126584e730db6d61b0ceb4f17 | |
parent | e327a4fcc1f8b60f607dc42cc3c19df71ff78aae (diff) |
Untruncate preloaded search string (#689)
* untruncate preloaded search
* add test_requires readline
-rw-r--r-- | src/prompt.c | 2 | ||||
-rw-r--r-- | test/README.adoc | 5 | ||||
-rwxr-xr-x | test/main/search-preload-test | 35 | ||||
-rw-r--r-- | test/tools/libtest.sh | 21 |
4 files changed, 62 insertions, 1 deletions
diff --git a/src/prompt.c b/src/prompt.c index 3f9c6f98..816f52ee 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -604,7 +604,7 @@ prompt_init(void) last_entry = history_get(history_length); if (last_entry) - string_copy(argv_env.search, last_entry->line); + string_ncopy(argv_env.search, last_entry->line, strlen(last_entry->line)); } #else char * diff --git a/test/README.adoc b/test/README.adoc index 12beaba7..40bdbcc1 100644 --- a/test/README.adoc +++ b/test/README.adoc @@ -69,3 +69,8 @@ timeout=<int>:: Set the default timeout for each invocation of tig under the test harness. The default is 10 if unset. 0 means "no timeout". Individual tests may override the value. + +Testing API +----------- + +test_require(git-worktree, address-sanitizer, diff-highlight, readline):: diff --git a/test/main/search-preload-test b/test/main/search-preload-test new file mode 100755 index 00000000..508c3b98 --- /dev/null +++ b/test/main/search-preload-test @@ -0,0 +1,35 @@ +#!/bin/sh + +. libtest.sh +. libgit.sh + +export LINES=3 +export COLUMNS=80 + +test_require readline + +in_work_dir create_repo_from_tgz "$base_dir/files/scala-js-benchmarks.tgz" + +tigrc <<EOF +set line-graphics = ascii +EOF + +# Force .tig_history since the final entry isn't guaranteed under the test harness. +file .tig_history <<EOF +Merge pull request #1 from sjrd/patch-1 +EOF + +steps ' + :find-next + :save-display main.screen +' + +test_tig + +assert_equals main.screen <<EOF +2013-10-18 07:00 Jonas Fonseca M-. Merge pull request #1 from sjrd/patch-1 +[main] 0b89f7997f696a7f6ae4c10e3b29817862e751d6 - commit 39 of 48 81% +EOF + +assert_equals stderr <<EOF +EOF diff --git a/test/tools/libtest.sh b/test/tools/libtest.sh index 25ceb307..82547b17 100644 --- a/test/tools/libtest.sh +++ b/test/tools/libtest.sh @@ -456,6 +456,21 @@ require_git_version() fi } +has_readline() +{ + # Test functionality, since there isn't a good way to inspect the binary. + readline_exit_status=1 + file readline_guard.script <<-EOF + :quit + EOF + + TIG_NO_DISPLAY=1 TIG_SCRIPT=readline_guard.script tig status </dev/null >/dev/null 2>/dev/null || true + test -e .tig_history && readline_exit_status=0 + rm -f -- readline_guard.script .tig_history + + return "$readline_exit_status" +} + test_require() { while [ $# -gt 0 ]; do @@ -481,6 +496,12 @@ test_require() test_skip "The test requires diff-highlight, usually found in share/git-core-contrib" fi ;; + readline) + if ! has_readline; then + test_skip "The test requires a tig compiled with readline" + fi + ;; + *) test_skip "Unknown feature requirement: $feature" esac |