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
+1
View File
@@ -0,0 +1 @@
ref: refs/heads/master
+5
View File
@@ -0,0 +1,5 @@
[core]
repositoryformatversion = 0
filemode = false
bare = false
+1
View File
@@ -0,0 +1 @@
Unnamed repository; edit this file 'description' to name the repository
Binary file not shown.
@@ -0,0 +1,2 @@
xśUŽÍ
Â0„=úcEHĄ?ŕAko>xRi“¶š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{Ç :ĘđÄ/â{˛Ó˘? ¤ł©Ć =•]Ó
@@ -0,0 +1,2 @@
xœU1NÅ@ D©‘¸Ã” ¡(_ÿtTˆ"øNâ‹Ýuäõ~NÏ&­=óf¦ÚãÜžo:EÉ cL²m}Ù6,¦³Q|ÄU + â˜Lã!4FJcÄ
^h•™œw¹ÁÙ¢$
@@ -0,0 +1,2 @@
xœ5A
Â0]z‡·ËF*uçÖ…Ð ¤íkˆùú“PééZwÃÀ0C”ýùrxøñRqjŸXBŒpLT[‹Ìwe ™ana]
@@ -0,0 +1,2 @@
xœMÌ=
€0 @açž"ÒÐôgô(5è ‰÷Wœ\|Oú¾oq°Kç:s+Tü‘S%¦#¡æÌsÁ|âèêmk¿à•0މ½“ïdúonj
@@ -0,0 +1,2 @@
xœ]A0D]“p‡cR 1";náJYÆ»ÛVÅà_ýÌëÌŸæm—#
wE;” q¯Ê–çÛ&u™È»?­âã˜ãhe×áBáJ¹ f¡².
@@ -0,0 +1,2 @@
xœ5A
Â0]r‡·ËF*Š'páôiûšÚ|M~héé­»a`˜v’çëåðŒcÁ+KÈ~Æ2N³W£ð]™:B¸û¸mŽåw«;ùÔÿünk¬yè¥;Õâ]ƒdDY \üEfB¹ª5
@@ -0,0 +1,2 @@
xœMÌ;
€0@ëœb/ h>$[z”$û‚A+x|ÁÊvŠ©Wï§ó¤ NhðVÒšŠÏÞ•šE6Ë®H`—lÜL¾õ¸‘‹4Ï1l¦~‘âof¡,>j^ tñ
@@ -0,0 +1 @@
a3de24d2748d8aff1eb5d785d7a08b0aaa46d76b
@@ -0,0 +1 @@
a3de24d2748d8aff1eb5d785d7a08b0aaa46d76b
+12 -5
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
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
View File