Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix null dereferences on unset state variable
Tig knows three kinds of state variables that encode different information: 1. the state of the view (ARGV_ENV_INFO), like %(commit) 2. the state of the worktree (REPO_INFO), like %(repo:head) 3. the arguments given on the commandline, like %(fileargs) The values exposed by the first two kinds are never null, but most of the third kind default to null. Prior to this commit when trying to format a null value, argv_format() reported success but left the output string as null. Fix this by writing the empty string in format_append_argv(), because current callers (echo) don't really care about the difference between empty and null. Reproduce the null dereferences with :!%(fileargs) :echo %(fileargs) Surprisingly to me, this did not break this example: bind generic aaa !sh -c 'printf "%s\n" "$@" | wc -l' -- line1 %(fileargs) line2 # still prints 2 because of the early return in argv_appendn(). In future we should also fix format_append_arg(), which currently fails on :echo "%(fileargs)" because format_expand_arg() does not receive variables like %(fileargs).
- Loading branch information