DESCRIPTION

[WIP] Added rename remote functionality

This will allow the user to rename any existing remote to a new name of
their choosing.
TODO: RenameRemoteOperation and test cases

Bug: 324368
Change-Id: Ie054d27b39b450b86551479bfa250a37d85b9e85
Signed-off-by: Rowan Gamble xxx@xxx.xxx

COMMENTS

author: Giselle Middleton
date: 2015-04-21 01:37:14.000000000

Uploaded patch set 1.

-------------------------------------
author: Brenden Conley
date: 2015-04-21 01:37:21.000000000

Patch Set 1:

Build Started https://hudson.eclipse.org/egit/job/egit.gerrit/6949/

-------------------------------------
author: Brenden Conley
date: 2015-04-21 01:53:41.000000000

Patch Set 1: Code-Review-1

Build Unstable 

https://hudson.eclipse.org/egit/job/egit.gerrit/6949/ : UNSTABLE

-------------------------------------
author: Douglas Trujillo
date: 2015-04-21 07:27:16.000000000

Patch Set 1: Code-Review-1

(9 comments)

Line:39, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ValidationUtils.java -> revert unrelated formatting changes

Line:63, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ValidationUtils.java -> revert unrelated formatting changes

Line:103, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/ValidationUtils.java -> use Repository.isValidRefName(Constants.R_REMOTES + remoteName)) to let JGit check validity of the remote name (see CloneDestinationPage.checkPage())

Line:1, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/dialogs/RemoteRenameDialog.java -> missing license header

Line:1, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RenameRemoteCommand.java -> missing license header

Line:1, org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameRemoteOperation.java -> missing license header

Line:59, org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameRemoteOperation.java -> - use RemoteConfig here which knows how to parse a remote section
- maybe you need to enhance RemoteConfig to support renaming

Line:63, org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameRemoteOperation.java -> externalize the error message

Line:80, org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameRemoteOperation.java -> locking the workspace is unnecessary for a git configuration change which doesn't affect the working tree, FileBasedConfig does prevent concurrent saves using a filesystem lock (see FileBasedConfig's javadoc)

-------------------------------------
author: Giselle Middleton
date: 2015-04-22 00:00:53.000000000

Patch Set 1:

(1 comment)

Question

Line:59, org.eclipse.egit.core/src/org/eclipse/egit/core/op/RenameRemoteOperation.java -> Should the change to RemoteConfig be just a copy? We remove a remote using StoredConfig, so all the copy would do is take an existing remote, create a new instance, and change its name?

-------------------------------------
author: Giselle Middleton
date: 2015-04-22 00:37:48.000000000

Patch Set 1:

When I rename a remote, should I leave the "fetch" alone as it still contains the original remote name? All the "remote tracking" branches currently keep the original remote name too, which might be confusing to some users.
Do I have to update each branch's "remote" in the config to the new remote name?
Is there anything else I'm missing in what needs to be changed in the config/git?

-------------------------------------
author: Zachary Orozco
date: 2015-04-22 07:50:30.000000000

Patch Set 1:

I like this feature. I think we should do the same as native git. Native git has "git remote rename <old> <new>". It renames remote tracking branches (e.g. from refs/remotes/origin/master to refs/remotes/new/master) and it updates the config. See here:

  [/tmp/dondalfi (master)]$ git branch -a
  * master
    remotes/origin/Adder
    remotes/origin/HEAD -> origin/master
    remotes/origin/Multiplyer
    remotes/origin/master
    remotes/origin/test
    remotes/origin/tmpA
  [/tmp/dondalfi (master)]$ git checkout -b test origin/Adder
  Branch test set up to track remote branch Adder from origin.
  Switched to a new branch 'test'
  [/tmp/dondalfi (test)]$ git remote rename origin new
  [/tmp/dondalfi (test)]$ git branch -a
    master
  * test
    remotes/new/Adder
    remotes/new/HEAD -> new/master
    remotes/new/Multiplyer
    remotes/new/master
    remotes/new/test
    remotes/new/tmpA
  [/tmp/dondalfi (test)]$ cat .git/config
  [core]
          repositoryformatversion = 0
          filemode = false
          bare = false
          logallrefupdates = true
          symlinks = false
          ignorecase = true
          hideDotFiles = dotGitOnly
  [remote "new"]
          url = xxx@xxx.xxx
          fetch = +refs/heads/*:refs/remotes/new/*
  [branch "master"]
          remote = new
          merge = refs/heads/master
  [branch "test"]
          remote = new
          merge = refs/heads/Adder

Notice that it will also update the "remote" value for a branch which is tracking a remote branch.

Now to the part you may not like: Can't we do that in JGit. Normally we add functionality which is there also in native git into the JGit library. This way also other tools apart from EGit using JGit can use this feature. I suggest to add a RemoteRenameCommand to org.eclipse.jgit.api which allows to rename remotes.

-------------------------------------
author: Douglas Trujillo
date: 2015-04-22 08:05:59.000000000

Patch Set 1:

+1, renaming a remote should be implemented in JGit

-------------------------------------
author: Giselle Middleton
date: 2015-04-22 10:44:14.000000000

Patch Set 1:

Ok, I am unfamilar with native git so I will look into the specified command first and then see what I can do for jgit.

-------------------------------------
