Files
DIY_GIT_in_Python/how_to/Change_24.md
2024-04-23 17:36:02 +02:00

843 B
Raw Blame History

  • base: Try different directories when searching for a ref

In the previous change, you might have noticed that we need to spell out the full name of a tag (Like refs/tags/mytag). This isnt very convenient, we would like to have shorter command names. For example, if weve created “mytag” tag, we should be able to do ugit log mytag rather than having to specify ugit log refs/tags/mytag.

Well extend get_oid to search in different ref subdirectories when resolving a name. Well search in:

    Root (.ugit): This way we can specify refs/tags/mytag
    .ugit/refs: This way we can specify tags/mytag
    .ugit/refs/tags: This way we can specify mytag
    .ugit/refs/heads: This will be needed for a future change

If we find the requested name in any of the directories, return it. Otherwise assume that the name is an OID.