[GH-ISSUE #70] Dockerized git-sim fails to run with various errors #45

Closed
opened 2026-03-02 16:47:43 +03:00 by kerem · 5 comments
Owner

Originally created by @durka on GitHub (Mar 7, 2023).
Original GitHub issue: https://github.com/initialcommit-com/git-sim/issues/70

I followed the Docker installation instructions.

Running git-sim in its own repo checkout results in an "SHA could not be resolved" error:
$ docker run --rm -v $(pwd):/usr/src/git-sim git-sim log
Simulating: git log
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /usr/local/lib/python3.11/site-packages/git_sim/log.py:65 in log             │
│                                                                              │
│   62 │   ),                                                                  │
│   63 ):                                                                      │
│   64 │   scene = Log(ctx=ctx, n=n, all=all)                                  │
│ ❱ 65 │   handle_animations(scene=scene)                                      │
│   66                                                                         │
│                                                                              │
│ ╭─────────────────────── locals ────────────────────────╮                    │
│ │   all = False                                         │                    │
│ │   ctx = <click.core.Context object at 0x7fb5eaabbcd0> │                    │
│ │     n = None                                          │                    │
│ │ scene = <git_sim.log.Log object at 0x7fb5ea5260d0>    │                    │
│ ╰───────────────────────────────────────────────────────╯                    │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git_sim/animations.py:17 in          │
│ handle_animations                                                            │
│                                                                              │
│   14                                                                         │
│   15                                                                         │
│   16 def handle_animations(scene: Scene) -> None:                            │
│ ❱ 17 │   scene.render()                                                      │
│   18 │                                                                       │
│   19 │   if settings.video_format == "webm":                                 │
│   20 │   │   webm_file_path = str(scene.renderer.file_writer.movie_file_path │
│                                                                              │
│ ╭────────────────────── locals ──────────────────────╮                       │
│ │ scene = <git_sim.log.Log object at 0x7fb5ea5260d0> │                       │
│ ╰────────────────────────────────────────────────────╯                       │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/manim/scene/scene.py:223 in render   │
│                                                                              │
│    220 │   │   """                                                           │
│    221 │   │   self.setup()                                                  │
│    222 │   │   try:                                                          │
│ ❱  223 │   │   │   self.construct()                                          │
│    224 │   │   except EndSceneEarlyException:                                │
│    225 │   │   │   pass                                                      │
│    226 │   │   except RerunSceneException as e:                              │
│                                                                              │
│ ╭─────────────────────── locals ───────────────────────╮                     │
│ │ preview = False                                      │                     │
│ │    self = <git_sim.log.Log object at 0x7fb5ea5260d0> │                     │
│ ╰──────────────────────────────────────────────────────╯                     │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git_sim/log.py:42 in construct       │
│                                                                              │
│   39 │   │   │   │   f"{settings.INFO_STRING} {type(self).__name__.lower()}{ │
│   40 │   │   │   )                                                           │
│   41 │   │   self.show_intro()                                               │
│ ❱ 42 │   │   self.parse_commits()                                            │
│   43 │   │   self.parse_all()                                                │
│   44 │   │   self.recenter_frame()                                           │
│   45 │   │   self.scale_frame()                                              │
│                                                                              │
│ ╭───────────────────── locals ──────────────────────╮                        │
│ │ self = <git_sim.log.Log object at 0x7fb5ea5260d0> │                        │
│ ╰───────────────────────────────────────────────────╯                        │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git_sim/git_sim_base_command.py:78   │
│ in parse_commits                                                             │
│                                                                              │
│     75 │   │   prevCircle=None,                                              │
│     76 │   │   shift=numpy.array([0.0, 0.0, 0.0]),                           │
│     77 │   ):                                                                │
│ ❱   78 │   │   commit = commit or self.get_commit()                          │
│     79 │   │                                                                 │
│     80 │   │   isNewCommit = commit.hexsha not in self.drawnCommits          │
│     81                                                                       │
│                                                                              │
│ ╭──────────────────────── locals ─────────────────────────╮                  │
│ │     commit = None                                       │                  │
│ │          i = 0                                          │                  │
│ │ prevCircle = None                                       │                  │
│ │       self = <git_sim.log.Log object at 0x7fb5ea5260d0> │                  │
│ │      shift = array([0., 0., 0.])                        │                  │
│ ╰─────────────────────────────────────────────────────────╯                  │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git_sim/git_sim_base_command.py:63   │
│ in get_commit                                                                │
│                                                                              │
│     60 │   │   self.show_outro()                                             │
│     61 │                                                                     │
│     62 │   def get_commit(self, sha_or_ref="HEAD"):                          │
│ ❱   63 │   │   return self.repo.commit(sha_or_ref)                           │
│     64 │                                                                     │
│     65 │   def get_default_commits(self):                                    │
│     66 │   │   defaultCommits = [self.get_commit()]                          │
│                                                                              │
│ ╭──────────────────────── locals ─────────────────────────╮                  │
│ │       self = <git_sim.log.Log object at 0x7fb5ea5260d0> │                  │
│ │ sha_or_ref = 'HEAD'                                     │                  │
│ ╰─────────────────────────────────────────────────────────╯                  │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/repo/base.py:614 in commit       │
│                                                                              │
│    611 │   │   """                                                           │
│    612 │   │   if rev is None:                                               │
│    613 │   │   │   return self.head.commit                                   │
│ ❱  614 │   │   return self.rev_parse(str(rev) + "^0")                        │
│    615 │                                                                     │
│    616 │   def iter_trees(self, *args: Any, **kwargs: Any) -> Iterator["Tree │
│    617 │   │   """:return: Iterator yielding Tree objects                    │
│                                                                              │
│ ╭────────────────────── locals ───────────────────────╮                      │
│ │  rev = 'HEAD'                                       │                      │
│ │ self = <git.repo.base.Repo '/usr/src/git-sim/.git'> │                      │
│ ╰─────────────────────────────────────────────────────╯                      │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/repo/fun.py:250 in rev_parse     │
│                                                                              │
│   247 │   │   │   │   if token == "@":                                       │
│   248 │   │   │   │   │   ref = cast("Reference", name_to_object(repo, rev[: │
│   249 │   │   │   │   else:                                                  │
│ ❱ 250 │   │   │   │   │   obj = cast(Commit_ish, name_to_object(repo, rev[:s │
│   251 │   │   │   │   # END handle token                                     │
│   252 │   │   │   # END handle refname                                       │
│   253 │   │   else:                                                          │
│                                                                              │
│ ╭────────────────────────── locals ──────────────────────────╮               │
│ │          lr = 6                                            │               │
│ │         obj = None                                         │               │
│ │ output_type = 'commit'                                     │               │
│ │   parsed_to = 0                                            │               │
│ │         ref = None                                         │               │
│ │        repo = <git.repo.base.Repo '/usr/src/git-sim/.git'> │               │
│ │         rev = 'HEAD^0'                                     │               │
│ │       start = 4                                            │               │
│ │       token = '^'                                          │               │
│ ╰────────────────────────────────────────────────────────────╯               │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/repo/fun.py:187 in               │
│ name_to_object                                                               │
│                                                                              │
│   184 │   │   raise BadName(name)                                            │
│   185 │   # END assert hexsha was found                                      │
│   186 │                                                                      │
│ ❱ 187 │   return Object.new_from_sha(repo, hex_to_bin(hexsha))               │
│   188                                                                        │
│   189                                                                        │
│   190 def deref_tag(tag: "Tag") -> "TagObject":                              │
│                                                                              │
│ ╭───────────────────────── locals ──────────────────────────╮                │
│ │       base = '%s'                                         │                │
│ │     hexsha = '0f1e3537ffa30234f208a6e9a390bcb603e25b4f'   │                │
│ │       name = 'HEAD'                                       │                │
│ │       repo = <git.repo.base.Repo '/usr/src/git-sim/.git'> │                │
│ │ return_ref = False                                        │                │
│ ╰───────────────────────────────────────────────────────────╯                │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/objects/base.py:94 in            │
│ new_from_sha                                                                 │
│                                                                              │
│    91 │   │   │   # the NULL binsha is always the root commit                │
│    92 │   │   │   return get_object_type_by_name(b"commit")(repo, sha1)      │
│    93 │   │   # END handle special case                                      │
│ ❱  94 │   │   oinfo = repo.odb.info(sha1)                                    │
│    95 │   │   inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha) │
│    96 │   │   inst.size = oinfo.size                                         │
│    97 │   │   return inst                                                    │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │  cls = <class 'git.objects.base.Object'>                                 │ │
│ │ repo = <git.repo.base.Repo '/usr/src/git-sim/.git'>                      │ │
│ │ sha1 = b'\x0f\x1e57\xff\xa3\x024\xf2\x08\xa6\xe9\xa3\x90\xbc\xb6\x03\xe… │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/db.py:40 in info                 │
│                                                                              │
│   37 │   │   self._git = git                                                 │
│   38 │                                                                       │
│   39 │   def info(self, binsha: bytes) -> OInfo:                             │
│ ❱ 40 │   │   hexsha, typename, size = self._git.get_object_header(bin_to_hex │
│   41 │   │   return OInfo(hex_to_bin(hexsha), typename, size)                │
│   42 │                                                                       │
│   43 │   def stream(self, binsha: bytes) -> OStream:                         │
│                                                                              │
│ ╭───────────────────────────────── locals ─────────────────────────────────╮ │
│ │ binsha = b'\x0f\x1e57\xff\xa3\x024\xf2\x08\xa6\xe9\xa3\x90\xbc\xb6\x03\… │ │
│ │   self = <git.db.GitCmdObjectDB object at 0x7fb5ea538a10>                │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/cmd.py:1383 in get_object_header │
│                                                                              │
│   1380 │   │                                                                 │
│   1381 │   │   :return: (hexsha, type_string, size_as_int)"""                │
│   1382 │   │   cmd = self._get_persistent_cmd("cat_file_header", "cat_file", │
│ ❱ 1383 │   │   return self.__get_object_header(cmd, ref)                     │
│   1384 │                                                                     │
│   1385 │   def get_object_data(self, ref: str) -> Tuple[str, str, int, bytes │
│   1386 │   │   """As get_object_header, but returns object data as well      │
│                                                                              │
│ ╭────────────────────────── locals ───────────────────────────╮              │
│ │  cmd = <git.cmd.Git.AutoInterrupt object at 0x7fb5e9297b00> │              │
│ │  ref = b'0f1e3537ffa30234f208a6e9a390bcb603e25b4f'          │              │
│ │ self = <git.cmd.Git object at 0x7fb5ea520c40>               │              │
│ ╰─────────────────────────────────────────────────────────────╯              │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/cmd.py:1370 in                   │
│ __get_object_header                                                          │
│                                                                              │
│   1367 │   │   if cmd.stdin and cmd.stdout:                                  │
│   1368 │   │   │   cmd.stdin.write(self._prepare_ref(ref))                   │
│   1369 │   │   │   cmd.stdin.flush()                                         │
│ ❱ 1370 │   │   │   return self._parse_object_header(cmd.stdout.readline())   │
│   1371 │   │   else:                                                         │
│   1372 │   │   │   raise ValueError("cmd stdin was empty")                   │
│   1373                                                                       │
│                                                                              │
│ ╭────────────────────────── locals ───────────────────────────╮              │
│ │  cmd = <git.cmd.Git.AutoInterrupt object at 0x7fb5e9297b00> │              │
│ │  ref = b'0f1e3537ffa30234f208a6e9a390bcb603e25b4f'          │              │
│ │ self = <git.cmd.Git object at 0x7fb5ea520c40>               │              │
│ ╰─────────────────────────────────────────────────────────────╯              │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/cmd.py:1329 in                   │
│ _parse_object_header                                                         │
│                                                                              │
│   1326 │   │   tokens = header_line.split()                                  │
│   1327 │   │   if len(tokens) != 3:                                          │
│   1328 │   │   │   if not tokens:                                            │
│ ❱ 1329 │   │   │   │   raise ValueError("SHA could not be resolved, git retu │
│   1330 │   │   │   else:                                                     │
│   1331 │   │   │   │   raise ValueError("SHA %s could not be resolved, git r │
│   1332 │   │   │   # END handle actual return value                          │
│                                                                              │
│ ╭─────────────────────── locals ───────────────────────╮                     │
│ │ header_line = b''                                    │                     │
│ │        self = <git.cmd.Git object at 0x7fb5ea520c40> │                     │
│ │      tokens = []                                     │                     │
│ ╰──────────────────────────────────────────────────────╯                     │
╰──────────────────────────────────────────────────────────────────────────────╯
ValueError: SHA could not be resolved, git returned: b''
In another repo, I get "Reference at 'HEAD' does not exist":
$ docker run --rm -v $(pwd):/usr/src/git-sim git-sim log
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /usr/local/lib/python3.11/site-packages/git_sim/log.py:64 in log             │
│                                                                              │
│   61 │   │   help="Display all local branches in the log output",            │
│   62 │   ),                                                                  │
│   63 ):                                                                      │
│ ❱ 64 │   scene = Log(ctx=ctx, n=n, all=all)                                  │
│   65 │   handle_animations(scene=scene)                                      │
│   66                                                                         │
│                                                                              │
│ ╭────────────────────── locals ───────────────────────╮                      │
│ │ all = False                                         │                      │
│ │ ctx = <click.core.Context object at 0x7fc7c9ace610> │                      │
│ │   n = None                                          │                      │
│ ╰─────────────────────────────────────────────────────╯                      │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git_sim/log.py:32 in __init__        │
│                                                                              │
│   29 │   │   self.all = all                                                  │
│   30 │   │                                                                   │
│   31 │   │   try:                                                            │
│ ❱ 32 │   │   │   self.selected_branches.append(self.repo.active_branch.name) │
│   33 │   │   except TypeError:                                               │
│   34 │   │   │   pass                                                        │
│   35                                                                         │
│                                                                              │
│ ╭────────────────────────── locals ───────────────────────────╮              │
│ │         all = False                                         │              │
│ │ all_command = False                                         │              │
│ │         ctx = <click.core.Context object at 0x7fc7c9ace610> │              │
│ │           n = 5                                             │              │
│ │   n_command = 5                                             │              │
│ │        self = <git_sim.log.Log object at 0x7fc7c958ef90>    │              │
│ ╰─────────────────────────────────────────────────────────────╯              │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/repo/base.py:896 in              │
│ active_branch                                                                │
│                                                                              │
│    893 │   │   :raises TypeError: If HEAD is detached                        │
│    894 │   │   :return: Head to the active branch"""                         │
│    895 │   │   # reveal_type(self.head.reference)  # => Reference            │
│ ❱  896 │   │   return self.head.reference                                    │
│    897 │                                                                     │
│    898 │   def blame_incremental(self, rev: str | HEAD, file: str, **kwargs: │
│    899 │   │   """Iterator for blame information for the given file at the g │
│                                                                              │
│ ╭───────────────────────── locals ──────────────────────────╮                │
│ │ self = <git.repo.base.Repo '/usr/src/0/.git/worktrees/1'> │                │
│ ╰───────────────────────────────────────────────────────────╯                │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/refs/symbolic.py:307 in          │
│ _get_reference                                                               │
│                                                                              │
│   304 │   │   """:return: Reference Object we point to                       │
│   305 │   │   :raise TypeError: If this symbolic reference is detached, henc │
│   306 │   │   │   to a reference, but to a commit"""                         │
│ ❱ 307 │   │   sha, target_ref_path = self._get_ref_info(self.repo, self.path │
│   308 │   │   if target_ref_path is None:                                    │
│   309 │   │   │   raise TypeError("%s is a detached symbolic reference as it │
│   310 │   │   return self.from_path(self.repo, target_ref_path)              │
│                                                                              │
│ ╭───────── locals ─────────╮                                                 │
│ │ self = <git.HEAD "HEAD"> │                                                 │
│ ╰──────────────────────────╯                                                 │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/refs/symbolic.py:210 in          │
│ _get_ref_info                                                                │
│                                                                              │
│   207 │   │   """Return: (str(sha), str(target_ref_path)) if available, the  │
│   208 │   │   rela_path points to, or None. target_ref_path is the reference │
│   209 │   │   point to, or None"""                                           │
│ ❱ 210 │   │   return cls._get_ref_info_helper(repo, ref_path)                │
│   211 │                                                                      │
│   212 │   def _get_object(self) -> Commit_ish:                               │
│   213 │   │   """                                                            │
│                                                                              │
│ ╭─────────────────────────── locals ────────────────────────────╮            │
│ │      cls = <class 'git.refs.head.HEAD'>                       │            │
│ │ ref_path = 'HEAD'                                             │            │
│ │     repo = <git.repo.base.Repo '/usr/src/0/.git/worktrees/1'> │            │
│ ╰───────────────────────────────────────────────────────────────╯            │
│                                                                              │
│ /usr/local/lib/python3.11/site-packages/git/refs/symbolic.py:193 in          │
│ _get_ref_info_helper                                                         │
│                                                                              │
│   190 │   │   │   # END for each packed ref                                  │
│   191 │   │   # END handle packed refs                                       │
│   192 │   │   if tokens is None:                                             │
│ ❱ 193 │   │   │   raise ValueError("Reference at %r does not exist" % ref_pa │
│   194 │   │                                                                  │
│   195 │   │   # is it a reference ?                                          │
│   196 │   │   if tokens[0] == "ref:":                                        │
│                                                                              │
│ ╭─────────────────────────── locals ────────────────────────────╮            │
│ │      cls = <class 'git.refs.head.HEAD'>                       │            │
│ │ ref_path = 'HEAD'                                             │            │
│ │     repo = <git.repo.base.Repo '/usr/src/0/.git/worktrees/1'> │            │
│ │  repodir = '/usr/src/0/.git/worktrees/1'                      │            │
│ │   tokens = None                                               │            │
│ ╰───────────────────────────────────────────────────────────────╯            │
╰──────────────────────────────────────────────────────────────────────────────╯
ValueError: Reference at 'HEAD' does not exist
Originally created by @durka on GitHub (Mar 7, 2023). Original GitHub issue: https://github.com/initialcommit-com/git-sim/issues/70 I followed the Docker installation instructions. <details><summary>Running git-sim in its own repo checkout results in an "SHA could not be resolved" error:</summary> ``` $ docker run --rm -v $(pwd):/usr/src/git-sim git-sim log Simulating: git log ╭───────────────────── Traceback (most recent call last) ──────────────────────╮ │ /usr/local/lib/python3.11/site-packages/git_sim/log.py:65 in log │ │ │ │ 62 │ ), │ │ 63 ): │ │ 64 │ scene = Log(ctx=ctx, n=n, all=all) │ │ ❱ 65 │ handle_animations(scene=scene) │ │ 66 │ │ │ │ ╭─────────────────────── locals ────────────────────────╮ │ │ │ all = False │ │ │ │ ctx = <click.core.Context object at 0x7fb5eaabbcd0> │ │ │ │ n = None │ │ │ │ scene = <git_sim.log.Log object at 0x7fb5ea5260d0> │ │ │ ╰───────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git_sim/animations.py:17 in │ │ handle_animations │ │ │ │ 14 │ │ 15 │ │ 16 def handle_animations(scene: Scene) -> None: │ │ ❱ 17 │ scene.render() │ │ 18 │ │ │ 19 │ if settings.video_format == "webm": │ │ 20 │ │ webm_file_path = str(scene.renderer.file_writer.movie_file_path │ │ │ │ ╭────────────────────── locals ──────────────────────╮ │ │ │ scene = <git_sim.log.Log object at 0x7fb5ea5260d0> │ │ │ ╰────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/manim/scene/scene.py:223 in render │ │ │ │ 220 │ │ """ │ │ 221 │ │ self.setup() │ │ 222 │ │ try: │ │ ❱ 223 │ │ │ self.construct() │ │ 224 │ │ except EndSceneEarlyException: │ │ 225 │ │ │ pass │ │ 226 │ │ except RerunSceneException as e: │ │ │ │ ╭─────────────────────── locals ───────────────────────╮ │ │ │ preview = False │ │ │ │ self = <git_sim.log.Log object at 0x7fb5ea5260d0> │ │ │ ╰──────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git_sim/log.py:42 in construct │ │ │ │ 39 │ │ │ │ f"{settings.INFO_STRING} {type(self).__name__.lower()}{ │ │ 40 │ │ │ ) │ │ 41 │ │ self.show_intro() │ │ ❱ 42 │ │ self.parse_commits() │ │ 43 │ │ self.parse_all() │ │ 44 │ │ self.recenter_frame() │ │ 45 │ │ self.scale_frame() │ │ │ │ ╭───────────────────── locals ──────────────────────╮ │ │ │ self = <git_sim.log.Log object at 0x7fb5ea5260d0> │ │ │ ╰───────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git_sim/git_sim_base_command.py:78 │ │ in parse_commits │ │ │ │ 75 │ │ prevCircle=None, │ │ 76 │ │ shift=numpy.array([0.0, 0.0, 0.0]), │ │ 77 │ ): │ │ ❱ 78 │ │ commit = commit or self.get_commit() │ │ 79 │ │ │ │ 80 │ │ isNewCommit = commit.hexsha not in self.drawnCommits │ │ 81 │ │ │ │ ╭──────────────────────── locals ─────────────────────────╮ │ │ │ commit = None │ │ │ │ i = 0 │ │ │ │ prevCircle = None │ │ │ │ self = <git_sim.log.Log object at 0x7fb5ea5260d0> │ │ │ │ shift = array([0., 0., 0.]) │ │ │ ╰─────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git_sim/git_sim_base_command.py:63 │ │ in get_commit │ │ │ │ 60 │ │ self.show_outro() │ │ 61 │ │ │ 62 │ def get_commit(self, sha_or_ref="HEAD"): │ │ ❱ 63 │ │ return self.repo.commit(sha_or_ref) │ │ 64 │ │ │ 65 │ def get_default_commits(self): │ │ 66 │ │ defaultCommits = [self.get_commit()] │ │ │ │ ╭──────────────────────── locals ─────────────────────────╮ │ │ │ self = <git_sim.log.Log object at 0x7fb5ea5260d0> │ │ │ │ sha_or_ref = 'HEAD' │ │ │ ╰─────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/repo/base.py:614 in commit │ │ │ │ 611 │ │ """ │ │ 612 │ │ if rev is None: │ │ 613 │ │ │ return self.head.commit │ │ ❱ 614 │ │ return self.rev_parse(str(rev) + "^0") │ │ 615 │ │ │ 616 │ def iter_trees(self, *args: Any, **kwargs: Any) -> Iterator["Tree │ │ 617 │ │ """:return: Iterator yielding Tree objects │ │ │ │ ╭────────────────────── locals ───────────────────────╮ │ │ │ rev = 'HEAD' │ │ │ │ self = <git.repo.base.Repo '/usr/src/git-sim/.git'> │ │ │ ╰─────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/repo/fun.py:250 in rev_parse │ │ │ │ 247 │ │ │ │ if token == "@": │ │ 248 │ │ │ │ │ ref = cast("Reference", name_to_object(repo, rev[: │ │ 249 │ │ │ │ else: │ │ ❱ 250 │ │ │ │ │ obj = cast(Commit_ish, name_to_object(repo, rev[:s │ │ 251 │ │ │ │ # END handle token │ │ 252 │ │ │ # END handle refname │ │ 253 │ │ else: │ │ │ │ ╭────────────────────────── locals ──────────────────────────╮ │ │ │ lr = 6 │ │ │ │ obj = None │ │ │ │ output_type = 'commit' │ │ │ │ parsed_to = 0 │ │ │ │ ref = None │ │ │ │ repo = <git.repo.base.Repo '/usr/src/git-sim/.git'> │ │ │ │ rev = 'HEAD^0' │ │ │ │ start = 4 │ │ │ │ token = '^' │ │ │ ╰────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/repo/fun.py:187 in │ │ name_to_object │ │ │ │ 184 │ │ raise BadName(name) │ │ 185 │ # END assert hexsha was found │ │ 186 │ │ │ ❱ 187 │ return Object.new_from_sha(repo, hex_to_bin(hexsha)) │ │ 188 │ │ 189 │ │ 190 def deref_tag(tag: "Tag") -> "TagObject": │ │ │ │ ╭───────────────────────── locals ──────────────────────────╮ │ │ │ base = '%s' │ │ │ │ hexsha = '0f1e3537ffa30234f208a6e9a390bcb603e25b4f' │ │ │ │ name = 'HEAD' │ │ │ │ repo = <git.repo.base.Repo '/usr/src/git-sim/.git'> │ │ │ │ return_ref = False │ │ │ ╰───────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/objects/base.py:94 in │ │ new_from_sha │ │ │ │ 91 │ │ │ # the NULL binsha is always the root commit │ │ 92 │ │ │ return get_object_type_by_name(b"commit")(repo, sha1) │ │ 93 │ │ # END handle special case │ │ ❱ 94 │ │ oinfo = repo.odb.info(sha1) │ │ 95 │ │ inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha) │ │ 96 │ │ inst.size = oinfo.size │ │ 97 │ │ return inst │ │ │ │ ╭───────────────────────────────── locals ─────────────────────────────────╮ │ │ │ cls = <class 'git.objects.base.Object'> │ │ │ │ repo = <git.repo.base.Repo '/usr/src/git-sim/.git'> │ │ │ │ sha1 = b'\x0f\x1e57\xff\xa3\x024\xf2\x08\xa6\xe9\xa3\x90\xbc\xb6\x03\xe… │ │ │ ╰──────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/db.py:40 in info │ │ │ │ 37 │ │ self._git = git │ │ 38 │ │ │ 39 │ def info(self, binsha: bytes) -> OInfo: │ │ ❱ 40 │ │ hexsha, typename, size = self._git.get_object_header(bin_to_hex │ │ 41 │ │ return OInfo(hex_to_bin(hexsha), typename, size) │ │ 42 │ │ │ 43 │ def stream(self, binsha: bytes) -> OStream: │ │ │ │ ╭───────────────────────────────── locals ─────────────────────────────────╮ │ │ │ binsha = b'\x0f\x1e57\xff\xa3\x024\xf2\x08\xa6\xe9\xa3\x90\xbc\xb6\x03\… │ │ │ │ self = <git.db.GitCmdObjectDB object at 0x7fb5ea538a10> │ │ │ ╰──────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/cmd.py:1383 in get_object_header │ │ │ │ 1380 │ │ │ │ 1381 │ │ :return: (hexsha, type_string, size_as_int)""" │ │ 1382 │ │ cmd = self._get_persistent_cmd("cat_file_header", "cat_file", │ │ ❱ 1383 │ │ return self.__get_object_header(cmd, ref) │ │ 1384 │ │ │ 1385 │ def get_object_data(self, ref: str) -> Tuple[str, str, int, bytes │ │ 1386 │ │ """As get_object_header, but returns object data as well │ │ │ │ ╭────────────────────────── locals ───────────────────────────╮ │ │ │ cmd = <git.cmd.Git.AutoInterrupt object at 0x7fb5e9297b00> │ │ │ │ ref = b'0f1e3537ffa30234f208a6e9a390bcb603e25b4f' │ │ │ │ self = <git.cmd.Git object at 0x7fb5ea520c40> │ │ │ ╰─────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/cmd.py:1370 in │ │ __get_object_header │ │ │ │ 1367 │ │ if cmd.stdin and cmd.stdout: │ │ 1368 │ │ │ cmd.stdin.write(self._prepare_ref(ref)) │ │ 1369 │ │ │ cmd.stdin.flush() │ │ ❱ 1370 │ │ │ return self._parse_object_header(cmd.stdout.readline()) │ │ 1371 │ │ else: │ │ 1372 │ │ │ raise ValueError("cmd stdin was empty") │ │ 1373 │ │ │ │ ╭────────────────────────── locals ───────────────────────────╮ │ │ │ cmd = <git.cmd.Git.AutoInterrupt object at 0x7fb5e9297b00> │ │ │ │ ref = b'0f1e3537ffa30234f208a6e9a390bcb603e25b4f' │ │ │ │ self = <git.cmd.Git object at 0x7fb5ea520c40> │ │ │ ╰─────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/cmd.py:1329 in │ │ _parse_object_header │ │ │ │ 1326 │ │ tokens = header_line.split() │ │ 1327 │ │ if len(tokens) != 3: │ │ 1328 │ │ │ if not tokens: │ │ ❱ 1329 │ │ │ │ raise ValueError("SHA could not be resolved, git retu │ │ 1330 │ │ │ else: │ │ 1331 │ │ │ │ raise ValueError("SHA %s could not be resolved, git r │ │ 1332 │ │ │ # END handle actual return value │ │ │ │ ╭─────────────────────── locals ───────────────────────╮ │ │ │ header_line = b'' │ │ │ │ self = <git.cmd.Git object at 0x7fb5ea520c40> │ │ │ │ tokens = [] │ │ │ ╰──────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────╯ ValueError: SHA could not be resolved, git returned: b'' ``` </details> <details><summary>In another repo, I get "Reference at 'HEAD' does not exist":</summary> ``` $ docker run --rm -v $(pwd):/usr/src/git-sim git-sim log ╭───────────────────── Traceback (most recent call last) ──────────────────────╮ │ /usr/local/lib/python3.11/site-packages/git_sim/log.py:64 in log │ │ │ │ 61 │ │ help="Display all local branches in the log output", │ │ 62 │ ), │ │ 63 ): │ │ ❱ 64 │ scene = Log(ctx=ctx, n=n, all=all) │ │ 65 │ handle_animations(scene=scene) │ │ 66 │ │ │ │ ╭────────────────────── locals ───────────────────────╮ │ │ │ all = False │ │ │ │ ctx = <click.core.Context object at 0x7fc7c9ace610> │ │ │ │ n = None │ │ │ ╰─────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git_sim/log.py:32 in __init__ │ │ │ │ 29 │ │ self.all = all │ │ 30 │ │ │ │ 31 │ │ try: │ │ ❱ 32 │ │ │ self.selected_branches.append(self.repo.active_branch.name) │ │ 33 │ │ except TypeError: │ │ 34 │ │ │ pass │ │ 35 │ │ │ │ ╭────────────────────────── locals ───────────────────────────╮ │ │ │ all = False │ │ │ │ all_command = False │ │ │ │ ctx = <click.core.Context object at 0x7fc7c9ace610> │ │ │ │ n = 5 │ │ │ │ n_command = 5 │ │ │ │ self = <git_sim.log.Log object at 0x7fc7c958ef90> │ │ │ ╰─────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/repo/base.py:896 in │ │ active_branch │ │ │ │ 893 │ │ :raises TypeError: If HEAD is detached │ │ 894 │ │ :return: Head to the active branch""" │ │ 895 │ │ # reveal_type(self.head.reference) # => Reference │ │ ❱ 896 │ │ return self.head.reference │ │ 897 │ │ │ 898 │ def blame_incremental(self, rev: str | HEAD, file: str, **kwargs: │ │ 899 │ │ """Iterator for blame information for the given file at the g │ │ │ │ ╭───────────────────────── locals ──────────────────────────╮ │ │ │ self = <git.repo.base.Repo '/usr/src/0/.git/worktrees/1'> │ │ │ ╰───────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/refs/symbolic.py:307 in │ │ _get_reference │ │ │ │ 304 │ │ """:return: Reference Object we point to │ │ 305 │ │ :raise TypeError: If this symbolic reference is detached, henc │ │ 306 │ │ │ to a reference, but to a commit""" │ │ ❱ 307 │ │ sha, target_ref_path = self._get_ref_info(self.repo, self.path │ │ 308 │ │ if target_ref_path is None: │ │ 309 │ │ │ raise TypeError("%s is a detached symbolic reference as it │ │ 310 │ │ return self.from_path(self.repo, target_ref_path) │ │ │ │ ╭───────── locals ─────────╮ │ │ │ self = <git.HEAD "HEAD"> │ │ │ ╰──────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/refs/symbolic.py:210 in │ │ _get_ref_info │ │ │ │ 207 │ │ """Return: (str(sha), str(target_ref_path)) if available, the │ │ 208 │ │ rela_path points to, or None. target_ref_path is the reference │ │ 209 │ │ point to, or None""" │ │ ❱ 210 │ │ return cls._get_ref_info_helper(repo, ref_path) │ │ 211 │ │ │ 212 │ def _get_object(self) -> Commit_ish: │ │ 213 │ │ """ │ │ │ │ ╭─────────────────────────── locals ────────────────────────────╮ │ │ │ cls = <class 'git.refs.head.HEAD'> │ │ │ │ ref_path = 'HEAD' │ │ │ │ repo = <git.repo.base.Repo '/usr/src/0/.git/worktrees/1'> │ │ │ ╰───────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/lib/python3.11/site-packages/git/refs/symbolic.py:193 in │ │ _get_ref_info_helper │ │ │ │ 190 │ │ │ # END for each packed ref │ │ 191 │ │ # END handle packed refs │ │ 192 │ │ if tokens is None: │ │ ❱ 193 │ │ │ raise ValueError("Reference at %r does not exist" % ref_pa │ │ 194 │ │ │ │ 195 │ │ # is it a reference ? │ │ 196 │ │ if tokens[0] == "ref:": │ │ │ │ ╭─────────────────────────── locals ────────────────────────────╮ │ │ │ cls = <class 'git.refs.head.HEAD'> │ │ │ │ ref_path = 'HEAD' │ │ │ │ repo = <git.repo.base.Repo '/usr/src/0/.git/worktrees/1'> │ │ │ │ repodir = '/usr/src/0/.git/worktrees/1' │ │ │ │ tokens = None │ │ │ ╰───────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────╯ ValueError: Reference at 'HEAD' does not exist ``` </summary>
kerem closed this issue 2026-03-02 16:47:43 +03:00
Author
Owner

@initialcommit-io commented on GitHub (Mar 7, 2023):

@durka Hmm I just tested locally on my Mac and was able to run the Dockerized git-sim commands.

The errors you're getting are a bit weird since it seems it's not able to find a reference to HEAD in the local Git repo, which is odd because HEAD should always be present in a non-corrupt Git repo.

Did you clone down the git-sim repo and not just download it from GitHub? Basically just want to make sure it's a valid Git repo. You can confirm by running git show HEAD, or just a git log to make sure that HEAD is set and accessible.

Can you also let me know the OS you're on and exactly what commands you ran and in what order?

<!-- gh-comment-id:1459012074 --> @initialcommit-io commented on GitHub (Mar 7, 2023): @durka Hmm I just tested locally on my Mac and was able to run the Dockerized git-sim commands. The errors you're getting are a bit weird since it seems it's not able to find a reference to HEAD in the local Git repo, which is odd because HEAD should always be present in a non-corrupt Git repo. Did you clone down the git-sim repo and not just download it from GitHub? Basically just want to make sure it's a valid Git repo. You can confirm by running `git show HEAD`, or just a `git log` to make sure that HEAD is set and accessible. Can you also let me know the OS you're on and exactly what commands you ran and in what order?
Author
Owner

@durka commented on GitHub (Mar 9, 2023):

Hey, I'm running on Ubuntu 22.04, though what's weird is you'd think that wouldn't matter with Docker.

I ran these commands:

$ docker build -t git-sim .
$ dgit-sim() { docker run --rm -v $(pwd):/usr/src/git-sim -e git_sim_media_dir=/tmp git-sim "$@"; }
$ export git_sim_media_dir=/tmp
$ git-sim log
Simulating: git log
Output image location: /tmp/git-sim_media/git-sim/images/git-sim-log_03-09-23_01-13-58.jpg
$ dgit-sim log
<error shown above>
ValueError: SHA could not be resolved, git returned: b''
<!-- gh-comment-id:1461138601 --> @durka commented on GitHub (Mar 9, 2023): Hey, I'm running on Ubuntu 22.04, though what's weird is you'd think that wouldn't matter with Docker. I ran these commands: ``` $ docker build -t git-sim . $ dgit-sim() { docker run --rm -v $(pwd):/usr/src/git-sim -e git_sim_media_dir=/tmp git-sim "$@"; } $ export git_sim_media_dir=/tmp $ git-sim log Simulating: git log Output image location: /tmp/git-sim_media/git-sim/images/git-sim-log_03-09-23_01-13-58.jpg $ dgit-sim log <error shown above> ValueError: SHA could not be resolved, git returned: b'' ```
Author
Owner

@initialcommit-io commented on GitHub (Mar 9, 2023):

@durka I wonder if it's just a file permissions issue, where the dockerized instance of the command doesn't have access to the local files in your Git repo and the Git repo itself (.git folder). This might be causing GitPython - the library that git-sim uses to interact with the local Git repo - to choke.

Can you try running the docker command with sudo?

<!-- gh-comment-id:1461243986 --> @initialcommit-io commented on GitHub (Mar 9, 2023): @durka I wonder if it's just a file permissions issue, where the dockerized instance of the command doesn't have access to the local files in your Git repo and the Git repo itself (.git folder). This might be causing GitPython - the library that git-sim uses to interact with the local Git repo - to choke. Can you try running the docker command with sudo?
Author
Owner

@durka commented on GitHub (Mar 9, 2023):

Ah you're right, it is permissions. It seems the docker container runs as root internally. If I redefine the function like so, it works (sudo not required, I didn't try that but I don't like to run stuff as sudo normally):

dgit-sim() { docker run --rm -v $(pwd):/usr/src/git-sim -u $(id -u):$(id -g) git-sim "$@"; }

(btw, also note the semicolon which is missing from the README)

<!-- gh-comment-id:1461349849 --> @durka commented on GitHub (Mar 9, 2023): Ah you're right, it is permissions. It seems the docker container runs as root internally. If I redefine the function like so, it works (sudo not required, I didn't try that but I don't like to run stuff as sudo normally): ``` dgit-sim() { docker run --rm -v $(pwd):/usr/src/git-sim -u $(id -u):$(id -g) git-sim "$@"; } ``` (btw, also note the semicolon which is missing from the README)
Author
Owner

@initialcommit-io commented on GitHub (Mar 9, 2023):

Nice! Glad you got it to work. I'll add the semi-colon. I'll close this one since you got it working 😸

<!-- gh-comment-id:1462910885 --> @initialcommit-io commented on GitHub (Mar 9, 2023): Nice! Glad you got it to work. I'll add the semi-colon. I'll close this one since you got it working 😸
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-sim#45
No description provided.