Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.4
-
Fix Version/s: 1.7
-
Component/s: maven-scm-provider-git
-
Labels:None
-
Complexity:Intermediate
-
Number of attachments :2
Description
I want to checkout a specific branch from my git repo using the maven-scm-plugin. The plugin first clones the repo and gets the default branch as selected in gitorious. After that the plugin executes git pull ... mybranch which works fine as long as there are no merge conflicts between current branch and branch to checkout. In the case of any conflict an error occurs.
The git checkout -b command should be used instead.
[INFO] Working directory: <a_dir> [INFO] Executing: /bin/sh -c cd /home/maven-proj/target/deploy-workspace && git fetch git://gitorious/<...>/my-proj.git [INFO] Working directory: <a_dir> [INFO] Executing: /bin/sh -c cd /home/maven-proj/target/deploy-workspace && git checkout HEAD [INFO] Working directory: <a_dir> [INFO] Executing: /bin/sh -c cd /home/maven-proj/target/deploy-workspace && git ls-files [INFO] Working directory: <a_dir> [INFO] [INFO] --- maven-scm-plugin:1.4:update (switch-branch) [INFO] Executing: /bin/sh -c cd /home/maven-proj/target/deploy-workspace && git pull git://gitorious/<..>/deploy.git mysql55 [WARNING] failed to update git, return code 1 [ERROR] Provider message: [ERROR] The git-pull origin master command failed. [ERROR] Command output: [ERROR] From git://gitorious/<...>/deploy * branch mysql55 -> FETCH_HEAD
-
- SCM-584.patch
- 01/Dec/10 12:20 PM
- 3 kB
- Sebastian Annies
-
Hide
- SCM-584-test-prj.zip
- 01/Dec/10 11:50 AM
- 21 kB
- Sebastian Annies
-
- show-SCM-584/pom.xml 1 kB
- show-SCM-584/repo/a.txt 0.0 kB
- show-SCM-584/.../ee92fca0f0b4aad7ac2072a8896d7c304cfff7 0.0 kB
- show-SCM-584/.../934c2f8c34d06be64f50ff901b3048e07d7208 0.1 kB
- show-SCM-584/.../d770772e94285a9133a7c5d9d7e555f411ce0f 0.1 kB
- show-SCM-584/.../906050b835c371a7f10042548e50da0338e46a 0.0 kB
- show-SCM-584/.../dd9b9dc4d109a772ad9c6fc66548f9130cd487 0.0 kB
- show-SCM-584/.../40aae28df5f6b39eeece27e153e78f94213716 0.2 kB
- show-SCM-584/.../dc2c45f465aa64774a7eddfa3967dd9bdaf290 0.2 kB
- show-SCM-584/.../38611ad7e489632f4d906af5ada34d9941c82d 0.0 kB
- show-SCM-584/.../a8dba179f1cdcffb71b9d0651c842916d89514 0.0 kB
- show-SCM-584/.../9fd2712a506d304774ff74d9a8982d06093dfd 0.0 kB
- show-SCM-584/repo/.git/.../heads/conflicting 0.3 kB
- show-SCM-584/repo/.git/.../refs/heads/master 0.3 kB
- show-SCM-584/repo/.git/logs/HEAD 0.9 kB
- show-SCM-584/repo/.git/index 0.1 kB
- show-SCM-584/repo/.git/config 0.1 kB
- show-SCM-584/repo/.git/description 0.1 kB
- show-SCM-584/repo/.git/info/exclude 0.2 kB
- show-SCM-584/repo/.git/.../heads/conflicting 0.0 kB
- show-SCM-584/repo/.git/refs/heads/master 0.0 kB
- show-SCM-584/repo/.../post-receive.sample 0.5 kB
- show-SCM-584/repo/.../pre-commit.sample 2 kB
- show-SCM-584/repo/.../commit-msg.sample 0.9 kB
- show-SCM-584/.../prepare-commit-msg.sample 1 kB
- show-SCM-584/repo/.../applypatch-msg.sample 0.4 kB
- show-SCM-584/repo/.../pre-applypatch.sample 0.4 kB
- show-SCM-584/repo/.../pre-rebase.sample 5 kB
- show-SCM-584/repo/.../post-commit.sample 0.2 kB
- show-SCM-584/repo/.../hooks/update.sample 4 kB
Activity
A little project showing the error. I would have written a regular test but I didn't understand the test framework. To see the error unzip and execute
mvn install
Patches the problem by appending the --branch parameter to the git command in case the version is a branch. This makes sure that a subsequent pull does what intended!
Patch availability for about 1,5 years and still not integrated... wow!
But furthermore it is really strange why this issue appeared in the first place. The initial developer(s) of the git provider must have been blind. How else can you explain that someone wanted to do a 'git pull' for switching to a branch?! As every documentation says 'git pull' is just a shortcut for 'git fetch' + 'git merge'.
From the man page:
[...] git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. [...]
Even if it worked for the developer in the first place then only by luck.
OK, I can confirm that the patch indeed fixes this problem but then the command sequence still is awful:
[INFO] [scm:checkout {execution: export-inplace}]
[INFO] Removing /srv/dev/test/target/upstream-sources
[INFO] Executing: /bin/sh -c cd /srv/dev/test/target && git clone --branch develop http://git.myserver.localdomain/other.git /srv/dev/test/target/upstream-sources
[INFO] Working directory: /srv/dev/test/target
[INFO] Executing: /bin/sh -c cd /tmp && git ls-remote http://git.myserver.localdomain/other.git
[INFO] Working directory: /tmp
[INFO] Executing: /bin/sh -c cd /srv/dev/test/target/upstream-sources && git pull http://git.myserver.localdomain/other.git develop:develop
[INFO] Working directory: /srv/dev/test/target/upstream-sources
[INFO] Executing: /bin/sh -c cd /srv/dev/test/target/upstream-sources && git checkout develop
[INFO] Working directory: /srv/dev/test/target/upstream-sources
[INFO] Executing: /bin/sh -c cd /srv/dev/test/target/upstream-sources && git ls-files
[INFO] Working directory: /srv/dev/test/target/upstream-sources
What I would expect is this:
[INFO] [scm:checkout {execution: export-inplace}]
[INFO] Removing /srv/dev/test/target/upstream-sources
[INFO] Executing: /bin/sh -c cd /srv/dev/test/target && git clone --branch develop http://git.myserver.localdomain/other.git /srv/dev/test/target/upstream-sources
[INFO] Working directory: /srv/dev/test/target
[INFO] Executing: /bin/sh -c cd /tmp && git ls-remote http://git.myserver.localdomain/other.git
[INFO] Working directory: /tmp
[INFO] Executing: /bin/sh -c cd /srv/dev/test/target/upstream-sources && git ls-files
[INFO] Working directory: /srv/dev/test/target/upstream-sources
...so drop the additional pull and checkout - doesn't make any sense in git, really.
Having a look at the code and that looks to be fixed (but issue not closed).
@Ancoron Luciferis: can you try with last SNAPSHOT ?
Using the latest 1.7-SNAPSHOT I now see the same output as with the patch applied to 1.6.
Before the git fetch listed above a git clone is performed: