Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIG_LS_REMOTE not behaving as documented #853

Closed
brtwrst opened this issue Jul 14, 2018 · 5 comments
Closed

TIG_LS_REMOTE not behaving as documented #853

brtwrst opened this issue Jul 14, 2018 · 5 comments

Comments

@brtwrst
Copy link
Contributor

brtwrst commented Jul 14, 2018

TLDR:
TIG_LS_REMOTE default got changed from git ls-remote to git show-ref in 3448d1c.
Now using git ls-remote in the TIG_LS_REMOTE environment variable breaks TIG because git ls-remote uses tabs and git show-ref uses spaces to separate output and TIG expects spaces.
/TLDR

Please see Chapter 3.2 at http://jonas.nitro.dk/tig/manual.html#env-variables
or Environment Variable Section at https://jonas.github.io/tig/doc/tig.1.html

The Manual speaks of an environment variable TIG_LS_REMOTE that can be used to "limit what branches are shown".

I was playing around with this and immediately noticed some strange behaviour:

When setting the supposed default:

export TIG_LS_REMOTE="git ls-remote ."

TIG breaks and shows no branches at all.

I checked the source code and found this in refdb.c line 314:

const char *ls_remote_argv[SIZEOF_ARG] = {
		"git", "show-ref", "--head", "--dereference", NULL
	};

which apparently got changed in 3448d1c
so when i tried:

export TIG_LS_REMOTE="git show-ref --head --dereference"

everything went back to normal.

when checking the outputs of git show-ref vs git ls-remote the only difference i could find was that show-ref uses a SPACE to separate the output and ls-remote uses a TAB.

here is git ls-remote .

dce1882dc0e27685ee82cf0a80c0dea286e87891        HEAD
dce1882dc0e27685ee82cf0a80c0dea286e87891        refs/heads/master
dce1882dc0e27685ee82cf0a80c0dea286e87891        refs/heads/test
dce1882dc0e27685ee82cf0a80c0dea286e87891        refs/remotes/origin/HEAD
dce1882dc0e27685ee82cf0a80c0dea286e87891        refs/remotes/origin/master

and here is git show-ref --head --dereference

dce1882dc0e27685ee82cf0a80c0dea286e87891 HEAD
dce1882dc0e27685ee82cf0a80c0dea286e87891 refs/heads/master
dce1882dc0e27685ee82cf0a80c0dea286e87891 refs/heads/test
dce1882dc0e27685ee82cf0a80c0dea286e87891 refs/remotes/origin/HEAD
dce1882dc0e27685ee82cf0a80c0dea286e87891 refs/remotes/origin/master

and sure enough i found this in refdb.c line 345

code = io_run_load(ls_remote_argv, " ", read_ref, &opt);

so it seems the separator TIG expects is hard coded as a space.
I tried replacing the tabs with spaces using TIG_LS_REMOTE=git ls-remote . | tr '\t' ' ' but that does not work.

@jonas
Copy link
Owner

jonas commented Jul 14, 2018

Thanks for the detailed report. I have been considering removing TIG_LS_REMOTE or migrating it to an option in ~/.tigrc so I am curious if you could share your use case?

Regarding the issue, would you mind trying to change the line you mentioned to

code = io_run_load(ls_remote_argv, " \t", read_ref, &opt);

So tabs are also a valid separator? If it works please make a pull request else if you prefer I can make one.

@brtwrst
Copy link
Contributor Author

brtwrst commented Jul 14, 2018

Well i just wanted to decrease visual clutter by (for example) not showing origin/HEAD.
Also i have some remotes that i just use for backup purposes and don't want to see all the time.
I'm not a developer by trade and i've been customizing the settings of tig just for the sake of it.
(Like figuring out how to make my sublimetext work with editor-line-number - sublimetext wants file:line not +line file)
Did i mention i use windows :D
I will try to change the line and compile it on my raspberry pi and get back to you after i figured out how to make a pull request.

