Git error is:
Pushing to http://myurl/project/.git
error: Cannot access URL http://myrul/project/.git/, return code 22
fatal: git-http-push failed
I changed my real url and project to myurl and project on the sample
above
on my windows 7 Apache the error log says:
[Fri Dec 09 08:58:57 2011] [error] [client 199.104.207.2] user
userName: authentication failure for "/project/.git/info/refs":
Password Mismatch
[Fri Dec 09 08:59:02 2011] [error] [client 199.104.207.2] user
userName: authentication failure for "/project/.git/": Password
Mismatch
with version 1.7.7.1 and earlier it was never an issue. Am i missing
anything with the new release.
Im running it on windows 7 and apache 2.2.21
Thanks
What is missing is the information about whether it really asked you to
enter username/password before (and now fails to do that) or is it
supposed to not work without authentication or whether you're using
a .netrc file to store your credentials? Or maybe something else
completely?
On the client side:
Using Git GUI
My username is in the url when i first cloned the project from the
remote server
with the format:
htt://myuse...@www.myurl.com/project/.git
When I do the push the TK OpenSSH dialog opens up asking for the
password
On the server side:
My Apache conf file consists of:
# Used for Webdav
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
DAVLockDB "c:/WebTools/Apache2/temp/DAV.lock"
ServerName myservername
Listen 8082
NameVirtualHost *:8082
<VirtualHost *:8082>
ServerAdmin myema...@emailaddress.com
ServerName myservername
DocumentRoot C:/Repositories/GitRepository
ErrorLog logs/error_8082.txt
DirectoryIndex index
<Location />
Order Allow,Deny
Allow from all
Dav on
AuthType Basic
AuthName "Git Project Repository"
AuthUserFile c:/WebTools/passwords/gitpasswords.dat
Require valid-user
<Limitexcept GET POST HEAD PROPFIND OPTIONS REPORT>
Require valid-user
</Limitexcept>
</Location>
# Allows directory browsing on the set paths
<Directory "C:/Repositories/GitRepository">
Options +Indexes
</Directory>
</VirtualHost>
When restored version of 1.7.7.1 on both the client and the server
everything is working again when it comes to
pushing my code.
http://myuse...@www.mysite.com/myproject/.git
the the TK OpenSSH dialog opens asking me for the password which i
enter.
On the server side. I have the following config in my conf file:
# Used for Webdav
LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
DAVLockDB "c:/WebTools/Apache2/temp/DAV.lock"
ServerName wrkstn1
Listen 8082
NameVirtualHost *:8082
<VirtualHost *:8082>
ServerAdmin myn...@email.com
ServerName wrkstn1
DocumentRoot C:/Repositories/GitRepository
ErrorLog logs/error_8082.txt
DirectoryIndex index
<Location />
Order Allow,Deny
Allow from all
Dav on
AuthType Basic
AuthName "Git Project Repository"
AuthUserFile c:/WebTools/passwords/gitpasswords.dat
Require valid-user
<Limitexcept GET POST HEAD PROPFIND OPTIONS REPORT>
Require valid-user
</Limitexcept>
</Location>
# Allows directory browsing on the set paths
<Directory "C:/Repositories/GitRepository">
Options +Indexes
</Directory>
</VirtualHost>
- The email and my servername was modified just so i dont have my
personal info on this message.
I switch it back to the previous version 1.7.7.1 and everything works
fine.
Thanks
I tried doing ALL sorts of searches to figure out how to get a .netrc
file working on a Windows based machine to no avail. In the end, I
ended up un-installing Git from the one Windows XP machine that I had
previously upgraded, and I have since re-installed Git verison
1.7.7.1. Now the prompt for password has returned and full
functionality has been restored to this machine.
On Dec 9, 8:47 am, Konstantin Khomoutov
<flatw...@users.sourceforge.net> wrote:
> On Fri, 9 Dec 2011 08:08:04 -0800 (PST)
>
>
>
>
>
>
>
>
>
> Eric <eric.advinc...@gmail.com> wrote:
> > When i try to push via http it fails all the time now.
>
> > Git error is:
>
> > Pushing tohttp://myurl/project/.git
> > error: Cannot access URLhttp://myrul/project/.git/, return code 22
[1] http://thread.gmane.org/gmane.comp.version-control.msysgit/14138
--
Sebastian Schuberth
> I'm putting Peff on CC for this thread [1], who recently worked on
> the HTTP credentials stuff. Maybe he has an idea how to debug this
> further.
Fortunately, my credentials code was not in v1.7.8, so it cannot be my
fault. :)
However, I have a theory.
> On 09.12.2011 17:08, Eric wrote:
>
> >When i try to push via http it fails all the time now.
> >
> >Git error is:
> >
> >Pushing to http://myurl/project/.git
> >error: Cannot access URL http://myrul/project/.git/, return code 22
> >fatal: git-http-push failed
> >
> >I changed my real url and project to myurl and project on the sample
> >above
> >
> >on my windows 7 Apache the error log says:
> >
> >[Fri Dec 09 08:58:57 2011] [error] [client 199.104.207.2] user
> >userName: authentication failure for "/project/.git/info/refs":
> >Password Mismatch
> >[Fri Dec 09 08:59:02 2011] [error] [client 199.104.207.2] user
> >userName: authentication failure for "/project/.git/": Password
> >Mismatch
> >
> >with version 1.7.7.1 and earlier it was never an issue. Am i missing
> >anything with the new release.
> >
> >Im running it on windows 7 and apache 2.2.21
It looks like you are using the old push-over-DAV protocol. Is that what
is supposed to be happening here, or is git failing to detect that it
can use smart-http?
Assuming that is what is supposed to be happening, I suspect the culprit
is 986bbc0 (http: don't always prompt for password, 2011-11-04). That
dropped the unconditional password prompt when we have a username, and
instead relied on the logic in 42653c0 (Prompt for a username when an
HTTP request 401s, 2010-04-01) to notice that the server wants a
password and ask then.
However, 42653c0's logic was added to the request functions in http.c,
whereas your error message comes from http-push.c:locking_available,
which rolls its own request straight to curl. So it bypasses the "try
again with a password" logic completely.
If this theory is right, then the patch below might fix it for you. It
emulates the same "try-again-with-auth" logic for http-push that is used
for regular http requests. However, I couldn't get the new tests to run
to completion. It correctly asks for a password, but then a later MKCOL
fails. I can't tell if that's because my patch is bad, or if there is
some other bug.
Can you give the patch a try and see if it helps?
---
diff --git a/http-push.c b/http-push.c
index edd553b..6dcf16d 100644
--- a/http-push.c
+++ b/http-push.c
@@ -40,6 +40,7 @@ enum XML_Status {
#define DAV_PROP_LOCKWR (1u << 0)
#define DAV_PROP_LOCKEX (1u << 1)
#define DAV_LOCK_OK (1u << 2)
+#define DAV_LOCK_REAUTH (1u << 3)
/* DAV XML properties */
#define DAV_CTX_LOCKENTRY ".multistatus.response.propstat.prop.supportedlock.lockentry"
@@ -1268,9 +1269,14 @@ static int locking_available(void)
repo->url);
} else {
- error("Cannot access URL %s, return code %d",
- repo->url, results.curl_result);
- lock_flags = 0;
+ if (results.http_code == 401) {
+ http_get_credentials(slot);
+ lock_flags = DAV_LOCK_REAUTH;
+ } else {
+ error("Cannot access URL %s, return code %d",
+ repo->url, results.curl_result);
+ lock_flags = 0;
+ }
}
} else {
error("Unable to start PROPFIND request on %s", repo->url);
@@ -1746,6 +1752,7 @@ int main(int argc, char **argv)
int rc = 0;
int i;
int new_refs;
+ int lock_flags;
struct ref *ref, *local_refs;
git_extract_argv0_path(argv[0]);
@@ -1827,9 +1834,13 @@ int main(int argc, char **argv)
#endif
/* Verify DAV compliance/lock support */
- if (!locking_available()) {
- rc = 1;
- goto cleanup;
+ lock_flags = locking_available();
+ if (lock_flags & DAV_LOCK_REAUTH) {
+ lock_flags = locking_available();
+ if (!lock_flags || lock_flags & DAV_LOCK_REAUTH) {
+ rc = 1;
+ goto cleanup;
+ }
}
sigchain_push_common(remove_locks_on_signal);
diff --git a/http.c b/http.c
index 44fcc4d..97c6fda 100644
--- a/http.c
+++ b/http.c
@@ -785,6 +785,19 @@ char *get_remote_object_url(const char *url, const char *hex,
return strbuf_detach(&buf, NULL);
}
+void http_get_credentials(struct active_request_slot *slot)
+{
+ /*
+ * git_getpass is needed here because its very likely stdin/stdout are
+ * pipes to our parent process. So we instead need to use /dev/tty,
+ * but that is non-portable. Using git_getpass() can at least be stubbed
+ * on other platforms with a different implementation if/when necessary.
+ */
+ if (!user_name)
+ user_name = xstrdup(git_getpass_with_description("Username", description));
+ init_curl_http_auth(slot->curl);
+}
+
/* http_request() targets */
#define HTTP_REQUEST_STRBUF 0
#define HTTP_REQUEST_FILE 1
@@ -840,15 +853,7 @@ static int http_request(const char *url, void *result, int target, int options)
if (user_name && user_pass) {
ret = HTTP_NOAUTH;
} else {
- /*
- * git_getpass is needed here because its very likely stdin/stdout are
- * pipes to our parent process. So we instead need to use /dev/tty,
- * but that is non-portable. Using git_getpass() can at least be stubbed
- * on other platforms with a different implementation if/when necessary.
- */
- if (!user_name)
- user_name = xstrdup(git_getpass_with_description("Username", description));
- init_curl_http_auth(slot->curl);
+ http_get_credentials(slot);
ret = HTTP_REAUTH;
}
} else {
diff --git a/http.h b/http.h
index ee16069..af845f3 100644
--- a/http.h
+++ b/http.h
@@ -78,6 +78,7 @@ struct buffer {
extern void run_active_slot(struct active_request_slot *slot);
extern void finish_active_slot(struct active_request_slot *slot);
extern void finish_all_active_slots(void);
+extern void http_get_credentials(struct active_request_slot *slot);
#ifdef USE_CURL_MULTI
extern void fill_active_slots(void);
diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
index 0a4cdfa..3c12b05 100644
--- a/t/lib-httpd/apache.conf
+++ b/t/lib-httpd/apache.conf
@@ -92,6 +92,9 @@ SSLEngine On
<Location /dumb/>
Dav on
</Location>
+ <Location /auth/dumb>
+ Dav on
+ </Location>
</IfDefine>
<IfDefine SVN>
diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh
index 64767d8..5e0b56a 100755
--- a/t/t5540-http-push.sh
+++ b/t/t5540-http-push.sh
@@ -45,6 +45,22 @@ test_expect_success 'clone remote repository' '
git clone $HTTPD_URL/dumb/test_repo.git test_repo_clone
'
+test_expect_success 'create password-protected repository' '
+ mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb" &&
+ cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git" \
+ "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git"
+'
+
+test_expect_success 'setup askpass helper' '
+ cat >askpass <<-\EOF &&
+ #!/bin/sh
+ echo user@host
+ EOF
+ chmod +x askpass &&
+ GIT_ASKPASS="$PWD/askpass" &&
+ export GIT_ASKPASS
+'
+
test_expect_success 'push to remote repository with packed refs' '
cd "$ROOT_PATH"/test_repo_clone &&
: >path2 &&
@@ -61,6 +77,14 @@ test_expect_success 'push already up-to-date' '
git push
'
+test_expect_success 'push to password-protected repository' '
+ git push "$HTTPD_URL/auth/dumb/test_repo.git" &&
+ git rev-parse --verify HEAD >expect &&
+ git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/test_repo.git" \
+ rev-parse --verify HEAD >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'push to remote repository with unpacked refs' '
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
rm packed-refs &&
On Fri, 6 Jan 2012, guillaum...@gmail.com wrote:
> I have not found any tutorial on how to build git / try a patch. I would
> love to try to patch and contribute to msysgit.
You can build Git as described here:
https://git.wiki.kernel.org/articles/i/n/s/MSysGit~InstallMSysGit_1a31.html
To try a patch, apply it in /git/ (possibly using the msysGit Bash) and
build Git with "cd /git/ && make" in Bash.
Ciao,
Johannes
On Fri, 6 Jan 2012, Johannes Schindelin wrote:
> On Fri, 6 Jan 2012, guillaum...@gmail.com wrote:
>
> > I have not found any tutorial on how to build git / try a patch. I would
> > love to try to patch and contribute to msysgit.
>
> You can build Git as described here:
> https://git.wiki.kernel.org/articles/i/n/s/MSysGit~InstallMSysGit_1a31.html
In related news, I now activated our GitHub Wiki. My understanding is that
anybody with a GitHub account can contribute (and since getting a GitHub
account is dirt-easy and free, that means literally everyone):
https://github.com/msysgit/msysgit/wiki
As an example, I copied the InstallMSysGit page from the Git Wiki,
directed my web browser to
https://github.com/msysgit/msysgit/wiki/InstallMSysGit
and pasted the text. Then I selected MediaWiki markup and added "= ... ="
markers around 1st level headings, "== ... ==" markers around 2nd level
headings, ''...'' around italic words/phrases, '''...''' around bold ones,
prefixed enumerations with "# " (in hindsight, I probably should have used
"* " since they used to be bullet lists) and verbatim sections with " " at
the beginning of the line.
This is something everybody can do.
Ciao,
Johannes
> I have not found any tutorial on how to build git / try a patch. I would
> love to try to patch and contribute to msysgit.
Although I appreciate the willingness to help, I believe you can spare the time to test Peff's patch by now as he already did another fix for the same issue in upstream Git 1.7.8.2, see
https://github.com/msysgit/git/commit/a4ddbc33d7906f0e10c68c140a9a1003d9715a77
--
Sebastian Schuberth
I've resolved various issues with the minimalism of msysgit so that I have
working scripts but I'm not sure about the right way to name the script
files.
I've been naming them with a .sh extension and running them direct from
their current directory (full name including extension) without doing any
'chmod's on them.
My understanding so far is:
In windows one expects to add a file extension to the file name to indicate
what it is, e.g. .pdf or .zip, and then windows knows what to do give the
name without the extension.
In Unix the first line of a script has the hashbang(shebang) followed by
the name of the interpreter, so it know what to do. Plus you should make
them executable. [http://www.ooblick.com/text/sh/]
For the msysgit user (me) the distinctions are either blurred, or were
opaque.
For example, In the git (1.7.8 full install) files there is both a
'git-submodule' and a 'git-submodule.sh' file with identical content. I'm
not sure why both namings are provided/needed, and for my own scripts. I'm
not sure sure what are the various 'right ways' of naming the files.
Could someone cast light on When and why to use a .sh extension on an
msysgit script?
Philip
In the git sources, files with .sh extensions are source and without
are generated from the source possibly with some substitutions. A
clean checkout of git will have 'git-submodule.sh' and one you run
make you will have a 'git-submodule' file. This is the one that should
get installed. If you look in Program Files\Git\libexec\git-core for
git-submodule* you will find only the version without the extension.
(Or you should do).
Was my thinking about when when to add an extension to the file name, or
make executable, for the two domains (Windows and Unix) about right? It
seems to be one of those things that is never mentioned, but is assumed
knowledge.
Philip
On Sun, 8 Jan 2012, Philip Oakley wrote:
> From: "Johannes Schindelin" <Johannes....@gmx.de>ent: Friday, January
> 06, 2012 9:58 PM
> > On Fri, 6 Jan 2012, Johannes Schindelin wrote:
> > > On Fri, 6 Jan 2012, guillaum...@gmail.com wrote:
> > > > I have not found any tutorial on how to build git / try a patch. I would
> > > > love to try to patch and contribute to msysgit.
> > >
> > > You can build Git as described here:
> > > https://git.wiki.kernel.org/articles/i/n/s/MSysGit~InstallMSysGit_1a31.html
> >
> > In related news, I now activated our GitHub Wiki. My understanding is that
> > anybody with a GitHub account can contribute (and since getting a GitHub
> > account is dirt-easy and free, that means literally everyone):
> >
> > https://github.com/msysgit/msysgit/wiki
> >
>
> I couldn't find any way to create a page.
Just direct your webbrowser to the URL
https://github.com/msysgit/msysgit/wiki/MyNewPage
I agree it is not very intuitive, but it is the same for other Wikis.
Ciao,
Johannes
On unix if the file is executable, then the process launching code
examines the start of the file for executable markers. If it sees #!
then it uses the indicated program to launch the file otherwise it
uses ELF or whatever to load a binary executable.
On windows we just have to know in places where we might expect a user
script that we need to perform these checks. So the windows
gitk/git-gui code for instance actually opens any hook scripts and
checks itself for #! at the start. We cannot assume that something
executable will have .sh on the end so instead we assume that when
passed a filename in a place we expect to receive an executable that
somehow it is executable. Then we try and run it. So in the
git/contrib/mingw.c file for mingw_spawnvpw there is an explict check
to see if we need to run an interpreter (parse_interpreter).
On my own system, I tend to add .sh to my scripts just so it is
obvious when looking at them that those are bash scripts. It also
helps if you want to associate any open/edit commands with the file
type as that is done on the extension. But when it comes to running
them, we look at the file magic - we have to.
So you spell out their names in full (including the .sh) when they are being
called, either from the command line or within other nested scripts (for use
on linux/bash), while-unix only folk probably won't be using the .sh in
either place. One simply has to be consistent in using the full name in
either choice.
Johannes,
I couldn't find any way to create a page. I was able to edit the home page
to give a link to the install page.
Is there something special that needs to be done to allow new pages to be
created now that we have a way of copying and marking up the old pages?
Philip
On Fri, 6 Jan 2012, Johannes Schindelin wrote:
> In related news, I now activated our GitHub Wiki. My understanding is
> that anybody with a GitHub account can contribute (and since getting a
> GitHub account is dirt-easy and free, that means literally everyone):
>
> https://github.com/msysgit/msysgit/wiki
I finally managed to get ahold of one of the kernel.org admins and got
kind of a dump of pages. The history is lost.
From now on, if anybody spots an issue in the Wiki: fix it.
Ciao,
Johannes
On Tue, 10 Jan 2012, Johannes Schindelin wrote:
> On Fri, 6 Jan 2012, Johannes Schindelin wrote:
>
> > In related news, I now activated our GitHub Wiki. My understanding is
> > that anybody with a GitHub account can contribute (and since getting a
> > GitHub account is dirt-easy and free, that means literally everyone):
> >
> > https://github.com/msysgit/msysgit/wiki
>
> I finally managed to get ahold of one of the kernel.org admins and got
> kind of a dump of pages. The history is lost.
Before I forget: I updated on http://msysgit.googlecode.com/, too.
Ciao,
Johannes