Commit Graph

5 Commits

Author SHA1 Message Date
Richard Earnshaw
24b178184f contrib: New remotes structure for vendor and personal refs
The initial structure for vendor and personal branches makes use of
the default remote (normally origin) for the upstream
repository).  Unfortunately, this causes some confusion, especially for
personal branches because a push will not push to the correct upstream
location.  This can be 'fixed' by adding a push refspec for the remote,
but that has the unfortunate consequence of breaking the push.default
behaviour for git push, and it becomes too easy to accidentally commit
something unintended to the main parts of the repository.

To work around this, this patch changes the configuration to use
separate 'remotes' for these additional refs, with one remote for the
personal space and another remote for each vendor's space.  The
personal space is called after the user's preferred branch-space
prefix (default 'me'), the vendor spaces are called
vendors/<vendor-name>.

As far as possible, I've made the script automatically restructure any
existing fetch or push lines that earlier versions of the scripts may
have created - the gcc-git-customization.sh script will convert all
vendor refs that it can find, so it is not necessary to re-add any
vendors you've already added.

You might, however, want to run
  git remote prune <origin>
after running to clean up any stale upstream-refs that might still be
in your local repo, and then
  git fetch vendors/<vendor>
or
  git fetch <me>
to re-populate the remotes/ structures.

Also, for any branch you already have that tracks a personal or vendor
branch upstream, you might need to run
  git config branch.<name>.remote <new-remote>

so that merges and pushes go to the right place (I haven't attempted
to automate this last part).

For vendors, the new structure means that

  git checkout -b <vendor>/<branch> remotes/vendors/<vendor>/<branch>

will correctly set up a remote tracking branch.

Please be aware that if you have multiple personal branches set up, then

  git push <me>

will still consider all of them for pushing.  If you only want to push
one branch, then either write
  git push <me> HEAD
or
  git push <me> <me>/branch
as appropriate.

And don't forget '-n' (--dry-run) to see what would be done if this
were not a dry run.

Finally, now that the vendors spaces are isolated from each other and
from the other spaces, I've added an option "--enable-push" to
git-fetch-vendor.sh.  If passed, then a "push" spec will be added for
that vendor to enable pushing to the upstream.  If you re-run the
script for the same vendor without the option, the push spec will be
removed.

	* gcc-git-customization.sh: Check that user-supplied remote
	name exists before continuting.  Use a separate remotes for the
	personal commit area.  Convert existing personal and vendor
	fetch rules to new layout.
	* git-fetch-vendor.sh: New vendor layout.  Add --enable-push
	option.
2020-01-20 10:37:29 +00:00
Richard Earnshaw
e61074228d contrib: Don't add push rules for personal and vendor spaces.
Originally, it seemed like a good idea to add automatic 'push' rules
to the git configuration, so that personal- and vendor-space commits
would automatically push to the right place.  Unfortunately, this
changes git's behaviour and with these settings "git push" will try to
push all branches in a local tree up to the corresponding location on
the server (ignoring the push.default setting).  The only known
mitigation for this is to ALWAYS use "git push <server> <branch>".

So instead, we no-longer add those rules by default and will document
the options on the wiki.  We don't automatically remove the push
entries but do print out the command that will do so, if the user so
wishes.

	* gcc-git-customization.sh: Explain why we want the user's
	upstream account name.  Don't add push rules.  Check if push rules
	have been added and suggest that they should be removed.
	* git-fetch-vendor.sh: Don't add push rules.
2020-01-15 11:31:29 +00:00
Richard Earnshaw
11b81575c5 Revert "contrib: Add in the default push rule which was overridden"
This reverts commit b60563a8bf.

Doesn't work as expected.
2020-01-13 18:43:28 +00:00
Richard Earnshaw
b60563a8bf contrib: Add in the default push rule which was overridden
When we add a push rule, the default rule gets removed, so add that in
explicitly.  This needs to come last since otherwise it would match
the custom redirecting rules we have for personal and vendor
sub-spaces.

I also noticed that the push rule for the vendor subspace still had
a force push default.  We don't want that so remove it.

	* gcc-git-customization.sh: Add back the default rule that
	is lost by adding a custom push rule.
	* git-fetch-vendor.sh: Likewise, also remove '+' from push specs.
2020-01-13 18:26:18 +00:00
Richard Earnshaw
b8f59c4b30 contrib: script to setup git to pull a vendors branches
This simple script is intended to setup a new git configuration to
pull the branches and tags for a specific vendor.  This should
simplify some of the steps needed for working with a vendor's
branches.

	* git-fetch-vendor.sh: New file.
2020-01-13 16:14:32 +00:00