timbrel / GitSavvy

Full git and GitHub integration with Sublime Text
MIT License
1.9k stars 135 forks source link

GRAPH: Option to disable --all by default (or remember last chosen option) #1869

Closed franciscolourenco closed 3 months ago

franciscolourenco commented 4 months ago

Every time I open the GRAPH view, the --all option is enabled, even if it was disabled last time I used the GRAPH view.

I mostly use the GRAPH without --all and would like to have an option to disable it by default, or in alternative that this option it remembered when switching in and out of the GRAPH view.

kaste commented 4 months ago

Depending on how you look at this problem it is relatively difficult to do. It also has an easy side though. How do you open the graph? Because that's how the global command is defined

    {
        "caption": "git: Repo History",
        "command": "gs_graph",
        "args": { "all": true }
    },

Set all to false and it will follow.

But (2) you can also use g on any commit etc. and here I probably set --all because I don't have code that decides if the commit is actually reachable from the current branch. To set --all might be a convenience here as we know the commit must be in that graph.

Then (3) there is another tricky question iirc. With GitSavvy you can have multiple graph views open for the same repo, filtered differently perhaps. Then I had to decide when such a graph view should be reused and maybe just scrolled or its filter rewritten, and when we should open a brand new view.

franciscolourenco commented 4 months ago

In my case I always use tab to switch between the status view into the graph view. I guess the command doesn't apply in that case?

kaste commented 4 months ago

No, that's not this command. Have to look it up.

kaste commented 4 months ago

That's actually calling gs_log_graph_current_branch which is defined as:

class gs_log_graph_current_branch(WindowCommand, GitCommand):
    def run(self, file_path=None):
        self.window.run_command('gs_graph', {
            'file_path': file_path,
            'all': True,
            'follow': 'HEAD',
        })
franciscolourenco commented 4 months ago

Maybe a config option that could affect the --all argument for both gs_log_graph_current_branch and gs_graph? And g could b left with --all for the reason you mentioned.

kaste commented 4 months ago

I don't see what I should change for gs_graph as --all is not the default for the command. Actually the default is false, just that the main commands I added to the Command Palette (e.g. git: Repo History) sets it to true. I think I considered these to be the showcase commands, and --all is the "better" showcase for users installing GitSavvy for sure. (All git gui's default to something like "all" afaik.) "All" is the best option for a lot of workflows actually, be it stackless or I-own-my-local-copy.

I think I thought users should add a different command/different args to the Palette or to their key bindings as their wish.

I'm not sure what gs_log_graph_current_branch means on the other side. It sets "all", but no branches, and just follows (=scrolls to) "HEAD". That would be a clear misnomer, and I think that command's name comes from the old GitSavvy 1.x. That's probably deprecated usage; don't remember clearly. Anyway, I also thought that the "tab" thing would be pluggable/configurable already, but it isn't. So that's a thing maybe to change.

TBF, I'm actually not a biiig fan of the "all: false" graphs as there are still very long. I either use "all: true" or shortened graphs that really compare e.g. the feature branch with the upstream main branch (e.g.origin/main) as these tend to be really short. These graphs are bound to "[H]" in the branches dashboard for example.

franciscolourenco commented 4 months ago

Didn't know about the [H], that is a useful view indeed.

Anyway, I would like to keep using the GRAPH view that you can access via tab key, but I'm mostly not interested in all branches, just the current one. It would be ideal if this setting was remembered as you go in and out of the graph. Or alternatively a setting to configure the default would also work.

kaste commented 4 months ago

I have a fix for the tab-in/tab-out. Just tabbing should IMO not change/reset the graph settings. I don't have an option for that as that seems just like a bug. 😕

franciscolourenco commented 4 months ago

@kaste that would already be fantastic!