Skip to content

Conversation

pmiossec
Copy link
Member

@pmiossec pmiossec commented Nov 7, 2023

Fixes #11333

doc: https://github.blog/2022-10-03-highlights-from-git-2-38/#rebase-dependent-branches-with-update-refs

Linked to what have already been done with #10289

Screenshots

Before

(normal rebase form)

After

image

Test methodology

  • Manual

Test environment(s)

  • Git Extensions 33.33.33
  • Build a2d7046
  • Git 2.42.0.windows.2
  • Microsoft Windows NT 10.0.22621.0
  • .NET 6.0.21
  • DPI 96dpi (no scaling)
  • Portable: False
  • Microsoft.WindowsDesktop.App Versions
    Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Merge strategy

I agree that the maintainer Rebase merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned pmiossec Nov 7, 2023
@pmiossec
Copy link
Member Author

pmiossec commented Nov 7, 2023

FYI, this form would need some redesign to make some room to rebase options.
The options lines are flow layout panel and by default the new checkbox is hidden because it appears outside of the initial form size.
To be able to push the feature and not wait an undetermined time (as it already stayed one year on my personal branch), I have enabled the wrapping in the flow panel so that the option is always visible...(until the rework of the form is effective).

@pmiossec
Copy link
Member Author

pmiossec commented Nov 7, 2023

/cc @quinmars you could test it and give feedback.

return EffectiveConfigFile.GetValue(setting);
}
public string GetEffectiveSetting(string setting) => EffectiveConfigFile.GetValue(setting);
public bool IsEffectiveSettingEnabled(string setting) => EffectiveConfigFile.IsEnabled(setting);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public bool IsEffectiveSettingEnabled(string setting) => EffectiveConfigFile.IsEnabled(setting);
public bool? GetEffectiveBoolSetting(string setting) => EffectiveConfigFile.GetBool(setting);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like us to consider an opportunity to generalise and have something like:

public T GetEffectiveSetting<T>(string settingName) 
{
   ...
}

public T GetSetting<T>(string settingName) 
{
   ...
}

@@ -5993,6 +5993,10 @@ Nothing to rebase.</source>
</source>
<target />
</trans-unit>
<trans-unit id="checkBoxUpdateRefs.Text">
<source>Update dependent refs</source>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add mnemonic?

@@ -2968,7 +2968,7 @@ private void LaunchRebase(string command)