BTW thanks for a great program.

@brtwrst
Copy link
Contributor Author

brtwrst commented Jul 14, 2018

Alright that was fun.
Changing the line does in fact fix this issue. And i did figure out how pull requests work.
Now i just have to figure out how to actually hide the refs i want to hide.

@jonas
Copy link
Owner

jonas commented Jul 15, 2018

Decreasing visual clutter was one of the reasons for introducing the feature.

Fixed in 20f1edf

@brtwrst
Copy link
Contributor Author

brtwrst commented Jul 15, 2018

Alright so its a valid use case after all.
Now i'm stuck on the fact that it behaves basically like a whitelist.
For my case here it would be a lot better if it would behave like a blacklist but i can see that - even though i have very little understanding of the source code - this would be a lot more than a one line change. If you ever rewrite the feature to use the .tigrc you might want to look into that possibility.

Thanks again

clrpackages pushed a commit to clearlinux-pkgs/tig that referenced this issue Sep 3, 2018
Alexander Droste (1):
      Revert "Handle \n like \r (#758)" (#769)

Andreas Stieger (1):
      Make build reproducible

Björn Andersson (3):
      Update make config for cygwin/ncurses (#792)
      New boolean option "send-child-enter" (#791)
      Fix line numbers in grep view when scrolled (#813)

Brtwrst (1):
      Fix TIG_LS_REMOTE not working with "git ls-remote". Solves jonas/tig#853 (#854)

Christian Brabandt (1):
      Handle \n like \r (#758)

Dan Wendorf (1):
      Replace status-untracked-dirs command in tigrc

David O'Trakoun (1):
      tig(1): Fix env var checked (#752)

Diego Pomares (1):
      Fix #463: Add user command flag to skip confirmation after execution (#738)

Edgar Hipp (1):
      Fix #663: avoid segfault when calling htab_empty (#745)

Greg Hewgill (1):
      Change link to stackoverflow.com to https

Jonas Fonseca (116):
      Merge pull request #597 from m42a/master
      Fix diff name discovery to better handle prefixes
      Fix #602: Escape directory names passed to git-ls-tree
      Minor update to NEWS
      Fix display of test results to work with POSIX sed
      Update NEWS
      Merge pull request #612 from rolandwalker/source-quiet-nonexistent
      Merge pull request #617 from rolandwalker/width-cleanups-tests
      Merge pull request #618 from rolandwalker/handle-empty-readline
      Merge pull request #622 from rolandwalker/perf-throttle-load-updates
      Merge pull request #619 from rolandwalker/more-control-character-bindings
      Merge pull request #620 from rolandwalker/readline-persistent-history-file
      Merge pull request #626 from rolandwalker/add-echo-action
      Merge pull request #625 from rolandwalker/diff-highlight-configurable
      Merge pull request #633 from rolandwalker/diff-highlight-git-colors
      Merge pull request #641 from rolandwalker/tree-fake-cd-return
      Merge pull request #634 from rolandwalker/quoted-argv-corruption
      Merge pull request #629 from rolandwalker/max-line-when-stop-loading
      Merge branch 'hide-cursor' of https://github.com/rolandwalker/tig
      Fix clearing of the status window
      Merge pull request #638 from swegener/graph-fixes
      Implement specialized report_clear
      Add test for rendering emojis
      Merge pull request #639 from swegener/graph-speedup
      Fix reading from stdin for "tig show"
      Document problem of outdated system-wide tigrc files in Homebrew
      Add testing docs to GitBook and add ignore file
      Make prompt_interrupted volatile
      Update NEWS
      Add more closed issues to NEWS
      Fix #527: set the reset display flag for line-graphics
      Test diff stat parsing
      Fix #590: Document limitation of staging chunk/lines
      Fix assertion
      Update and fix wording in the NEWS file
      Improve the toggle option menu
      Ignore warning about unused variable
      Merge pull request #668 from rolandwalker/doc-linting
      Fix #232: Do not generate any input when handling Ctrl-Z
      Merge pull request #664 from rolandwalker/test-category-todo
      Ensure that `make update-docs` is up-to-date
      Fix suspension capability when calling out to external commands
      Move terminal modes setup to separate function
      Fix #522: Increase size of the internal date buffer
      Merge pull request #674 from rolandwalker/wordexp
      Merge pull request #682 from rolandwalker/rm-var-sel-workaround
      Merge pull request #678 from rolandwalker/single-line-output
      Fix #687: disable the graph when --no-merges is passed
      Remove unnecessary definition of TIG_NO_DISPLAY from tests
      Update NEWS
      Mangle :save-options test paths to write to HOME
      Merge pull request #707 from rolandwalker/assert-vars-improve
      Disable leak detection for AddressSanitizer
      Add support for printing backtraces on segfault
      Merge pull request #712 from rolandwalker/assert-vars-followup
      Merge pull request #718 from rolandwalker/history-dedupe-at-save
      Merge pull request #688 from rolandwalker/test-timeout
      Merge pull request #724 from rolandwalker/test-timeout-followups
      Fix code markers for the color command examples
      Update NEWS
      tig-2.3.0
      Merge pull request #737 from rolandwalker/test-filter
      Merge pull request #725 from rolandwalker/termios
      Fix formatting of the Windows install documentation
      Move loop updating views to separate method
      Fix #164: Add workaround to detect busy event loops
      Use initscr to ensure proper TTY setup for the prompt (#768)
      Update NEWS
      tig-2.3.1
      Only check for busy loop when no views are updating
      tig-2.3.2
      Fix #164 by catching SIGHUP
      Change refs_tags type to size_t
      tig-2.3.3
      Merge pull request #780 from hwangcc23/mirror-fix
      Print the ncurses and readline versions (#796)
      Merge pull request #799 from proski/warning-fixes
      Use view flags to apply the grep view's line number fix
      Update compat/hashtab.c with latest libiberty version
      Fix #824: Workaround potential null pointer dereferences
      Rework #790 to define newscr in tig.h if undefined (#797)
      Update NEWS
      Fail the Travis build if a test fails
      Require sudo to run LeakSanitizer
      Merge pull request #825 from jonas/cleanups
      Test address sanitizer in a separate build
      Fix #821: Add key mappings for single and double quotes
      Change the blame view to have the same default columns as git-blame
      Fix #459, #781: Remove worktree code that changes the CWD
      Fix argument parsing to pass '--' to git-rev-parse
      Fix #763: Handle GIT_PREFIX by setting GIT_WORK_TREE and changing directory
      Filter the checked GIT_* environment variables
      Update the configured snap name to match the registered name
      Fix the emoji test to pass on Travis
      Add dedicated valgrind build
      Move chdir() before setenv() to ensure the prefix is correct
      Only include lines where GIT_* is at the start
      Configure AppVeyor to build on Cygwin
      Show AppVeyor build status badge
      Show AppVeyor status badge for the master branch
      Add utf8proc for handling character properties
      Limit to only build on Cygwin64
      Merge pull request #828 from rolandwalker/process-group-leader
      Fix git alias to use grep instead of sed
      Update the snapcraft configuration
      Merge pull request #832 from odnoletkov/master
      Add tests for #836 and #802
      snap: depend on pkg-config
      snap: depend on ncurses and readline dev packages
      Fix issues reported by the clang scan-build tool
      Fix #839: use stack allocated memory to handle TIG_LS_REMOTE
      Merge pull request #850 from jonas/scan-build-fixes
      Update NEWS
      tig-2.4.0
      Fix #856: Add CURSES_CFLAGS to CPPFLAGS (#857)
      tig-2.4.1

Leo Arias (1):
      Add the packaging metadata to build the tig snap (#721)

Maksim Odnoletkov (2):
      Fix sh compatibility in tig-pick
      Minor cleanup in tig-pick

Marc Aldorasi (2):
      Delay check for blame -C option
      Only override blame-options when given command line blame options

Matt (1):
      Added another installation method (#753)

Max Odnoletkov (1):
      Fix #569: Pass command line args through to the stage view (#823)

PaulChanHK (1):
      Fix #428: Change date formatting to show timezones by default

Pavel Roskin (5):
      Drop "const" from return values, it is ignored
      Let strncpy() terminate the destination
      Annotate fall-through in case statements
      Don't allow pos->lineno to underflow in file search (#800) (#801)
      Fix arithmetic operation on void pointer (#803)

Ramsay Jones (1):
      save-view: fix some printf format specifiers

Roland Walker (129):
      also interpret button5 as wheel-down
      add action view-close-no-quit
      add bool option mouse-wheel-cursor
      add test for source command
      Improve test suite portability (#609, #614)
      add a -q parameter to source for source-if-present
      width on line-number is documented, accepted, but ignored; make it work width on status is documented, accepted, but ignored; remove it width on text is undocumented, accepted, but ignored; remove it width on commit-title is undocumented, accepted, but ignored; remove it fix: width of 1 fails when column is trimmed add tests for all remaining columns that support width adjust main/view-split-test to match - neither behavior is correct
      recognize empty readline input and clear report
      bindable ctrl chars C-C/V/S/@, handle readline C-C
      perf: throttle screen updates during load
      persist readline history to ~/.tig_history
      add echo action
      make diff-highlight use std configurable colors
      pick up diff-highlight colors from git-colors
      title count to highest item on stop-loading action
      don't read past end-of-string in concat_argv
      fix back/parent in tree-view: return after pop
      hide cursor unless at textual prompt
      let Ctrl-C exit Y/N and menu prompts
      expand tig variables in echo action
      raise maximum unicode codepoint
      doc ScrollFwd/Back and abbreviate Fn keys as range
      recast keybinding notes as bullets
      enable Fn keys thru 19, and 6 shifted special keys
      enable scroll optimization for Terminal.app/Iterm2
      remove needless check
      set cursor coord when not updating prompt contents
      allow Ctrl-C to terminate file-finder prompt
      report_clear() efficiency plus clear after grep
      configurable truncation-delimiter w/ utf8 suggest
      reduce flicker in file finder; avoid wclear
      erase status line at exit time
      allocate enough memory for finder items NUL term
      distinguish cancel and empty string at all prompts
      clarify Shifted symbolic keys in news
      independent throttle increment for each view
      signal handler should be closest around readline
      preload last search from history
      gitignore OS X valgrind byproduct
      missing quotes
      doubled words
      mention $XDG_CONFIG_HOME consistently
      extraneous verb "Set"
      make symbolic keys match what tigrc accepts
      document "$if tig" support for ~/.inputrc
      use hyphens within adjectival noun phrases
      sync with "make update-docs"
      let commands be much longer than SIZEOF_STR
      flush buffered keystrokes after external viewer
      doubledash and similar test suite linting
      missing unary operator
      missing backslash
      add a TODO test category
      allow overriding sed executable in makefile
      make $TEST_OPTS respect wordsplit under bash
      whitespace
      wordexp support and compat fallback
      expand tilde in load_option_file()/:source paths
      expand tilde in :script paths
      quieten which gsed
      make unicode_width() understand more characters
      accept dir param to io_run_buf()
      shorten TODO message
      simplify restore-after-test_tig with subshell
      add --subshell= flag to test_case
      reduce emoji test to case that always passes
      remove hardcoded workaround from unicode_width
      reintroduce failing unicode test as a TODO
      external cmd opt flag + for "echo first line"
      avoid picking up user freedesktop vars in tests
      permit diff cells of len 0, to reset bg color
      don't segfault on ":exec" irregular args
      todo test for bug re jumping past last line
      tolerate empty lines in scripts
      tilde expansion was added to :script
      incorporate xterm wcwidth.c to find unicode widths
      valgrind test fixes
      save-options able to write empty reference_format
      suppress a warning within darwin libsystem
      readline-complete on repo variables
      empty assert as stdin, not argument
      rewrite assert-vars: robust + preserve space
      make 2nd arg to assert_equals govern whitespace
      reorder to ensure that assert_vars tests complete
      ignore user's $INPUTRC variable in tests
      ignore script lines starting with # (comment)
      rewrite compat/wordexp and ensure nul terminator
      ensure ordered writes to trace file
      fill in dev cruft stub parameter
      whitespace_arg more readable default value
      require expected-count argument to assert_vars
      history-size option
      don't accept jump past max line
      don't store history empties or consecutive dupes
      add test-todo make target
      no teardown unless history-size positive
      deduplicate history on save
      simplify test_tig logic via subshell, redirection
      apply timeouts to external tig processes in tests
      leverage backgrounded model for one-word $runner
      restore cursor in done_display
      mv acinclude.m4 to descriptive tools/iconv.m4
      add test_case --assert-equals=<filename>=<content>
      bash cleanups
      add test timeout bonus under valgrind
      add test_timeout() variable setter
      raise on-branch* long test timeouts
      suppress run: message from valgrind (#732)
      avoid writing to same file providing content (#728)
      child after fork should call _exit not exit (#726)
      quieten unary argument warning during configure (#723)
      save and restore TTY attributes
      restore tty attrs+flush before/after external cmd
      give feedback as test cases are run
      add ability to filter tests via TEST_OPTS
      bug: branch on content in expected file (#731)
      consistency in use of IFS (#729)
      convert test timeout watchers to polls (#735)
      raise timeout in test which sleeps (#733)
      preserve/restore TTY attributes in test suite (#727)
      Visually distinguish merge vs commit in utf-8 graph (#660)
      Sidestep readline when executing a script (#703)
      Add `maxwidth` format param for fields `author`, `file-name`, `ref` (#624)
      Untruncate preloaded search string (#689)
      Let `set diff-highlight=true` work when the diff-highlight executable is not on $PATH (#662)
      make tig the process-group leader
      clean up all child processes at exit
      less hacky libreadline test (#829)
      Stub docs for testing API (#730)

Ronan Jouchet (1):
      tigrc doc: mention using git-show --format in diff-options (#843)

Stephen (1):
      Parallelize the Travis CI build and macOS to the matrix (#750)

Sven Wegener (11):
      test: Remove git log output from graph tests
      test: Fix commit names
      graph: Use graph_column_has_commit
      graph: Add regression test for "─╭" instead of " ╭"
      graph: Fix display of "─╭" to " ╭"
      graph: Add regression test for "─┬" instead of "──"
      graph: Fix display of "──" to "─┬"
      graph: Add ─┤ display
      graph: Add ─┼ display
      graph: Speed up graph generation by interning ids
      graph: Optimize initial and merge calculation

Thomas Koutcher (7):
      Fix file argument (#788)
      Fix incorrect behaviour of up and down keys in diff view when opened from diff preview (#835)
      Open the stage view when maximizing a split diff view of (un)staged changes (#836)
      Fix Vim going background after running Tig (#837)
      Use fully qualified ref name for tag when conflicting with branch name (#849)
      Fix resize not working after entering command (#845) (#846)
      Fix deleted file mode line remains highlighted after hovering in diff or stage view (#851)

harshavardhan (1):
      updated https to https (#777)

hwangcc23 (3):
      Fix the resource leak
      Fix dead code
      Fix usage of sizeof(finder->line)

kiryph (1):
      Bind G also in main

plgruener (1):
      Adjust case of reldate letters according to ISO-8601

rofl0r (2):
      display.c: fix build with netbsd-curses (#789)
      display.h: fix build against netbsd-curses (#790)

Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants