mirror of
https://github.com/initialcommit-com/git-sim.git
synced 2026-04-26 19:15:51 +03:00
[GH-ISSUE #95] Two branches without common commit? git-annex use case #59
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/git-sim#59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yarikoptic on GitHub (Jul 6, 2023).
Original GitHub issue: https://github.com/initialcommit-com/git-sim/issues/95
Originally assigned to: @initialcommit-io on GitHub.
https://git-annex.branchable.com is a tool to manage data within git. To do that, git-annex creates and manipulates
git-annexbranch. You can see a collection of such repositories at https://github.com/dandisets , http://datasets.datalad.org/, etc.It would have been cool if I could provide git-sim which would describe some basic use cases, such as
so I wondered how to use
git-simto visualize the history here with two branches.@initialcommit-io commented on GitHub (Jul 6, 2023):
Hi @yarikoptic,
Thanks for your interest in git-sim! It sounds like this is a new feature request. Can you describe in more detail what you're looking for? I don't have experience with git-annex so if you can provide more details on that and how git-sim would relate to it / interact with it in your proposed feature I can get a better understanding of what you mean.
@yarikoptic commented on GitHub (Jul 6, 2023):
Here is a bash script which implements "above" example (note - you would need git-annex)
I also shared a sample of that repo at http://www.oneukrainian.com/tmp/dl-Hq2CrkR.tgz (after removing
dl-Hq2CrkR/origin/git-sim_media/).Overall what seems to be missing are
to be able to make video follow commits in chronological order as in commit times (I made them specifically to be produced 1 second apart).
somehow "annotate" each step in the video with the command which resulted in that change (not just
"update"commit of thegit-annexbranch) -- would have been awesome.git-simseems to implement a number ofgitcommands to provide those demonstrations but more detailed as on what effecting the tree/staging area etc. If we could annotate all commands "natively", would have been cool.A wild uncooked idea on how to do it - at least in POSIX shell (or bash specifically)... In the bash script above I used
export PS4='> $(sleep 1)'to slow down... may be we could abuse it orPROMPT_COMMANDto make a record somewhere (git notes?) of timestamp and command to be executed. Then while creating animation read out those times and match to commit times to discover which command triggered any particular action, thus providing text/annotation. then anyone could script their desired interactions "natively", and only do smth likePROMPT_COMMAND="git sim record $PROMPT_COMMAND"to make such records.@initialcommit-io commented on GitHub (Jul 7, 2023):
Thanks for the details. If I understand correctly, it sounds like git-annex creates additional branches that are used for helping to track large files?
Anyway, one thing you can try is using the
--allglobal flag which will display all local branches in the git-sim output:git-sim --all loggit-sim --all branch new_branchgit-sim --all -n 10 merge devetc...
Note this might show more branches than you want, and currently there isn't a way to specify exactly which branches to show.
If you need it, we can do an enhancement to create a new option to allow specific branch names to be specified, if showing all branches is too much.
@initialcommit-io commented on GitHub (Jul 10, 2023):
@yarikoptic Hi again just wanted to check if you saw my last comment and tested out my suggestion for this.
@yarikoptic commented on GitHub (Jul 10, 2023):
just one branch, always named the same and which users should not even bother to ever checkout or merge manually --
git-annex. Since I seegit-simprimarily to use on some demo repos -- I do not have immediate need for filtering out branches ----allis good enough.well, as I showed in that snippet (folded by default) in comment above -- indeed I tried
git-sim --all logand it worked and I have triedgit sim --animate log --allwhich gave me very lovely animation but as I pointed out in that comment -- events were not happening in the chronological order of the commits, thus limit the "demonstration utility". Should I may be file a separate issue for that chronological aspect?the other limitation, on which I have tried to come up with an idea for a solution, is annotation of changes in the
animatewith actual commands which lead to the change, without explicitly needing to redo the script withgit-simalternatives since there are none forgit-annexcommands.@initialcommit-io commented on GitHub (Jul 10, 2023):
Oh ok I think I understand a little better now. So that's a good point about the chronological order of commits - currently git-sim parses commits by tracing the parent/child relationships, so the order is not necessarily chronological depending on merges from other branches and other scenarios.
It's a good point because I believe by default Git's actual log commands does produce chronological commit order... so let me look into adding that. It would be nice if you could create a new issue for that.
I'm still not 100% clear on exactly what you're looking for with the annotations. It sounds like you're looking for a list of commands to be included in the images/videos, to help users understand how the commit structure came about.
It might be possible to use Git's reflog for that, at least for as long as Git keeps the reflog entries around. We could also use Git notes or something like you mentioned to link specific annotations to each commit, which Git-Sim could pick up on and use in the display. But of course this would rely on the user to add a note to every commit.
The other question is where to display the annotations in the output. Should it replace the commit message? Or somehow make more room for the message?
@yarikoptic commented on GitHub (Jul 10, 2023):
done: #96
yes
it might indeed work for some which change current HEAD, but would not work for my use case where command is changing not (only) HEAD but some other reference (
git-annexbranch)And that is where I was hypothesizing on how to automate it in that comment . Did a prototype -- this tiny helper
and run on some sample script with
gitand other needed commands like the one I gave above (now removed some git-sim invocation etc):and then running like
NB note that we are swallowing all stderr here into our log file
we get:
and thus all time stamped invocations for all commands, so that some
--animatecould figure out what commit was produced by what (preceeding in time)gitcommand.I thought like "closed captions" at the bottom appear for the duration whenever animation of commit(s) being created displayed
@yarikoptic commented on GitHub (Jul 10, 2023):
a "gotcha" is that git is likely not recording subsecond resolution for any of those "dates" so any "demo" script would still need to abuse
PS4to do some sleeping... well -- that record-commands4sim.sh could do that I guess -- it would delay execution but I think that is ok@initialcommit-io commented on GitHub (Jul 11, 2023):
Ok thanks for spelling it out for me - I am not that great with shell. But now I see what you have in mind.
My thoughts are that this deviates a little bit from the purpose of git-sim, which is to allow the simulation of Git subcommands on an existing repo (aside from clone and init which obviously don't start with an existing local copy).
It seems your use case is more to simulate a flow of git commands of a whole workflow - in this case with git-annex - as opposed to showing the result of a specific Git subcommand.
But this got me thinking - as a part of git-sim, I wrote a simple Python dependency called git-dummy. In fact this is already installed by default when git-sim is installed. The purpose of git-dummy is to generate dummy Git repos (basically sample repos with fake data) that are in a desired state for executing the desired git-sim subcommand. For example you can choose the number of commits, branches, merges, divergence-points, merge-locations, etc...
I wonder if adding a new feature to git-dummy would make more sense than modifying git-sim itself for this. For example, we could add a feature in git-dummy that would override the default repo generation and allow specification of a custom set of commands to run on the repo instead - similar to the set of commands you provided:
Maybe this could be specified in a file that gets passed in as a command-line arg, like:
git-dummy --input-file=commands.txtSince git-dummy is actually generating the git repo, we can add a flag to create a Git note with each commit, corresponding somehow to the command specified in the file. Although it might get a bit hairy with commands that don't explicitly lead to a new commit (which we could possibly handle with a manual symbol added in the input file), and would rely on specified commands to be available locally.
Anyway, at this point the Git notes would be populated with the "closed caption" data, so it should be simple to ingest those from git-sim and add them to the animations (while using chronological order based on the other ticket you raised).
Maybe I'm missing something that makes this method completely not work, but please let me know your thoughts.
@initialcommit-io commented on GitHub (Jul 11, 2023):
Also I would probably try and avoid stuff like correlating timestamps and intentional program delay which could get messy and slow down the performance. Wouldn't using Git notes remove the need for this since each "closed caption" note would be associated with its corresponding commit upon creation, so no need to correlate timestamps or introduce delays?
@yarikoptic commented on GitHub (Jul 11, 2023):
no - avoiding bash hackery sounds like a good way forward! Indeed it could be a helper which runs "one line at a time" and adds corresponding command to git notes... the "problem" could be that git notes IIRC would associate with a particular commit but
git annexcommands would operate on some other branch and may be generate multiple commits (IIRC it should be possible). so may begit noteswould not be the best storage. I guess ideally that helper for each line execution could be a list of records stored in yaml or json with fieldswith the last record at the end without any
commandvalue. Then it would be possible to rebuild entire history -- what refs appeared, what commits where done between different states of refs etc.@initialcommit-io commented on GitHub (Jul 11, 2023):
Currently everything in git-sim is done based on commits, so I was assuming that annotations would be linked to individual commits to show what command resulted in that commit. That is why it seemed OK to use something like Git notes so that the code could just grab the associated annotation (if exists) and display it while drawing the commit. But maybe I'm missing something with how git-annex (or other technically non-git commands) should be represented.
Again I would assume that even if storing the annotation info in a data file you could just store commit ID along with each annotation. Why correlate timestamps if we can just store the commit ID? But it seems the you're thinking of a different representation?
@yarikoptic commented on GitHub (Jul 11, 2023):
I am thinking of use cases where a git command could result in multiple commits across multiple branches. Let me give an example:
so, indeed , in principle, you can
git notesboth of those commits f6cc3d314a25029523640a0df5acc6e28fd6598c and 3efcf509bbd04a833edee5e45599fc3cfbfe90ac (didn't check but there could be multiple actually on git-annex branch) with the same command (git commit -m ...' -a), but then may be you would kinda need to reconstruct the fact that it was the same single command which produced both of the commits, right?NB my greedy wish here is to eventually use not only
gitcommands butdataladcommands too -- and those could easily create more than one commit across different branches, e.g.datalad createalone isgit init; git annex init; git add .datalad/config; git commitin a nutshell;datalad addurlscould add gzillion of files/urls and create git submodules etc...)FWIW, if going
git notesway -- might be worth making those notes "machine readable" (we do similar indatalad run, see e.g. any of those commit messages https://github.com/search?q=datalad+runcmd&type=commits) and have it likethen listing the
git noteswould indeed allow to uniquely and unambigously associated even multiple commits with the samegit_sim_id-- no interpolation or anything. But helper should add git-notes for all commits which were generated by running a command.NB: adding multiple notes for the same commit could be tricky - would require reading old one and adding a new one, so multiple records for different "things" could co-exist I guess if so desired
@initialcommit-io commented on GitHub (Apr 18, 2024):
Closing without implementation as the effort to implement such a thing likely outweighs the demand from a user perspective. However, if more folks request this I will reconsider.