Committing Without Git
matheustavares.gitlab.io
matheustavares.gitlab.io
git archive --remote=ssh://host/pathto/repo.git HEAD README.md | tar xO
Though apparently support depends on how you're running git, and potentially some enabled server side options.[1] https://stackoverflow.com/questions/1125476/retrieve-a-singl...
git clone --filter=tree:0 --depth=1 --sparse --no-checkout && git checkout HEAD <desired_file>
(But that would still end up fetching a few more objects than just the desired file.)
(I would assume git doesn't trust the server, and will verify that the chain of hashes works out.)
"Fun" is a good reason for this sort or exploration, but it also has its practical uses. For instance, I use `isomorphic-git` (a git client written in JavaScript) to include a comment with the relevant commit hash in my bundled JavaScript. I can run it on any machine with Node, without opening a shell or trying to find where/if git is installed locally.
#@title Give your cell a headline
%%js_module
where js_module is defined here: # Copyright 2023 Google LLC.
# SPDX-License-Identifier: Apache-2.0
from IPython.core.display import display, HTML
from IPython.core.magic import register_cell_magic
import time
@register_cell_magic
def js_module(line, cell):
if cell.startswith('http'):
src, hash = cell.split('#') if '#' in cell else [cell, '']
timestamp = time.time() if 'cachebust' in line else ''
display(HTML(
"<script type = 'module' src = '{src}?{timestamp}'></script>".format(src = src, hash = hash, timestamp = timestamp)
))
else:
display(HTML(
"<script type = 'module'>{cell}</script>".format(cell = cell)
))
The #@title lets you collapse the cell, so the JavaScript isn't showing. Colab has a strong philosophy of ensuring the user can see everything they're running, so I don't think there's a better way to encapsulate the bundled JS.Blog posts are becoming my favourite form of knowledge transfer
I’ve been meaning to start one myself and posts like this are making me move it up my todo list
A few months ago I figured out how to modify remote refs in a similar fashion although I wrote it in go. https://stackoverflow.com/a/77210784/308851
$ TEST_VAR="$(printf 'first\0second')"
bash: warning: command substitution: ignored null byte in input
I'm not familiar with working with null characters in Bash in this way, but I think there might be a way to do it.One option with shells is some set/get functions that encode/decode to base64, hex, etc. Feels pretty clunky though.