git svn fetch - Session URL does not match expected session URL - git-svn

I try to execute git svn fetch on a ubuntu machine that host a svn server. (transfering svn repo to git) git svn response with the error:
Session URL does not match expected session URL: Repository moved permanently to 'http://localhost/svn/repo' at /usr/share/perl5/Git/SVN.pm line 148.
I am able to access the svn repository over the browser:
svn co http://localhost/svn/repo/trunk also works.
The config of my git repository look like:
[svn-remote "svn"]
url = http://localhost/svn/repo
fetch = trunk:refs/remotes/origin/trunk
branches = branches/branchA/*:refs/remotes/branchA/*
Last year I do the exact same process without any issues. What should the error message tell to me?
GIT_TRACE=1:
07:30:19.957480 git.c:576 trace: exec: git-svn fetch
07:30:19.957508 run-command.c:646 trace: run_command: git-svn fetch
06:30:20.264901 git.c:344 trace: built-in: git rev-parse --git-dir
06:30:20.270689 git.c:344 trace: built-in: git rev-parse --show-cdup
06:30:20.280345 git.c:344 trace: built-in: git config --bool --get svn.useSvmProps
06:30:20.282850 git.c:344 trace: built-in: git config --get svn.ignorerefs
06:30:20.284977 git.c:344 trace: built-in: git config --bool --get svn.uselogauthor
06:30:20.289744 git.c:344 trace: built-in: git config --int --get svn.logwindowsize
06:30:20.296912 git.c:344 trace: built-in: git config --get svn.repackflags
06:30:20.302913 git.c:344 trace: built-in: git config --bool --get svn.parent
06:30:20.308843 git.c:344 trace: built-in: git config --bool --get svn.noMetadata
06:30:20.313303 git.c:344 trace: built-in: git config --get svn.authorsprog
06:30:20.315443 git.c:344 trace: built-in: git config --bool --get svn.fetchall
06:30:20.325453 git.c:344 trace: built-in: git config --get svn.configdir
06:30:20.327644 git.c:344 trace: built-in: git config --int --get svn.repack
06:30:20.336702 git.c:344 trace: built-in: git config --get svn.includepaths
06:30:20.339225 git.c:344 trace: built-in: git config --get svn.username
06:30:20.341358 git.c:344 trace: built-in: git config --bool --get svn.localtime
06:30:20.350228 git.c:344 trace: built-in: git config --bool --get svn.useSvnsyncProps
06:30:20.352446 git.c:344 trace: built-in: git config --bool --get svn.nocheckout
06:30:20.361053 git.c:344 trace: built-in: git config --get svn.authorsfile
06:30:20.365090 git.c:344 trace: built-in: git config --get svn.ignorepaths
06:30:20.367110 git.c:344 trace: built-in: git config --bool --get svn.followparent
06:30:20.376769 git.c:344 trace: built-in: git config --get svn.revision
06:30:20.378979 git.c:344 trace: built-in: git config --bool --get svn.addauthorfrom
06:30:20.384743 git.c:344 trace: built-in: git config --bool --get svn.noauthcache
06:30:20.389012 git.c:344 trace: built-in: git config --bool --get svn.quiet
06:30:20.391455 git.c:344 trace: built-in: git rev-parse --symbolic --all
06:30:20.444247 git.c:344 trace: built-in: git rev-parse --git-path svn
06:30:20.453089 git.c:344 trace: built-in: git config -l
06:30:20.465201 git.c:344 trace: built-in: git config -l
06:30:20.468112 git.c:344 trace: built-in: git config --bool svn.useSvmProps
06:30:20.474744 git.c:344 trace: built-in: git config -l
Session URL does not match expected session URL: Repository moved permanently to 'http://localhost/svn/repo' at /usr/share/perl5/Git/SVN.pm line 148.

Find an old version of my virtual machine. The correct git config should looks like:
[svn-remote "svn"]
url = file:///localhost/svn/repo # <- instead of http://
fetch = trunk:refs/remotes/origin/trunk
branches = branches/branchA/*:refs/remotes/branchA/*
Hope this prevent someday ppl wasting time...

Related

Azure DevOps private Linux agent - YAML pipeline checkout failing - can fix with "git config --global --unset http.extraHeader" but not early enough

We have an issue regarding the following:
Azure DevOps Linux Private Agent
Possible issue with corrupt / stale bearer token
Can be fixed with this command by logging onto the box but this is not convenient: git config --global --unset http.extraHeader
Can be fixed with this command as part of script in YAML: git config --global --unset http.extraHeader but not early enough. (See next comment below).
I can't run this command early enough in the pipeline YAML to clear the header as checkout is not controlled by me.
It generally only happens if a previous run fails at some point on the same private agent
Syncing repository: test-project-azure-workspace (Git)
git version
git version 2.26.0
git lfs version
git-lfs/2.10.0 (GitHub; linux amd64; go 1.13.4)
git config --get remote.origin.url
git clean -ffdx
git reset --hard HEAD
HEAD is now at 5f9fd24 sql mi
git config gc.auto 0
git config --get-all http.https://xxxxxxx#dev.azure.com/xxxxxxx/xxxxxxx/_git/test-project-azure-workspace.extraheader
git config --get-all http.proxy
git config http.version HTTP/1.1
git -c http.extraheader="AUTHORIZATION: bearer ***" -c http.proxy="http://10.XXX.XXX.XX:80" fetch --force --tags --prune --progress --no-recurse-submodules --unshallow origin
* Couldn't find host dev.azure.com in the .netrc file; using defaults
Here is the code that can remedy the symptom:
- script: |
echo '======================================================================'
echo 'list all of git config values for your convenience:'
echo '======================================================================'
git config --list
echo '======================================================================'
existing_header=$(git config --get http.extraHeader)
if [ ${#existing_header} -gt 0 ]
then
echo 'We found the http.extraHeader'
echo 'un-setting extra header: http.extraHeader 🔥'
git config --global --unset http.extraHeader
else
echo 'no extra header: http.extraHeader was not found. Nothing to unset 👍'
fi
condition: always()
workingDirectory: '$(Agent.BuildDirectory)/s'
displayName: 'Remove Git Authentication'
Obviously, I am treating the symptom and not the cause so any pointers as to what is causing this would be a great help.
You can create a "cleaning" job at the start of your pipeline that uses the checkout task with none as the repo to checkout. This will allow you to then run the cleaning script.
- job: cleanAgent
steps:
- checkout: none
- script: |
echo "Put your git cleaner here"
A better option is really to clean the agent after you are done by running a cleaning task with a condition of always() at the end of your pipeline. This can be hard if other people also use the agents and don't clean-up though.
- job: cleanupAgents
condition: always()
steps:
- script: |
echo "Put your git cleaner here"

Git clone command not showing the remote branchs

I have a remote git repo that has a master branch1 and branch2
when i perform a git clone,I am only able to see the master and the remote branches are missing.
What could be done to fix this issue ?
when i do git branch -a
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
$ git branch -r
origin/HEAD -> origin/master
origin/master
Try use git fetch origin --all

Drone ssh plugin not triggered

My drone.yml file is straightforward:
build:
image: node
commands:
- echo $${BRANCH}
deploy:
ssh:
host: my-domain
user: admin
port: 22
commands:
- touch /home/admin/testdrone
But in the output it seems like the ssh plugin is never even pulled:
[info] Pulling image plugins/drone-git:latest
$ git init
Initialized empty Git repository in /drone/src/github.com/.../.git/
$ git remote add origin https://github.com/....git
$ git fetch --no-tags --depth=50 origin +refs/pull/782/merge:
From https://github.com/...
* branch refs/pull/782/merge -> FETCH_HEAD
$ git checkout -qf FETCH_HEAD
$ echo drone-deploy
drone-deploy
How can I investigate what's going wrong?
Turns out that deploy steps are only executed if the hook is not a Pull Request. That was what was going wrong with my setup

git-svn: how to change the svn username on dcommit?

I cloned a SVN repository into a git repository using git svn clone. At that point in time, I did not have a username at that site and hence didn't use the --username option of clone. As I can now commit to the SVN repository with my new username, I would like to add that username. Without it, dcommit simply fails:
% LANG=C git svn dcommit
Committing to <THE URL> ...
RA layer request failed: Server sent unexpected return value (405 Method Not Allowed) in response to MKACTIVITY request for '/svn/!svn/act/0ceca4c5-f7b4-4432-94be-0485559a6040' at /usr/lib/git-core/git-svn line 945.
Is there a way to tell git about a new username? The git-svn manual doesn't seem to help: adding a username is only allowed on init and branch. I don't know how git works with SVN internally, but I guess there should be a way to add a username afterwards.
Note that I am using SVN over http.
You can specify the username in the dcommit command, e.g.
git svn dcommit --username=isapir
I think you can use this procedure (from the git svn manpage) to create a clone of your existing svn repository, but change the git svn init step so that it specifies a username. Your new git-svn repository will then have a username.
# Clone locally - make sure the refs/remotes/ space matches the server
mkdir project
cd project
git init
git remote add origin server:/pub/project
git config --replace-all remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
git fetch
# Prevent fetch/pull from remote git server in the future,
# we only want to use git svn for future updates
git config --remove-section remote.origin
# Create a local branch from one of the branches just fetched
git checkout -b master FETCH_HEAD
# Initialize 'git svn' locally (be sure to use the same URL and -T/-b/-t options as were used on server)
git svn init --username my_new_name http://svn.example.com/project
# Pull the latest changes from Subversion
git svn rebase
Note that if you specify a username, you would not be able to dcommit a merge commit, not before Git 2.16.x/2.17 (Q1 2018).
That is because "git svn dcommit" did not take into account the fact that a
svn+ssh:// URL with a username# (typically used for pushing) refers
to the same SVN repository without the username# and failed when
svn.pushmergeinfo option is set.
See commit 8aaed89 (15 Sep 2017) by Jason Merrill (jwmerrill).
(Merged by Jason Merrill -- jwmerrill -- in commit 8aaed89, 17 Sep 2017)
git-svn: fix svn.pushmergeinfo handling of svn+ssh usernames.
Previously, svn dcommit of a merge with svn.pushmergeinfo set would
get error messages like
merge parent <X> for <Y> is on branch svn+ssh://gcc.gnu.org/svn/gcc/trunk,
which is not under the git-svn root svn+ssh://jason#gcc.gnu.org/svn/gcc!"
So, let's call remove_username (as we do for svn info) before comparing
rooturl to branchurl.

How to commit a Git repo to an empty repo SVN server?

I have setup an empty svn on a server and I have been working on locally making commits along the way. Now I wish to commit my repo to an svn server. For this I tried:
git-svn checkout http://remote.svn.server.com
git-svn dcommit
Git complains that:
Use of uninitialized value in concatenation (.) or string at /usr/bin/git-svn line 411.
Committing to ...
Unable to determine upstream SVN information from HEAD history
Since I started on my local computer first, and the repo online is empty, I can't find any info on how to make this work.
I needed something like this recently and the process is relatively straightforward.
There's good tutorial by Brandon Dimcheff, "Commit a linear git history to subversion" (replaces old broken link), which these steps are based on.
As of Git version 1.6.3 these are the steps:
$ svnadmin create svn_repository
$ svn mkdir -m "Initial setup" file:///full/path/to/svn_repository/trunk
$ mkdir gitrepo && cd gitrepo
$ git init
$ echo 'Hello from Git' > file.txt
$ git add file.txt
$ git commit -m "Hello from Git"
$ git svn init --trunk=trunk file:///full/path/to/svn_repository/
$ git svn fetch
$ git branch -a # Lists remotes/trunk
$ git rebase --onto remotes/trunk --root master
# => Applying: Hello from Git etc.
$ git svn dcommit
# => Committing to ... Committed r2 ... etc
You can do a svn checkout of svn_repository now and see your Git repo.
Here is what I would do:
git-svn clone http://remote.svn.server.com otherdir
Then in other dir pull the changes locally from your previous dir. Then you should have a git repo that is "connected" via git-svn and you should be able to use dcommit on it.
This might also be a useful read.