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

ls-file-collection misinterprets argument as a path for gittree #605

Open
mih opened this issue Jan 26, 2024 · 0 comments
Open

ls-file-collection misinterprets argument as a path for gittree #605

mih opened this issue Jan 26, 2024 · 0 comments

Comments

@mih
Copy link
Member

mih commented Jan 26, 2024

Here is the demo:

% datalad ls-file-collection gittree .
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/datalad/cli/main.py", line 190, in _run_with_exception_handler
    return cmdlineargs.func(cmdlineargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/datalad/cli/exec.py", line 107, in call_from_parser
    ret = list(ret)
          ^^^^^^^^^
  File "/usr/lib/python3/dist-packages/datalad_next/patches/interface_utils.py", line 218, in _execute_command_
    for r in _process_results(
  File "/usr/lib/python3/dist-packages/datalad/interface/utils.py", line 319, in _process_results
    for res in results:
  File "/usr/lib/python3/dist-packages/datalad_next/commands/ls_file_collection.py", line 405, in __call__
    for item in collection.iter:
  File "/usr/lib/python3/dist-packages/datalad_next/iter_collections/gittree.py", line 112, in iter_gittree
    for line in _git_ls_tree(path, treeish, *lstree_args):
  File "/usr/lib/python3/dist-packages/datalad_next/iter_collections/gittree.py", line 130, in _git_ls_tree
    with iter_git_subproc(
  File "/usr/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/usr/lib/python3/dist-packages/datalad_next/iterable_subprocess/iterable_subprocess.py", line 192, in iterable_subprocess
    raise CommandError(
datalad.runner.exception.CommandError: <exception str() failed>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/datalad", line 33, in <module>
    sys.exit(load_entry_point('datalad==0.19.5', 'console_scripts', 'datalad')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/datalad/cli/main.py", line 143, in main
    _run(cmdlineargs)
  File "/usr/lib/python3/dist-packages/datalad/cli/main.py", line 169, in _run
    else _run_with_exception_handler(namespace)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/datalad/cli/main.py", line 212, in _run_with_exception_handler
    exit_code = _communicate_commanderror(exc) or exit_code
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/datalad/cli/main.py", line 225, in _communicate_commanderror
    exc_msg = exc.to_str(include_output=False)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/datalad/runner/exception.py", line 61, in to_str
    join_cmdline(cmd) if isinstance(cmd, list) else cmd
    ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/datalad/utils.py", line 2672, in join_cmdline
    return ' '.join(map(quote_cmdlinearg, args))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/datalad/utils.py", line 2656, in quote_cmdlinearg
    ) if on_windows else shlex_quote(arg)
                         ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/shlex.py", line 329, in quote
    if _find_unsafe(s) is None:
       ^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'PosixPath'

Using HEAD instead of . results in an expected behavior.

Instead of crashing, it should determine that . is not a valid tree-ish:

% git ls-tree .
fatal: Not a valid object name .
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

1 participant