string rebaseCmd = Commands.Rebase(
GetActualRevision(LatestSelectedRevision)?.FirstParentId?.ToString(), interactive: true, preserveMerges: false,
autosquash: false, autoStash: true, ignoreDate: false, committerDateIsAuthorDate: false, supportRebaseMerges: Module.GitVersion.SupportRebaseMerges);
autosquash: false, autoStash: true, ignoreDate: false, committerDateIsAuthorDate: false, supportRebaseMerges: Module.GitVersion.SupportRebaseMerges, updateRefs: false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it the default argument value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please create a struct that contains all the parameters instead? Not only it'd be more maintainable; there's a threshold on a number of parameters (I don't know it by heart) after which every new parameter becomes an overhead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RussKie Not sure that I agree with this point of view (even if I understand that there are a lot of params due to the number of options of the git rebase command) because:

  • it's consistent with all the methods of the Commands class. I would say it's even the goal of this class to use this pattern where you have a param for each command option.
  • create a struct/record will have the same problem where you initialize a lot of values. You just add a level of indirection
  • it's acceptable because the command is used only 3 times and I don't it will increase in the future and that's not a call that we modify often. I think we can live with that.

@RussKie I don't really get what you means by overhead.
Is it a performance one? In this case it is not a problem because it is called once and waiting for human interaction.
Or cognitive one? If that's the case, we say that the limit is around 7 +/-2. But as it is a simple mapping, with a very simple logic and without interaction between the parameters, the code logic is very easy to understand and a much bigger number is acceptable.

@quinmars
Copy link

quinmars commented Nov 8, 2023

@pmiossec, I have tested it an it works like a charme, thank you. I have a small suggestion. When I set updateRefs = true in the configuration, the checkbox is checked and disabled. That's not bad, but even better would be if the user could uncheck the checkbox to use --no-update-refs for this commit. I do not know, however, how difficult this would be to implement. Personally, I will not change the default setting, so for me, your solution is all I need!

@pmiossec
Copy link
Member Author

pmiossec commented Nov 8, 2023

That's not bad, but even better would be if the user could uncheck the checkbox to use --no-update-refs for this commit

@quinmars
I looked for that when I developed the feature and put a comment saying explicitly that there was no way to override the setting. I can't explained how I missed it (maybe the git pro documentation was not up to date at the time).
I will have to better handle it, you're right.

@pmiossec pmiossec force-pushed the update-refs_support branch from 1f0bd23 to 6703b46 Compare November 8, 2023 13:43
@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 9, 2023
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 9, 2023
@pmiossec pmiossec force-pushed the update-refs_support branch from 6703b46 to 2303cb0 Compare November 9, 2023 13:33
@pmiossec
Copy link
Member Author

pmiossec commented Nov 9, 2023

Except the request on change on parameters number of Commands.Rebase(), I have made a new proposition for everything else.

Point of view?

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking better

catch (Exception ex)
{
Debug.WriteLine($"Setting '{setting}': fail to convert value '{value}' into type '{targetType}'. Error: {ex}");
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return null;
return default(T);

Copy link
Member

@mstv mstv Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why handle the exception at all?
If we try to get a setting using a wrong type, it is a bug or an invalid manipulation of the settings file

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was at least for when the setting was not set. But indeed it is better to handle it before. Done.

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking better

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 13, 2023
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 13, 2023
@pmiossec pmiossec force-pushed the update-refs_support branch 2 times, most recently from 82769a8 to 15230e4 Compare November 23, 2023 12:02
catch (Exception ex)
{
Debug.WriteLine($"Setting '{setting}': fail to convert value '{value}' into type '{targetType}'. Error: {ex}");
return null;
Copy link
Member

@mstv mstv Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why handle the exception at all?
If we try to get a setting using a wrong type, it is a bug or an invalid manipulation of the settings file

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 24, 2023
@RussKie
Copy link
Member

RussKie commented Nov 24, 2023

I'd like for this to go behind #11269.

@pmiossec pmiossec force-pushed the update-refs_support branch from 15230e4 to 0653ca6 Compare November 24, 2023 08:27
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 24, 2023
@pmiossec pmiossec force-pushed the update-refs_support branch from 2365fc1 to 57b5e2f Compare November 24, 2023 09:40
@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 25, 2023
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Nov 25, 2023
Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been using n earlier version of this PR for some time. Very useful - you just have to remember to remove the update-ref when rebasing temp branches.
Implementation is fine for me. Compare the handling to #11369 (for Git settings).

@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Dec 3, 2023
@pmiossec
Copy link
Member Author

pmiossec commented Dec 3, 2023

Done.

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a few nits in addition to Igor's comments

@pmiossec pmiossec force-pushed the update-refs_support branch from 439018b to 25e2385 Compare December 4, 2023 09:00
Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are few small outstanding items. Other than that 👍

catch (Exception ex)
{
Debug.WriteLine($"Setting '{setting}': fail to convert value '{value}' into type '{targetType}'. Error: {ex}");
throw new GitConfigFormatException($"Setting '{setting}': fail to convert value '{value}' into type '{targetType}'");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gentle ping

Comment on lines 160 to 168
/// <summary>
/// Get the config setting from git converted in an expected C# value type (bool, int, ...)
/// </summary>
/// <typeparam name="T">the expected type of the git setting.</typeparam>
/// <param name="setting">the git setting key</param>
/// <returns>
/// null if the settings is not set
/// the value converted in the <typeparamref name="T" /> type otherwise.
/// </returns>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gentle ping

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Dec 5, 2023
@pmiossec pmiossec force-pushed the update-refs_support branch from 25e2385 to 15f4c1e Compare December 5, 2023 11:14
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Dec 5, 2023
@pmiossec pmiossec force-pushed the update-refs_support branch 3 times, most recently from c565b3a to ee5ea8b Compare December 5, 2023 12:01
@@ -156,8 +156,31 @@ public interface IGitModule
Task<IReadOnlyList<Remote>> GetRemotesAsync();

string GetSetting(string setting);

#pragma warning disable CS1574 // XML comment has cref attribute that could not be resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move GitConfigFormatException to Plugins/GitUIPluginInterfaces?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - we can't have the upstream dependency refer to downstream implementations.

@RussKie
Copy link
Member

RussKie commented Dec 6, 2023

Did I ever mention that building public API is extremely hard? 🤣

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Dec 6, 2023
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Dec 6, 2023
@pmiossec pmiossec force-pushed the update-refs_support branch from 223c4bd to 4fe3ff9 Compare December 6, 2023 08:24
@RussKie RussKie merged commit 8ece7c4 into gitextensions:master Dec 6, 2023
@ghost ghost added this to the vNext milestone Dec 6, 2023
@RussKie
Copy link
Member

RussKie commented Dec 6, 2023

Thank you!

@pmiossec pmiossec deleted the update-refs_support branch December 7, 2023 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for the rebase option --update-refs
6 participants