mirror of
https://github.com/initialcommit-com/git-sim.git
synced 2026-04-26 19:15:51 +03:00
[GH-ISSUE #22] Feature request - show branches unrelated to the current command being simulated #16
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/git-sim#16
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 @ryanmcfall on GitHub (Jan 25, 2023).
Original GitHub issue: https://github.com/initialcommit-com/git-sim/issues/22
It would be nice if there was a way to include branches that won't be changed by the command being simulated to help the user of the tool visualize which commits those branches reference in addition to the ones that will change.
For example, I have might have a
mainbranch along with two feature branchesMessagePostandPhotoPost, which share a common parent, and have a single commit that is not yet merged intomain.If I
git switch mainand then executegit-sim merge MessagePost, the simulation very nicely shows me that theMessagePostandmainpointers now point to the same commit, the one added to theMessagePostbranch. ThePhotoPosttip will still point at a commit whose parent is the original common parent ofMessagePostandPhotoPost. It would be instructional to see thatPhotoPostdoesn't move.Maybe add an option to
git-simthat allows the user to specify additional branches besidesHEADand any branches that are actually involved in the simulated operation.For context, I am teaching a university class on Git, and I think my students could really benefit from seeing this information. It's available using
git log --graph --all, but the visualizations provided bygit-simare much nicer.@initialcommit-io commented on GitHub (Jan 26, 2023):
@ryanmcfall Yes the main thing I'm working on at the moment is a more robust way for the tool to show multiple branches at once in addition to more complex branching structures. I will take into account your suggestion. More to come on this soon.
@ryanmcfall commented on GitHub (Jan 27, 2023):
Thanks @initialcommit-io. If you would like someone to beta test anything you come up with, I'm happy to do so.
I made a quick stab at trying this myself, working with the
git statuscommand. Maybestatusorlogor both are the appropriate places to show additional branches, and the other commands don't really need them. Supportinggit log --all --decorate --graphmight make the most sense, since it includes options that are already available as part of the base git commands. But I can certainly see how it might get hard to generate a visualization of a very large repository.@initialcommit-io commented on GitHub (Jan 27, 2023):
Yes, before I get to this I need to at least update Git log to properly show branch divergences strating from a single branch head, by tracing back the parent/child relationships. For the initial version of Git-Sim I wanted to get something out there to see if anyone would be interested, so it just does something super simple by listing out X commits from the history and connecting them with arrows, but it wouldn't even necessarily properly pick up branch divergences yet. I have an initial working version of this but just hammering out the issues before releasing it. This will be released as a part of
git-sim logbefore the other commands.Keep in mind this is a different issue than the one you suggested, which is to show multiple branches starting from their diverged heads. My change outlined above will only show divergences in the history of a single branch, to start.
Once that's done we can start applying it to other commands, and after that, I think we can get to your suggestion :D.
I'm also curious about looking into a network-building dependency that might help better represent the DAG and make it easier to work with and draw using Manim.
If you'd like to contribute we can try to brainstorm/research/test some different options.
However, it might be beneficial for you to get a feel for the codebase before we get into that - I might recommend taking a crack at #15 which is a request to add
git switch/git checkoutas a supported git-sim subcommand.@initialcommit-io commented on GitHub (Mar 3, 2023):
Hi @ryanmcfall ! Sorry for the delay on this one. I just completed a large refactoring of how git-sim parses commit history by following the parent/child relationships recursively. This allows more accurate graphs to be drawn as well as the implementation of some new flags/options to get the "git log --all --graph" behavior you mentioned.
You'll need to update to git-sim version 0.2.6 to take advantage of these new features:
There are 2 new global flags/options that you can play with:
The
--allglobal flag can be used with any subcommand that doesn't draw a table, and includes all unrelated branch heads in the graph that have no children (i.e. all true branch heads that aren't ancestors of other branches)The
-n <number>global option can be used to specify the max number of commits to trace back from each branch head, and can be used with any subcommand that doesn't draw a table. By default this is set to 5 for all subcommands, but you can use it to show as many commits in the graphs as you'd like!Give it a test and let me know how it works for you!
PS: One thing I still haven't added is the ability to specify exactly which unrelated branches would want to be seen, in the case there are very many --all could get unruly. So hopefully I'll add that sometime relatively soon...
@initialcommit-io commented on GitHub (Mar 25, 2023):
Closing since this feature was released several weeks ago.