Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup: Fix git backup branch handling for non-master branches #4373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

VisibleSampling
Copy link

The current git backup functionality assumes a 'master' branch when pushing changes, which caused issues when using different branch names (like 'main'). This PR fixes two issues:

  1. Creates the configured branch on git init instead of relying on default master
  2. Uses the configured branch name for both source and destination in push command

These changes allow users to properly use any branch name in their git backup configuration without needing manual workarounds.

Testing:

  • Tested with new repository using 'main' branch
  • Tested with unique repository names such as test and potato
  • Confirmed backup works without manual branch creation
  • Verified push command uses correct branch names

Fixes #4143

- Create configured branch on git init instead of default master
- Use configured branch for both source and destination in push command
- Fixes issues with non-master branch names
@fichtner
Copy link
Member

fichtner commented Nov 30, 2024

On the surface this looks reasonable, but @AdSchellevis needs to decide. Might be time to change “master” default to “main” in the model as this is the default now for git anyway?

@AdSchellevis
Copy link
Member

The local branch name isn't really relevant as long as you follow the instructions in https://docs.opnsense.org/manual/git-backup.html , switching branch names like this will likely be even less resilient than it currently is.

At the moment you can change the branch name on your end after which it will easily create one upstream for you if it doesn't exist yet, which guarantees both are in sync.

A fix for one person here will be an issue for someone else I'm afraid, if documentation isn't clear about the use case in some way let's try to improve that part. The designed use-case is pretty simple, start with a clean branch and keep it on track with the plugin, nothing more, nothing less.

@fichtner
Copy link
Member

For now it seems git-init https://git-scm.com/docs/git-init will still default to "master"

Creates the configured branch on git init instead of relying on default master

So this works for now. The one spot you found with "master:" hardcode may be problematic when the default changes.

Uses the configured branch name for both source and destination in push command

So it does not seem to matter much?

Cheers,
Franco

@VisibleSampling
Copy link
Author

I understand, thanks for looking into the request I appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

os-git-backup - error in push
3 participants