Compare commits

...

5 Commits

Author SHA1 Message Date
Nathan McRae
646ca42e6f Add example repository 2024-07-21 16:49:10 -07:00
Nathan McRae
9200690b69 Rename main script to subcommit-git 2024-07-21 16:47:05 -07:00
Nathan McRae
69befa481e Add readme 2024-07-21 16:46:27 -07:00
Nathan McRae
08771733b1 Allow first commit in repo
Before you had to do it through vanilla git
2024-07-20 09:29:52 -07:00
Nathan McRae
77bdcc1024 Change repo dir from .git to .subcommit-git 2024-07-20 09:29:05 -07:00
55 changed files with 40 additions and 5 deletions

View File

@ -0,0 +1 @@
ref: refs/heads/master

View File

@ -0,0 +1,5 @@
[core]
repositoryformatversion = 0
filemode = false
bare = false

View File

@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository

Binary file not shown.

View File

@ -0,0 +1,2 @@
xśUŽÍ
Â0„=úcEHĄ<48>?ŕAko><3E>xRi“¶<E2809C>šJ˝<>ďî&jĹ=-3;ßNŢ´9Ő`¤tŃÜ„DÚYѨ|Zgađ'ŞÖka ´Ĺ…+ÍÜÂMU$(jn0ˇý~<Çx„hT ćl ·XöŞňj([2˘JcD‡ŽWrŤqç>qc3¤R줣ž:;Ç_ŢH{3óŹôt­üG*äóŘŰV1źť÷Yç÷Ď]x÷íjE{Ç :ĘđÄ/â{˛Ó˘? ¤ł©Ć =•]Ó

View File

@ -0,0 +1,2 @@
xœU<EFBFBD>1NÅ@ ¸Ã” ¡(_ÿtTˆ"øNâÝuäõ~NÏ&­=óf¦ÚãÜžo:EÉ cL²m}Ù6,¦³Q|ÄU + â˜Lã!4FJc<4A>Ä ^h•™œw¹ÁÙ¢$
p=¤A<04>þ§ð'Å©Œ{5Ð8Ö?ùŸ¡âëS÷ ˜¦ÈɱÉî{@íðÓ-È;ãòK?áÔ¶—]<5D>ôÙ\vsÞ×­2òXOß»S‰=[Þó²“ùAÍ® jã¼ðà²r¸6w·_¥jp%

View File

@ -0,0 +1,2 @@
xœ5<EFBFBD>A
Â0]z‡·ËF*uçÖ…Ð ¤íkˆùú“PééZwÃÀ0C”ýùrxø<78>ñRqjŸXBŒpLT[Ìwe ™ana] óæZw²iÚünº¶i;‰IÆSÍÖ±+ŸY^<14>Ö„âù?þ‚/“?.

View File

@ -0,0 +1,2 @@
xœMÌ=
€0 @açž"ÒÐôgô(5<>è ‰÷Wœ\|Oú¾oq°K<15>ç:s+TüÂS%¦#¡æÌsÁ<73>|âèêmk¿à•0Ž‰½“ïdúonj ¤¢§AëâˆYÿ

View File

@ -0,0 +1,2 @@
xœ]<5D>A0D]“p‡cR 1";náJYÆ»ÛVÅà_ýÌëÌŸæm—#
wE;” q¯ÊçÛ&u<>™È»?­âã˜ãhe×áBáJ¹ f¡². •Øèý~Î|<\zxb0 ¢I5SݤöVDcRðN=­ÙëÞ ˆ™(Ó‹ðØÔ]æ~ÉÔ Â<>ô4­ìE]Èú‘€ªŽë '¯á:wF÷¾ù÷£Ä†æ­<C3A6>:ÿp[<5B>

View File

@ -0,0 +1,2 @@
xœ5<EFBFBD>A
Â0]r‡·ËF*Š'páôiûšÚ|M~héé­»a`˜vçëåðŒcÁ+KÈ~Æ2N³W£ð]™:B¸û¸mŽåw«;ùÔÿünk¬y<C2AC>è¥;Õâ]ƒdDY \üEfB¹ª5

View File

@ -0,0 +1,2 @@
xœMÌ;
€0@ëœb/ h>$[z”$û‚A+x|ÁÊvŠ©Wï§ó¤ Nhð<01>VÒšŠÏÞ•šE6Ë®H`—l<E28094>ÜL¾õ¸4Ï1l¦~âof¡<>,>j^ tñ

View File

@ -0,0 +1 @@
a3de24d2748d8aff1eb5d785d7a08b0aaa46d76b

View File

@ -0,0 +1 @@
a3de24d2748d8aff1eb5d785d7a08b0aaa46d76b

View File

@ -50,7 +50,7 @@ class GitRepository (object):
def __init__(self, path, force=False):
self.worktree = path.replace("\\", "/")
self.gitdir = join_path(path, ".git")
self.gitdir = join_path(path, ".subcommit-git")
if not (force or os.path.isdir(self.gitdir)):
raise Exception(f"Not a git repository {path}")
@ -156,7 +156,7 @@ def cmd_init(args):
def repo_find(path=".", required=True):
path = os.path.realpath(path)
if os.path.isdir(join_path(path, ".git")):
if os.path.isdir(join_path(path, ".subcommit-git")):
return GitRepository(path)
# If we haven't returned, recurse in parent
@ -1093,7 +1093,7 @@ def check_ignore(rules, path):
raise Exception("This function requires path to be relative to the repository's root")
# Eh, just hardcode it
if (path.startswith(".git")):
if (path.startswith(".subcommit-git")):
return True
result = check_ignore_scoped(rules.scoped, path)
@ -1487,6 +1487,7 @@ def tree_from_index(repo, index, commit_map, author, commit_time, message):
if path in commit_map:
(subcommit_hash, subcommit) = commit_map[path]
else:
subcommit_hash = None
subcommit = None
if subcommit == None or subcommit.kvlm[b'tree'] != sha.encode('ascii'):
@ -1530,12 +1531,18 @@ def cmd_commit(args):
repo = repo_find()
index = index_read(repo)
root_commit_sha = object_find(repo, "HEAD")
root_commit = object_read(repo, root_commit_sha)
if root_commit_sha:
root_commit = object_read(repo, root_commit_sha)
else:
root_commit = None
commit_time = datetime.now()
author = gitconfig_user_get(gitconfig_read())
commit_map = create_commit_map(repo, root_commit)
if root_commit:
commit_map = create_commit_map(repo, root_commit)
else:
commit_map = dict()
tree = tree_from_index(repo,
index,

5
readme.txt Normal file
View File

@ -0,0 +1,5 @@
This is an implementation of alternate git internals where trees point to subcommits rather than other trees. This allows subdirectory history tracking to be baked into the repository structure.
This is based on Write Yourself a Git (https://wyag.thb.lt/)
Note that this requires >= Python 3.10