* defined behaviour for multiple urls for a remote
From: Sitaram Chamarty @ 2011-10-14 7:07 UTC (permalink / raw)
To: Git Mailing List
Hi,
What's the defined behaviour if I do this:
[remote "both"]
url = https://code.google.com/p/gitolite/
url = git@github.com:sitaramc/gitolite.git
I know what I'm seeing (a fetch only goes to the first URL, and does a
HEAD->FETCH_HEAD because I didn't provide a refspec line, while a push
seems to push all to both), but I was curious what the official
position is, because I couldn't find it in the docs.
--
Sitaram
^ permalink raw reply
* Re: [BUG] git checkout <branch> allowed with uncommitted changes
From: Victor Engmark @ 2011-10-14 7:16 UTC (permalink / raw)
To: arQon; +Cc: git
In-Reply-To: <loom.20111013T175500-495@post.gmane.org>
On Thu, Oct 13, 2011 at 04:17:51PM +0000, arQon wrote:
> Victor Engmark <victor.engmark <at> terreactive.ch> writes:
> > 1. `checkout master` and commit the fix there, then shift back and
> > continue working
>
> I absolutely agree. And it's far more common than any of us would like.
> My point is, you *can't* do this in git without first staging your current branch
> via either commit or stash, or you risk changes bleeding between the branches
> and/or work being lost irretrievably.
It's been pointed out enough times already that work is *not* lost (at
least unless you --force it to) *nor* the branches corrupted, so I'll
just advice to look at more Git documentation. I used CVS 2004-2006 or
so, Subversion 2006-2009, and Git since then. It's vastly superior to
either, and it's really difficult to lose any work unless getting into
the habit of forcing every change.
> This is not something that you would
> expect, and as you say:
>
> > The second most important thing a VCS should do is not destroy any of your
> uncommitted work unless you tell it to
>
> ... which is exactly what git does, and why I have a problem with it.
No, it does not. Others have explained this better already.
> But the response here is uniformly "that's just how git is", so obviously it's
> something you learn to become aware of over time, and avoid. It's not going to
> get "fixed", because people who are used to git don't see it as a bug, so I just
> have to decide whether I can live with it or not.
It took a while to get my head around just how broken the Subversion
model was, and why my expectations from using that model kept resulting
in "weird" state (although don't get me started on `svn clean`). Don't
worry, you'll see the light :)
--
terreActive AG
Kasinostrasse 30
CH-5001 Aarau
Tel: +41 62 834 00 55
Fax: +41 62 823 93 56
www.terreactive.ch
Wir sichern Ihren Erfolg - seit 15 Jahren
^ permalink raw reply
* [PATCH 0/6] http-auth-early
From: Michael J Gruber @ 2011-10-14 7:40 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
In-Reply-To: <4E9692BF.8040705@drmicha.warpmail.net>
Here are the early parts of Jeff's http-auth-keyring series.
It contains only parts which are not using the credential API (which
is still under discussion), so that this can go in (and help users)
and alleviates the pressure on the credential discussion:
Early bits with cleanups to http.c.
Cherry-picked bit for improved prompts ("Username for ..." etc.)
Cherry-pickes bit for using configured pushurls.
I tried to pick/resolve in a way which should help rebasing Jeff's series
on top of this.
Jeff King (5):
url: decode buffers that are not NUL-terminated
improve httpd auth tests
remote-curl: don't retry auth failures with dumb protocol
http: retry authentication failures for all http requests
http_init: accept separate URL parameter
Michael J Gruber (1):
http: use hostname in credential description
http-fetch.c | 2 +-
http-push.c | 10 +-----
http.c | 91 +++++++++++++++++++++++++++---------------------
http.h | 2 +-
remote-curl.c | 4 +-
t/lib-httpd.sh | 10 +++--
t/t5550-http-fetch.sh | 51 +++++++++++++++++++++++++--
url.c | 26 ++++++++++----
url.h | 1 +
9 files changed, 128 insertions(+), 69 deletions(-)
--
1.7.7.338.g0156b
^ permalink raw reply
* [PATCH 1/6] url: decode buffers that are not NUL-terminated
From: Michael J Gruber @ 2011-10-14 7:40 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
In-Reply-To: <cover.1318577792.git.git@drmicha.warpmail.net>
From: Jeff King <peff@peff.net>
The url_decode function needs only minor tweaks to handle
arbitrary buffers. Let's do those tweaks, which cleans up an
unreadable mess of temporary strings in http.c.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
http.c | 27 ++++-----------------------
url.c | 26 ++++++++++++++++++--------
url.h | 1 +
3 files changed, 23 insertions(+), 31 deletions(-)
diff --git a/http.c b/http.c
index a1ea3db..c93716c 100644
--- a/http.c
+++ b/http.c
@@ -307,8 +307,7 @@ static CURL *get_curl_handle(void)
static void http_auth_init(const char *url)
{
- char *at, *colon, *cp, *slash, *decoded;
- int len;
+ char *at, *colon, *cp, *slash;
cp = strstr(url, "://");
if (!cp)
@@ -328,29 +327,11 @@ static void http_auth_init(const char *url)
return; /* No credentials */
if (!colon || at <= colon) {
/* Only username */
- len = at - cp;
- user_name = xmalloc(len + 1);
- memcpy(user_name, cp, len);
- user_name[len] = '\0';
- decoded = url_decode(user_name);
- free(user_name);
- user_name = decoded;
+ user_name = url_decode_mem(cp, at - cp);
user_pass = NULL;
} else {
- len = colon - cp;
- user_name = xmalloc(len + 1);
- memcpy(user_name, cp, len);
- user_name[len] = '\0';
- decoded = url_decode(user_name);
- free(user_name);
- user_name = decoded;
- len = at - (colon + 1);
- user_pass = xmalloc(len + 1);
- memcpy(user_pass, colon + 1, len);
- user_pass[len] = '\0';
- decoded = url_decode(user_pass);
- free(user_pass);
- user_pass = decoded;
+ user_name = url_decode_mem(cp, colon - cp);
+ user_pass = url_decode_mem(colon + 1, at - (colon + 1));
}
}
diff --git a/url.c b/url.c
index 3e06fd3..389d9da 100644
--- a/url.c
+++ b/url.c
@@ -68,18 +68,20 @@ static int url_decode_char(const char *q)
return val;
}
-static char *url_decode_internal(const char **query, const char *stop_at,
- struct strbuf *out, int decode_plus)
+static char *url_decode_internal(const char **query, int len,
+ const char *stop_at, struct strbuf *out,
+ int decode_plus)
{
const char *q = *query;
- do {
+ while (len) {
unsigned char c = *q;
if (!c)
break;
if (stop_at && strchr(stop_at, c)) {
q++;
+ len--;
break;
}
@@ -88,6 +90,7 @@ static char *url_decode_internal(const char **query, const char *stop_at,
if (0 <= val) {
strbuf_addch(out, val);
q += 3;
+ len -= 3;
continue;
}
}
@@ -97,34 +100,41 @@ static char *url_decode_internal(const char **query, const char *stop_at,
else
strbuf_addch(out, c);
q++;
- } while (1);
+ len--;
+ }
*query = q;
return strbuf_detach(out, NULL);
}
char *url_decode(const char *url)
{
+ return url_decode_mem(url, strlen(url));
+}
+
+char *url_decode_mem(const char *url, int len)
+{
struct strbuf out = STRBUF_INIT;
- const char *colon = strchr(url, ':');
+ const char *colon = memchr(url, ':', len);
/* Skip protocol part if present */
if (colon && url < colon) {
strbuf_add(&out, url, colon - url);
+ len -= colon - url;
url = colon;
}
- return url_decode_internal(&url, NULL, &out, 0);
+ return url_decode_internal(&url, len, NULL, &out, 0);
}
char *url_decode_parameter_name(const char **query)
{
struct strbuf out = STRBUF_INIT;
- return url_decode_internal(query, "&=", &out, 1);
+ return url_decode_internal(query, -1, "&=", &out, 1);
}
char *url_decode_parameter_value(const char **query)
{
struct strbuf out = STRBUF_INIT;
- return url_decode_internal(query, "&", &out, 1);
+ return url_decode_internal(query, -1, "&", &out, 1);
}
void end_url_with_slash(struct strbuf *buf, const char *url)
diff --git a/url.h b/url.h
index 7100e32..abdaf6f 100644
--- a/url.h
+++ b/url.h
@@ -4,6 +4,7 @@
extern int is_url(const char *url);
extern int is_urlschemechar(int first_flag, int ch);
extern char *url_decode(const char *url);
+extern char *url_decode_mem(const char *url, int len);
extern char *url_decode_parameter_name(const char **query);
extern char *url_decode_parameter_value(const char **query);
--
1.7.7.338.g0156b
^ permalink raw reply related
* [PATCH 2/6] improve httpd auth tests
From: Michael J Gruber @ 2011-10-14 7:40 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
In-Reply-To: <cover.1318577792.git.git@drmicha.warpmail.net>
From: Jeff King <peff@peff.net>
These just checked that we could clone a repository when the
username and password were given in the URL; we should also
check that git will prompt when no or partial credentials
are given.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/lib-httpd.sh | 10 +++++---
t/t5550-http-fetch.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index b8996a3..f7dc078 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -81,8 +81,7 @@ prepare_httpd() {
if test -n "$LIB_HTTPD_SSL"
then
- HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT
- AUTH_HTTPD_URL=https://user%40host:user%40host@127.0.0.1:$LIB_HTTPD_PORT
+ HTTPD_PROTO=https
RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \
-config "$TEST_PATH/ssl.cnf" \
@@ -93,9 +92,12 @@ prepare_httpd() {
export GIT_SSL_NO_VERIFY
HTTPD_PARA="$HTTPD_PARA -DSSL"
else
- HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
- AUTH_HTTPD_URL=http://user%40host:user%40host@127.0.0.1:$LIB_HTTPD_PORT
+ HTTPD_PROTO=http
fi
+ HTTPD_DEST=127.0.0.1:$LIB_HTTPD_PORT
+ HTTPD_URL=$HTTPD_PROTO://$HTTPD_DEST
+ HTTPD_URL_USER=$HTTPD_PROTO://user%40host@$HTTPD_DEST
+ HTTPD_URL_USER_PASS=$HTTPD_PROTO://user%40host:user%40host@$HTTPD_DEST
if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN"
then
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index a1883ca..ed4db09 100755
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
@@ -35,11 +35,54 @@ test_expect_success 'clone http repository' '
test_cmp file clone/file
'
-test_expect_success 'clone http repository with authentication' '
+test_expect_success 'create password-protected repository' '
mkdir "$HTTPD_DOCUMENT_ROOT_PATH/auth/" &&
- cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" "$HTTPD_DOCUMENT_ROOT_PATH/auth/repo.git" &&
- git clone $AUTH_HTTPD_URL/auth/repo.git clone-auth &&
- test_cmp file clone-auth/file
+ cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
+ "$HTTPD_DOCUMENT_ROOT_PATH/auth/repo.git"
+'
+
+test_expect_success 'setup askpass helpers' '
+ cat >askpass <<-EOF &&
+ #!/bin/sh
+ echo >>"$PWD/askpass-query" "askpass: \$*" &&
+ cat "$PWD/askpass-response"
+ EOF
+ chmod +x askpass &&
+ GIT_ASKPASS="$PWD/askpass" &&
+ export GIT_ASKPASS &&
+ >askpass-expect-none &&
+ echo "askpass: Password: " >askpass-expect-pass &&
+ { echo "askpass: Username: " &&
+ cat askpass-expect-pass
+ } >askpass-expect-both
+'
+
+test_expect_success 'cloning password-protected repository can fail' '
+ >askpass-query &&
+ echo wrong >askpass-response &&
+ test_must_fail git clone "$HTTPD_URL/auth/repo.git" clone-auth-fail &&
+ test_cmp askpass-expect-both askpass-query
+'
+
+test_expect_success 'http auth can use user/pass in URL' '
+ >askpass-query &&
+ echo wrong >askpass-reponse &&
+ git clone "$HTTPD_URL_USER_PASS/auth/repo.git" clone-auth-none &&
+ test_cmp askpass-expect-none askpass-query
+'
+
+test_expect_success 'http auth can use just user in URL' '
+ >askpass-query &&
+ echo user@host >askpass-response &&
+ git clone "$HTTPD_URL_USER/auth/repo.git" clone-auth-pass &&
+ test_cmp askpass-expect-pass askpass-query
+'
+
+test_expect_success 'http auth can request both user and pass' '
+ >askpass-query &&
+ echo user@host >askpass-response &&
+ git clone "$HTTPD_URL/auth/repo.git" clone-auth-both &&
+ test_cmp askpass-expect-both askpass-query
'
test_expect_success 'fetch changes via http' '
--
1.7.7.338.g0156b
^ permalink raw reply related
* [PATCH 3/6] remote-curl: don't retry auth failures with dumb protocol
From: Michael J Gruber @ 2011-10-14 7:40 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
In-Reply-To: <cover.1318577792.git.git@drmicha.warpmail.net>
From: Jeff King <peff@peff.net>
When fetching an http URL, we first try fetching info/refs
with an extra "service" parameter. This will work for a
smart-http server, or a dumb server which ignores extra
parameters when fetching files. If that fails, we retry
without the extra parameter to remain compatible with dumb
servers which didn't like our first request.
If the server returned a "401 Unauthorized", indicating that
the credentials we provided were not good, there is not much
point in retrying. With the current code, we just waste an
extra round trip to the HTTP server before failing.
But as the http code becomes smarter about throwing away
rejected credentials and re-prompting the user for new ones
(which it will later in this series), this will become more
confusing. At some point we will stop asking for credentials
to retry smart http, and will be asking for credentials to
retry dumb http. So now we're not only wasting an extra HTTP
round trip for something that is unlikely to work, but we're
making the user re-type their password for it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
remote-curl.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index faaeda4..6c24ab1 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -115,7 +115,7 @@ static struct discovery* discover_refs(const char *service)
http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
/* try again with "plain" url (no ? or & appended) */
- if (http_ret != HTTP_OK) {
+ if (http_ret != HTTP_OK && http_ret != HTTP_NOAUTH) {
free(refs_url);
strbuf_reset(&buffer);
--
1.7.7.338.g0156b
^ permalink raw reply related
* [PATCH 4/6] http: retry authentication failures for all http requests
From: Michael J Gruber @ 2011-10-14 7:40 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
In-Reply-To: <cover.1318577792.git.git@drmicha.warpmail.net>
From: Jeff King <peff@peff.net>
Commit 42653c0 (Prompt for a username when an HTTP request
401s, 2010-04-01) changed http_get_strbuf to prompt for
credentials when we receive a 401, but didn't touch
http_get_file. The latter is called only for dumb http;
while it's usually the case that people don't use
authentication on top of dumb http, there is no reason not
to allow both types of requests to use this feature.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
http.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/http.c b/http.c
index c93716c..89e3cf4 100644
--- a/http.c
+++ b/http.c
@@ -846,13 +846,18 @@ static int http_request(const char *url, void *result, int target, int options)
return ret;
}
+static int http_request_reauth(const char *url, void *result, int target,
+ int options)
+{
+ int ret = http_request(url, result, target, options);
+ if (ret != HTTP_REAUTH)
+ return ret;
+ return http_request(url, result, target, options);
+}
+
int http_get_strbuf(const char *url, struct strbuf *result, int options)
{
- int http_ret = http_request(url, result, HTTP_REQUEST_STRBUF, options);
- if (http_ret == HTTP_REAUTH) {
- http_ret = http_request(url, result, HTTP_REQUEST_STRBUF, options);
- }
- return http_ret;
+ return http_request_reauth(url, result, HTTP_REQUEST_STRBUF, options);
}
/*
@@ -875,7 +880,7 @@ static int http_get_file(const char *url, const char *filename, int options)
goto cleanup;
}
- ret = http_request(url, result, HTTP_REQUEST_FILE, options);
+ ret = http_request_reauth(url, result, HTTP_REQUEST_FILE, options);
fclose(result);
if ((ret == HTTP_OK) && move_temp_to_file(tmpfile.buf, filename))
--
1.7.7.338.g0156b
^ permalink raw reply related
* [PATCH 5/6] http: use hostname in credential description
From: Michael J Gruber @ 2011-10-14 7:40 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
In-Reply-To: <cover.1318577792.git.git@drmicha.warpmail.net>
Until now, a request for an http password looked like:
Username:
Password:
Now it will look like:
Username for 'example.com':
Password for 'example.com':
Picked-from: Jeff King <peff@peff.net>
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
http.c | 41 +++++++++++++++++++++++++++++++++--------
t/t5550-http-fetch.sh | 4 ++--
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/http.c b/http.c
index 89e3cf4..149e116 100644
--- a/http.c
+++ b/http.c
@@ -42,7 +42,7 @@ static long curl_low_speed_time = -1;
static int curl_ftp_no_epsv;
static const char *curl_http_proxy;
static const char *curl_cookie_file;
-static char *user_name, *user_pass;
+static char *user_name, *user_pass, *description;
static const char *user_agent;
#if LIBCURL_VERSION_NUM >= 0x071700
@@ -139,6 +139,25 @@ static void process_curl_messages(void)
}
#endif
+static char *git_getpass_one(const char *what, const char *desc)
+{
+ struct strbuf prompt = STRBUF_INIT;
+ char *r;
+
+ if (desc)
+ strbuf_addf(&prompt, "%s for '%s': ", what, desc);
+ else
+ strbuf_addf(&prompt, "%s: ", what);
+ /* FIXME: for usernames, we should do something less magical that
+ * actually echoes the characters. However, we need to read from
+ * /dev/tty and not stdio, which is not portable (but getpass will do
+ * it for us). http.c uses the same workaround. */
+ r = git_getpass(prompt.buf);
+
+ strbuf_release(&prompt);
+ return xstrdup(r);
+}
+
static int http_options(const char *var, const char *value, void *cb)
{
if (!strcmp("http.sslverify", var)) {
@@ -214,7 +233,7 @@ static void init_curl_http_auth(CURL *result)
if (user_name) {
struct strbuf up = STRBUF_INIT;
if (!user_pass)
- user_pass = xstrdup(git_getpass("Password: "));
+ user_pass = xstrdup(git_getpass_one("Password", description));
strbuf_addf(&up, "%s:%s", user_name, user_pass);
curl_easy_setopt(result, CURLOPT_USERPWD,
strbuf_detach(&up, NULL));
@@ -229,7 +248,7 @@ static int has_cert_password(void)
return 0;
/* Only prompt the user once. */
ssl_cert_password_required = -1;
- ssl_cert_password = git_getpass("Certificate Password: ");
+ ssl_cert_password = git_getpass_one("Certificate Password", description);
if (ssl_cert_password != NULL) {
ssl_cert_password = xstrdup(ssl_cert_password);
return 1;
@@ -307,7 +326,7 @@ static CURL *get_curl_handle(void)
static void http_auth_init(const char *url)
{
- char *at, *colon, *cp, *slash;
+ const char *at, *colon, *cp, *slash, *host;
cp = strstr(url, "://");
if (!cp)
@@ -323,16 +342,22 @@ static void http_auth_init(const char *url)
at = strchr(cp, '@');
colon = strchr(cp, ':');
slash = strchrnul(cp, '/');
- if (!at || slash <= at)
- return; /* No credentials */
- if (!colon || at <= colon) {
+ if (!at || slash <= at) {
+ /* No credentials, but we may have to ask for some later */
+ host = cp;
+ }
+ else if (!colon || at <= colon) {
/* Only username */
user_name = url_decode_mem(cp, at - cp);
user_pass = NULL;
+ host = at + 1;
} else {
user_name = url_decode_mem(cp, colon - cp);
user_pass = url_decode_mem(colon + 1, at - (colon + 1));
+ host = at + 1;
}
+
+ description = url_decode_mem(host, slash - host);
}
static void set_from_env(const char **var, const char *envname)
@@ -828,7 +853,7 @@ static int http_request(const char *url, void *result, int target, int options)
* but that is non-portable. Using git_getpass() can at least be stubbed
* on other platforms with a different implementation if/when necessary.
*/
- user_name = xstrdup(git_getpass("Username: "));
+ user_name = xstrdup(git_getpass_one("Username", description));
init_curl_http_auth(slot->curl);
ret = HTTP_REAUTH;
}
diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh
index ed4db09..d1ab4d0 100755
--- a/t/t5550-http-fetch.sh
+++ b/t/t5550-http-fetch.sh
@@ -51,8 +51,8 @@ test_expect_success 'setup askpass helpers' '
GIT_ASKPASS="$PWD/askpass" &&
export GIT_ASKPASS &&
>askpass-expect-none &&
- echo "askpass: Password: " >askpass-expect-pass &&
- { echo "askpass: Username: " &&
+ echo "askpass: Password for '\''$HTTPD_DEST'\'': " >askpass-expect-pass &&
+ { echo "askpass: Username for '\''$HTTPD_DEST'\'': " &&
cat askpass-expect-pass
} >askpass-expect-both
'
--
1.7.7.338.g0156b
^ permalink raw reply related
* [PATCH 6/6] http_init: accept separate URL parameter
From: Michael J Gruber @ 2011-10-14 7:40 UTC (permalink / raw)
To: git; +Cc: Jeff King, Junio C Hamano
In-Reply-To: <cover.1318577792.git.git@drmicha.warpmail.net>
From: Jeff King <peff@peff.net>
The http_init function takes a "struct remote". Part of its
initialization procedure is to look at the remote's url and
grab some auth-related parameters. However, using the url
included in the remote is:
- wrong; the remote-curl helper may have a separate,
unrelated URL (e.g., from remote.*.pushurl). Looking at
the remote's configured url is incorrect.
- incomplete; http-fetch doesn't have a remote, so passes
NULL. So http_init never gets to see the URL we are
actually going to use.
- cumbersome; http-push has a similar problem to
http-fetch, but actually builds a fake remote just to
pass in the URL.
Instead, let's just add a separate URL parameter to
http_init, and all three callsites can pass in the
appropriate information.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
http-fetch.c | 2 +-
http-push.c | 10 +---------
http.c | 8 ++++----
http.h | 2 +-
remote-curl.c | 2 +-
5 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/http-fetch.c b/http-fetch.c
index 3af4c71..e341872 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -63,7 +63,7 @@ int main(int argc, const char **argv)
git_config(git_default_config, NULL);
- http_init(NULL);
+ http_init(NULL, url);
walker = get_http_walker(url);
walker->get_tree = get_tree;
walker->get_history = get_history;
diff --git a/http-push.c b/http-push.c
index 6e8f6d0..ecbfae5 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1747,7 +1747,6 @@ int main(int argc, char **argv)
int i;
int new_refs;
struct ref *ref, *local_refs;
- struct remote *remote;
git_extract_argv0_path(argv[0]);
@@ -1821,14 +1820,7 @@ int main(int argc, char **argv)
memset(remote_dir_exists, -1, 256);
- /*
- * Create a minimum remote by hand to give to http_init(),
- * primarily to allow it to look at the URL.
- */
- remote = xcalloc(sizeof(*remote), 1);
- ALLOC_GROW(remote->url, remote->url_nr + 1, remote->url_alloc);
- remote->url[remote->url_nr++] = repo->url;
- http_init(remote);
+ http_init(NULL, repo->url);
#ifdef USE_CURL_MULTI
is_running_queue = 0;
diff --git a/http.c b/http.c
index 149e116..b181c8a 100644
--- a/http.c
+++ b/http.c
@@ -367,7 +367,7 @@ static void set_from_env(const char **var, const char *envname)
*var = val;
}
-void http_init(struct remote *remote)
+void http_init(struct remote *remote, const char *url)
{
char *low_speed_limit;
char *low_speed_time;
@@ -431,11 +431,11 @@ void http_init(struct remote *remote)
if (getenv("GIT_CURL_FTP_NO_EPSV"))
curl_ftp_no_epsv = 1;
- if (remote && remote->url && remote->url[0]) {
- http_auth_init(remote->url[0]);
+ if (url) {
+ http_auth_init(url);
if (!ssl_cert_password_required &&
getenv("GIT_SSL_CERT_PASSWORD_PROTECTED") &&
- !prefixcmp(remote->url[0], "https://"))
+ !prefixcmp(url, "https://"))
ssl_cert_password_required = 1;
}
diff --git a/http.h b/http.h
index 0bf8592..3c332a9 100644
--- a/http.h
+++ b/http.h
@@ -86,7 +86,7 @@ extern void add_fill_function(void *data, int (*fill)(void *));
extern void step_active_slots(void);
#endif
-extern void http_init(struct remote *remote);
+extern void http_init(struct remote *remote, const char *url);
extern void http_cleanup(void);
extern int data_received;
diff --git a/remote-curl.c b/remote-curl.c
index 6c24ab1..d4d0910 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -850,7 +850,7 @@ int main(int argc, const char **argv)
url = strbuf_detach(&buf, NULL);
- http_init(remote);
+ http_init(remote, url);
do {
if (strbuf_getline(&buf, stdin, '\n') == EOF)
--
1.7.7.338.g0156b
^ permalink raw reply related
* [PATCH 1/4] git-gui: handle config booleans without value
From: Bert Wesarg @ 2011-10-14 8:14 UTC (permalink / raw)
To: Pat Thoyts; +Cc: git, Bert Wesarg
When git interprets a config variable without a value as bool it is considered
as true. But git-gui doesn't so until yet.
The value for boolean configs are also case-insensitive.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
git-gui.sh | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index f897160..d687871 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -299,7 +299,9 @@ proc is_config_true {name} {
global repo_config
if {[catch {set v $repo_config($name)}]} {
return 0
- } elseif {$v eq {true} || $v eq {1} || $v eq {yes}} {
+ }
+ set v [string tolower $v]
+ if {$v eq {} || $v eq {true} || $v eq {1} || $v eq {yes} || $v eq {on}} {
return 1
} else {
return 0
@@ -310,7 +312,9 @@ proc is_config_false {name} {
global repo_config
if {[catch {set v $repo_config($name)}]} {
return 0
- } elseif {$v eq {false} || $v eq {0} || $v eq {no}} {
+ }
+ set v [string tolower $v]
+ if {$v eq {false} || $v eq {0} || $v eq {no} || $v eq {off}} {
return 1
} else {
return 0
@@ -1060,6 +1064,10 @@ git-version proc _parse_config {arr_name args} {
} else {
set arr($name) $value
}
+ } elseif {[regexp {^([^\n]+)$} $line line name]} {
+ # no value given, but interpreting them as
+ # boolean will be handled as true
+ set arr($name) {}
}
}
}
@@ -1075,6 +1083,10 @@ git-version proc _parse_config {arr_name args} {
} else {
set arr($name) $value
}
+ } elseif {[regexp {^([^=]+)$} $line line name]} {
+ # no value given, but interpreting them as
+ # boolean will be handled as true
+ set arr($name) {}
}
}
close $fd_rc
--
1.7.6.789.gb4599
^ permalink raw reply related
* [PATCH 2/4] git-gui: add smart case search mode in searchbar
From: Bert Wesarg @ 2011-10-14 8:14 UTC (permalink / raw)
To: Pat Thoyts; +Cc: git, Bert Wesarg
In-Reply-To: <94b050c4cf7ae8df8d79112e13613244ebff4037.1318579823.git.bert.wesarg@googlemail.com>
Setting config gui.search.smartcase to true, the search mode in the
searchbar (from the blame view) is by default case-insensitive. But
entering an upper case letter into the search field activates the case-
sensitive search mode.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
lib/search.tcl | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/lib/search.tcl b/lib/search.tcl
index ef3486f..461c66d 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -7,7 +7,8 @@ field w
field ctext
field searchstring {}
-field casesensitive 1
+field casesensitive
+field default_casesensitive
field searchdirn -forwards
field smarktop
@@ -18,6 +19,12 @@ constructor new {i_w i_text args} {
set w $i_w
set ctext $i_text
+ if {[is_config_true gui.search.smartcase]} {
+ set default_casesensitive 0
+ } else {
+ set default_casesensitive 1
+ }
+
${NS}::frame $w
${NS}::label $w.l -text [mc Find:]
entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
@@ -45,6 +52,7 @@ constructor new {i_w i_text args} {
method show {} {
if {![visible $this]} {
grid $w
+ set casesensitive $default_casesensitive
}
focus -force $w.ent
}
@@ -125,6 +133,9 @@ method _incrsearch {} {
if {[catch {$ctext index anchor}]} {
$ctext mark set anchor [_get_new_anchor $this]
}
+ if {[regexp {[[:upper:]]} $searchstring]} {
+ set casesensitive 1
+ }
if {$searchstring ne {}} {
set here [_do_search $this anchor mlen]
if {$here ne {}} {
--
1.7.6.789.gb4599
^ permalink raw reply related
* [PATCH 3/4] git-gui: add regexp search mode to the searchbar
From: Bert Wesarg @ 2011-10-14 8:14 UTC (permalink / raw)
To: Pat Thoyts; +Cc: git, Bert Wesarg
In-Reply-To: <94b050c4cf7ae8df8d79112e13613244ebff4037.1318579823.git.bert.wesarg@googlemail.com>
It's off by default, but can be enabled via the config gui.search.regexp.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
lib/search.tcl | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/lib/search.tcl b/lib/search.tcl
index 461c66d..9268ec3 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -7,6 +7,8 @@ field w
field ctext
field searchstring {}
+field regexpsearch
+field default_regexpsearch
field casesensitive
field default_casesensitive
field searchdirn -forwards
@@ -19,6 +21,7 @@ constructor new {i_w i_text args} {
set w $i_w
set ctext $i_text
+ set default_regexpsearch [is_config_true gui.search.regexp]
if {[is_config_true gui.search.smartcase]} {
set default_casesensitive 0
} else {
@@ -30,10 +33,13 @@ constructor new {i_w i_text args} {
entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
${NS}::button $w.bn -text [mc Next] -command [cb find_next]
${NS}::button $w.bp -text [mc Prev] -command [cb find_prev]
- ${NS}::checkbutton $w.cs -text [mc Case-Sensitive] \
+ ${NS}::checkbutton $w.re -text [mc RegExp] \
+ -variable ${__this}::regexpsearch -command [cb _incrsearch]
+ ${NS}::checkbutton $w.cs -text [mc Case] \
-variable ${__this}::casesensitive -command [cb _incrsearch]
pack $w.l -side left
pack $w.cs -side right
+ pack $w.re -side right
pack $w.bp -side right
pack $w.bn -side right
pack $w.ent -side left -expand 1 -fill x
@@ -52,6 +58,7 @@ constructor new {i_w i_text args} {
method show {} {
if {![visible $this]} {
grid $w
+ set regexpsearch $default_regexpsearch
set casesensitive $default_casesensitive
}
focus -force $w.ent
@@ -106,6 +113,9 @@ method _do_search {start {mlenvar {}} {dir {}} {endbound {}}} {
upvar $mlenvar mlen
lappend cmd -count mlen
}
+ if {$regexpsearch} {
+ lappend cmd -regexp
+ }
if {!$casesensitive} {
lappend cmd -nocase
}
--
1.7.6.789.gb4599
^ permalink raw reply related
* [PATCH 4/4] git-gui: add search history to searchbar
From: Bert Wesarg @ 2011-10-14 8:14 UTC (permalink / raw)
To: Pat Thoyts; +Cc: git, Bert Wesarg
In-Reply-To: <94b050c4cf7ae8df8d79112e13613244ebff4037.1318579823.git.bert.wesarg@googlemail.com>
Use the up/down keys to browse the history.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
lib/search.tcl | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/lib/search.tcl b/lib/search.tcl
index 9268ec3..15f99d8 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -13,6 +13,9 @@ field casesensitive
field default_casesensitive
field searchdirn -forwards
+field history
+field history_index
+
field smarktop
field smarkbot
@@ -28,6 +31,8 @@ constructor new {i_w i_text args} {
set default_casesensitive 1
}
+ set history [list]
+
${NS}::frame $w
${NS}::label $w.l -text [mc Find:]
entry $w.ent -textvariable ${__this}::searchstring -background lightgreen
@@ -50,6 +55,8 @@ constructor new {i_w i_text args} {
trace add variable searchstring write [cb _incrsearch_cb]
bind $w.ent <Return> [cb find_next]
bind $w.ent <Shift-Return> [cb find_prev]
+ bind $w.ent <Key-Up> [cb _prev_search]
+ bind $w.ent <Key-Down> [cb _next_search]
bind $w <Destroy> [list delete_this $this]
return $this
@@ -58,8 +65,10 @@ constructor new {i_w i_text args} {
method show {} {
if {![visible $this]} {
grid $w
+ $w.ent delete 0 end
set regexpsearch $default_regexpsearch
set casesensitive $default_casesensitive
+ set history_index [llength $history]
}
focus -force $w.ent
}
@@ -68,6 +77,7 @@ method hide {} {
if {[visible $this]} {
focus $ctext
grid remove $w
+ _save_search $this
}
}
@@ -160,6 +170,55 @@ method _incrsearch {} {
}
}
+method _save_search {} {
+ if {$searchstring eq {}} {
+ return
+ }
+ if {[llength $history] > 0} {
+ foreach {s_regexp s_case s_expr} [lindex $history end] break
+ } else {
+ set s_regexp $regexpsearch
+ set s_case $casesensitive
+ set s_expr ""
+ }
+ if {$searchstring eq $s_expr} {
+ # update modes
+ set history [lreplace $history end end \
+ [list $regexpsearch $casesensitive $searchstring]]
+ } else {
+ lappend history [list $regexpsearch $casesensitive $searchstring]
+ }
+ set history_index [llength $history]
+}
+
+method _prev_search {} {
+ if {$history_index > 0} {
+ incr history_index -1
+ foreach {s_regexp s_case s_expr} [lindex $history $history_index] break
+ $w.ent delete 0 end
+ $w.ent insert 0 $s_expr
+ set regexpsearch $s_regexp
+ set casesensitive $s_case
+ }
+}
+
+method _next_search {} {
+ if {$history_index < [llength $history]} {
+ incr history_index
+ }
+ if {$history_index < [llength $history]} {
+ foreach {s_regexp s_case s_expr} [lindex $history $history_index] break
+ } else {
+ set s_regexp $default_regexpsearch
+ set s_case $default_casesensitive
+ set s_expr ""
+ }
+ $w.ent delete 0 end
+ $w.ent insert 0 $s_expr
+ set regexpsearch $s_regexp
+ set casesensitive $s_case
+}
+
method find_prev {} {
find_next $this -backwards
}
@@ -170,6 +229,7 @@ method find_next {{dir -forwards}} {
set searchdirn $dir
$ctext mark unset anchor
if {$searchstring ne {}} {
+ _save_search $this
set start [_get_new_anchor $this]
if {$dir eq "-forwards"} {
set start "$start + 1c"
--
1.7.6.789.gb4599
^ permalink raw reply related
* [PATCH] git-gui: fix multi selected file operation
From: Bert Wesarg @ 2011-10-14 8:19 UTC (permalink / raw)
To: Pat Thoyts; +Cc: git, Bert Wesarg
The current path for what we see the diff is not in the list of selected
paths. But when we add single paths (with Ctrl) to the set the current path
would not be used when the action is performed.
Fix this by explicitly putting the path into the list before we start
showing the diff.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
---
git-gui.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/git-gui.sh b/git-gui.sh
index f897160..e5dd8bc 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -2474,6 +2474,7 @@ proc toggle_or_diff {w x y} {
[concat $after [list ui_ready]]
}
} else {
+ set selected_paths($path) 1
show_diff $path $w $lno
}
}
--
1.7.6.789.gb4599
^ permalink raw reply related
* url.<base>.insteadOf with empty value
From: Kirill Likhodedov @ 2011-10-14 9:03 UTC (permalink / raw)
To: git
If I don't specify any value for url.<base>.insteadOf or url.<base>.pushInsteadOf, Git substitutes all urls for remotes defined in .git/config
Probably that's because any url starts with empty string and thus has to be substituted.
But it might be a bit confusing, because on the other hand if no value is given to the property insteadOf, user may expect this property to be ignored.
Please check if current Git behavior is correct.
If it is not a bug, I'd suggest to add a note to man git-config about this.
# git version
git version 1.7.6
# cat .git/config
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = github.com/klikh/Test.git
pushUrl = jetbrains.com/klikh/Test.git
[url "http://"]
insteadOf=
# git remote -v
origin http://github.com/klikh/Test.git (fetch)
origin http://jetbrains.com/klikh/Test.git (push)
----------------------------------
Kirill Likhodedov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
^ permalink raw reply
* Re: [BUG] git checkout <branch> allowed with uncommitted changes
From: Holger Hellmuth @ 2011-10-14 9:27 UTC (permalink / raw)
To: Jeff King; +Cc: arQon, git
In-Reply-To: <20111014013830.GA7258@sigill.intra.peff.net>
On 14.10.2011 03:38, Jeff King wrote:
> On Thu, Oct 13, 2011 at 06:56:14PM +0000, arQon wrote:
>
>> I'll give a shot, though I don't know how good it'll be. Off the top of my
>> head, I don't see any good way to explain the inconsistency with LOCAL CHANGES
>> sometimes preventing switches and sometimes not, based on what is to the user
>> an arbitrary set of rules that has nothing to do with the *current state* of
>> the worktree, but rather the state of those files in prior commits.
>
> The rules are fairly straightforward.
They are. But what arQon is getting at is that the normal switchability
depends on something that is often a game of chance: Did I change a file
that is different between the two branches? That is only known by the
user for branches not far removed.
Now the obvious answer is: It doesn't matter because git tells you. At
the right time to act upon it. But git says "M file" instead of what
'git status' would say: "# modified: file". Is there a reason for
that? On one hand it should be familiar to svn users, on the other hand
it is an inconsistency. And personally I always hated those cryptic
status flags of svn
Another good point arQon made is that the case that you switched with
forgotten local changes is more common than the case that you switched
because you made changes in the wrong branch. If that were the case the
warning that you have local changes should be more visible than that
small "M file", at best something that looks similar to 'git status' output.
Now what really is more common depends on the individual. If you are a
beginner or a semi-frequent user, then forgetting local changes is
probably far more common, wheras most people on this mailing list would
say its the other way round. It much depends on your commit frequency
because the more often you commit, the less likely is that you would
forget local changes.
^ permalink raw reply
* Re: [PATCH] git-svn: Allow certain refs to be ignored
From: Piotr Krukowiecki @ 2011-10-14 9:24 UTC (permalink / raw)
To: Eric Wong; +Cc: Michael Olson, git, Junio C Hamano
In-Reply-To: <20111010225838.GB3828@dcvr.yhbt.net>
On Tue, Oct 11, 2011 at 12:58 AM, Eric Wong <normalperson@yhbt.net> wrote:
> Junio C Hamano <gitster@pobox.com> wrote:
>> Asking Eric to comment when he has time to do so.
>>
>> I find these pattern matches that are not anchored on either side
>> somewhat disturbing (e.g. --ignore-refs=master would ignore master2)
>> but ignore-paths codepath seems to follow the same pattern, so perhaps it
>> is in line with what git-svn users want. I dunno.
>
> As stated last year, I remember wanting globs instead of regexps, but
> we already made the regexp mistake with ignore-paths, too :(
>
> I don't think it's horrible with regexps, and if git-svn users find it
> useful, it's fine by me.
In my case globs would be too limited. I'm using negative look-ahead
assertions to match only branches/tags for projects that are
interesting to me. With globs it's not possible AFAIK (I would have to
specify all ignored patterns by hand which would work only for known
patterns):
ignore-paths = ^path/branches/(?!proj1|proj2)
>> Michael Olson <mwolson@gnu.org> writes:
>> > Re-sent by request of Piotr Krukowiecki. This is against v1.7.4.1,
>> > and I've been using it stably for a while.
>
> Michael: can you please rebase against latest and resend? Thanks.
I've got following error while using the patch. I don't know it also
happens without the patch...
M ...
r216099 = 4d16d4890915f4c02ba541956957a4e4b4bed400
(refs/remotes/proj2/proj2-branch9)
Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
Counting objects: 10284, done.
Compressing objects: 100% (7695/7695), done.
Writing objects: 100% (10284/10284), done.
Total 10284 (delta 5077), reused 0 (delta 0)
fatal: refs/remotes/proj1/trunk: not a valid SHA1
update-ref refs/heads/master refs/remotes/proj1/trunk: command
returned error: 128
$ git log -1
fatal: bad default revision 'HEAD'
$ git log -1 trunk
fatal: ambiguous argument 'trunk': unknown revision or path not in the
working tree.
Use '--' to separate paths from revisions
$ ls .git/refs/remotes/
proj2
The commands I've used:
git svn init --prefix=proj2/ -Rproj2 -s
--ignore-paths='^proj2/branches/(?!proj1|proj2)|^proj2/tags/(?!proj1|proj2)|^proj2/(?!trunk|branches|tags)'
--ignore-refs='^refs/remotes/proj2/(?!proj1|proj2|trunk|tag)|^refs/remotes/proj2/tags/(?!proj1|proj2)'
http://url/svn/repos/proj2
git svn init --prefix=proj1/ -Rproj1 -s
--ignore-paths='^proj1/branches/(?!proj1|proj2)|^proj1/tags/(?!proj1|proj2)|^proj2/(?!trunk|branches|tags)'
--ignore-refs='^refs/remotes/proj1/(?!proj1|proj2|trunk|tag)|^refs/remotes/proj1/tags/(?!proj1|proj2)'
http://url/svn/repos/proj1
git svn fetch proj2 && git svn fetch proj1
The error happened while fetching proj2. I wonder why it tried to set
master to proj1?
Is my command ok? I want to have both proj1 and proj2 under one git repository.
--
Piotr Krukowiecki
^ permalink raw reply
* Re: defined behaviour for multiple urls for a remote
From: Kirill Likhodedov @ 2011-10-14 9:36 UTC (permalink / raw)
To: git
In-Reply-To: <CAMK1S_jZJuqC6_-eVT7LJFh+DEphbsypS6f4nRb6Qc4-xBa_wQ@mail.gmail.com>
Sitaram Chamarty <sitaramc <at> gmail.com> writes:
> What's the defined behaviour if I do this:
>
> [remote "both"]
> url = https://code.google.com/p/gitolite/
> url = git <at> github.com:sitaramc/gitolite.git
>
> I know what I'm seeing (a fetch only goes to the first URL, and does a
> HEAD->FETCH_HEAD because I didn't provide a refspec line, while a push
> seems to push all to both), but I was curious what the official
> position is, because I couldn't find it in the docs.
Please see the message from Linus about that: http://marc.info/?l=git&m=116231242118202&w=2
You also may check how Git understands your remotes by running
git remote -v
It will show, where it is going to fetch from and push to.
I agree though, that documentation should be updated.
^ permalink raw reply
* Re: [BUG] git checkout <branch> allowed with uncommitted changes
From: Victor Engmark @ 2011-10-14 9:54 UTC (permalink / raw)
To: Holger Hellmuth; +Cc: Jeff King, arQon, git
In-Reply-To: <4E980093.6040704@ira.uka.de>
On Fri, Oct 14, 2011 at 11:27:47AM +0200, Holger Hellmuth wrote:
> On 14.10.2011 03:38, Jeff King wrote:
> >On Thu, Oct 13, 2011 at 06:56:14PM +0000, arQon wrote:
> >
> >>I'll give a shot, though I don't know how good it'll be. Off the top of my
> >>head, I don't see any good way to explain the inconsistency with LOCAL CHANGES
> >>sometimes preventing switches and sometimes not, based on what is to the user
> >>an arbitrary set of rules that has nothing to do with the *current state* of
> >>the worktree, but rather the state of those files in prior commits.
> >
> >The rules are fairly straightforward.
>
> They are. But what arQon is getting at is that the normal
> switchability depends on something that is often a game of chance:
> Did I change a file that is different between the two branches? That
> is only known by the user for branches not far removed.
>
> Now the obvious answer is: It doesn't matter because git tells you.
> At the right time to act upon it. But git says "M file" instead of
> what 'git status' would say: "# modified: file". Is there a
> reason for that? On one hand it should be familiar to svn users, on
> the other hand it is an inconsistency. And personally I always hated
> those cryptic status flags of svn
>
> Another good point arQon made is that the case that you switched
> with forgotten local changes is more common than the case that you
> switched because you made changes in the wrong branch. If that were
> the case the warning that you have local changes should be more
> visible than that small "M file", at best something that looks
> similar to 'git status' output.
Very good point. How about by default just running `git status` after a
successful checkout, and only printing the result if there are any
changes? That way:
1) If no changes are pending, nothing is displayed.
2) The user sees a *familiar* style output if anything changed.
3) If there's an alias for "status", it would be used.
Example:
$ mkdir /tmp/test
$ cd /tmp/test
$ git init
Initialized empty Git repository in /tmp/test/.git/
$ echo foo > foo
$ echo bar > bar
$ git add foo bar
$ git commit -m "Initial commit"
[master (root-commit) 55246c6] Initial commit
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 bar
create mode 100644 foo
$ echo foobar > bar
$ git branch --track test
Branch test set up to track local branch master.
$ git checkout test
M bar
Switched to branch 'test'
After `git checkout test`, we should instead see:
# On branch test
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: bar
#
no changes added to commit (use "git add" and/or "git commit -a")
2c,
V
--
terreActive AG
Kasinostrasse 30
CH-5001 Aarau
Tel: +41 62 834 00 55
Fax: +41 62 823 93 56
www.terreactive.ch
Wir sichern Ihren Erfolg - seit 15 Jahren
^ permalink raw reply
* Git shouldn't allow to push a new branch called HEAD
From: Daniele Segato @ 2011-10-14 11:31 UTC (permalink / raw)
To: Git Mailing List
Hi all,
following from a discussion in IRC freenode #git between me, sitaram an
shruggar
step to reproduce:
$ mkdir /tmp/gitbug
$ cd /tmp/gitbug/
$ # create a fake remote repo
$ git init --bare remote.git
$ # clone it with the user that will generate the bug
$ git clone remote.git buggenerator
$ cd buggenerator/
$ touch whatever
$ git add .
$ git commit -m "first commit"
$ git push origin master
$ # now clone the same repo the other guy is the "victim" of this issue
$ cd ..
$ git clone remote.git victim
$ # time to create the remote HEAD branch
$ cd buggenerator/
$ git push origin HEAD:HEAD
$ # the remote refs has been created!
$ git ls-remote
$ # another commit
$ echo 'any change' >> whatever
$ git commit -a -m "some change"
$ git push origin master
$ # the refs/heads/HEAD is still where it was
$ git ls-remote
$ # now from the victim perspective
$ cd ../victim/
$ # every time executing a fetch he will get a force update
$ # or maybe even an error, seen it my real repo, don't know how
$ # to reproduce
$ git fetch
$ git fetch
$ git ls-remote
$ git fetch
$ git ls-remote
$ git branch -a
full console log:
mastro@mastroc3 ~ $ mkdir /tmp/gitbug
mastro@mastroc3 ~ $ cd /tmp/gitbug/
mastro@mastroc3 /tmp/gitbug $ git init --bare remote.git
Initialized empty Git repository in /tmp/gitbug/remote.git/
mastro@mastroc3 /tmp/gitbug $ git clone remote.git buggenerator
Cloning into buggenerator...
done.
warning: You appear to have cloned an empty repository.
mastro@mastroc3 /tmp/gitbug $ cd buggenerator/
mastro@mastroc3 /tmp/gitbug/buggenerator (master #) $ touch whatever
mastro@mastroc3 /tmp/gitbug/buggenerator (master #) $ git add .
mastro@mastroc3 /tmp/gitbug/buggenerator (master #) $ git commit -m
"first commit"
[master (root-commit) 11d0a12] first commit
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 whatever
mastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git push origin
master
Counting objects: 3, done.
Writing objects: 100% (3/3), 213 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /tmp/gitbug/remote.git
* [new branch] master -> master
mastro@mastroc3 /tmp/gitbug/buggenerator (master) $ cd ..
mastro@mastroc3 /tmp/gitbug $ git clone remote.git victim
Cloning into victim...
done.
mastro@mastroc3 /tmp/gitbug $ cd buggenerator/
# now creating the HEAD remote branch
mastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git push origin
HEAD:HEAD
Total 0 (delta 0), reused 0 (delta 0)
To /tmp/gitbug/remote.git
* [new branch] HEAD -> HEAD
mastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git ls-remote
From /tmp/gitbug/remote.git
11d0a122125e50e78c7aa4aa81a3d6090dba648e HEAD
11d0a122125e50e78c7aa4aa81a3d6090dba648e refs/heads/HEAD <-----
shouldn't be there!
11d0a122125e50e78c7aa4aa81a3d6090dba648e refs/heads/master
mastro@mastroc3 /tmp/gitbug/buggenerator (master) $ echo 'any change' >>
whatever
mastro@mastroc3 /tmp/gitbug/buggenerator (master *) $ git commit -a -m
"some change"
[master 77852ef] some change
1 files changed, 1 insertions(+), 0 deletions(-)
mastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git push origin
master
Counting objects: 5, done.
Writing objects: 100% (3/3), 253 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /tmp/gitbug/remote.git
11d0a12..77852ef master -> master
mastro@mastroc3 /tmp/gitbug/buggenerator (master) $ git ls-remote
From /tmp/gitbug/remote.git
77852effa972187d60d4c75145198991f1c0f868 HEAD
11d0a122125e50e78c7aa4aa81a3d6090dba648e refs/heads/HEAD
77852effa972187d60d4c75145198991f1c0f868 refs/heads/master
mastro@mastroc3 /tmp/gitbug/buggenerator (master) $ cd ../victim/
mastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch
remote: Counting objects: 5, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From /tmp/gitbug/remote
11d0a12..77852ef master -> origin/master
mastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch
From /tmp/gitbug/remote
+ 77852ef...11d0a12 HEAD -> origin/HEAD (forced update)
mastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch
From /tmp/gitbug/remote
11d0a12..77852ef master -> origin/master
mastro@mastroc3 /tmp/gitbug/victim (master) $ git ls-remote
From /tmp/gitbug/remote.git
77852effa972187d60d4c75145198991f1c0f868 HEAD
11d0a122125e50e78c7aa4aa81a3d6090dba648e refs/heads/HEAD
77852effa972187d60d4c75145198991f1c0f868 refs/heads/master
mastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch
From /tmp/gitbug/remote
+ 77852ef...11d0a12 HEAD -> origin/HEAD (forced update)
mastro@mastroc3 /tmp/gitbug/victim (master) $ git ls-remote
From /tmp/gitbug/remote.git
77852effa972187d60d4c75145198991f1c0f868 HEAD
11d0a122125e50e78c7aa4aa81a3d6090dba648e refs/heads/HEAD
77852effa972187d60d4c75145198991f1c0f868 refs/heads/master
mastro@mastroc3 /tmp/gitbug/victim (master) $ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
this can be fixed with:
git push --delete origin HEAD
(or git push origin :HEAD)
then
git remote prune origin
But I think that git shouldn't allow the remote HEAD reference to be
created in the first place
regards,
Daniele
^ permalink raw reply
* Re: Git shouldn't allow to push a new branch called HEAD
From: Daniele Segato @ 2011-10-14 11:35 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <1318591877.2938.20.camel@mastroc3.mobc3.local>
On Fri, 2011-10-14 at 13:31 +0200, Daniele Segato wrote:
> Hi all,
>
>
> following from a discussion in IRC freenode #git between me, sitaram an
> shruggar
>
>
> step to reproduce:
>
> $ mkdir /tmp/gitbug
> $ cd /tmp/gitbug/
>
> $ # create a fake remote repo
> $ git init --bare remote.git
>
> $ # clone it with the user that will generate the bug
> $ git clone remote.git buggenerator
> $ cd buggenerator/
> $ touch whatever
> $ git add .
> $ git commit -m "first commit"
> $ git push origin master
>
> $ # now clone the same repo the other guy is the "victim" of this issue
> $ cd ..
> $ git clone remote.git victim
>
> $ # time to create the remote HEAD branch
> $ cd buggenerator/
> $ git push origin HEAD:HEAD
>
> $ # the remote refs has been created!
> $ git ls-remote
>
> $ # another commit
> $ echo 'any change' >> whatever
> $ git commit -a -m "some change"
> $ git push origin master
>
> $ # the refs/heads/HEAD is still where it was
> $ git ls-remote
>
> $ # now from the victim perspective
> $ cd ../victim/
>
> $ # every time executing a fetch he will get a force update
> $ # or maybe even an error, seen it my real repo, don't know how
> $ # to reproduce
> $ git fetch
> $ git fetch
> $ git ls-remote
> $ git fetch
> $ git ls-remote
> $ git branch -a
This should also help understanding what happen in the "victim" local
repo at every fetch:
mastro@mastroc3 /tmp/gitbug/victim (master) $ git br -av
* master 11d0a12 [behind 1] first commit
remotes/origin/HEAD -> origin/master
remotes/origin/master 77852ef some change
mastro@mastroc3 /tmp/gitbug/victim (master) $ git fetch
From /tmp/gitbug/remote
+ 77852ef...11d0a12 HEAD -> origin/HEAD (forced update)
mastro@mastroc3 /tmp/gitbug/victim (master) $ git br -av
* master 11d0a12 first commit
remotes/origin/HEAD -> origin/master
remotes/origin/master 11d0a12 first commit
regards,
Daniele
^ permalink raw reply
* [PATCH] t7800: avoid arithmetic expansion notation
From: Michael J Gruber @ 2011-10-14 12:15 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Sitaram Chamarty
ba959de (git-difftool: allow skipping file by typing 'n' at prompt, 2011-10-08)
introduced shell code like
$((foo; bar) | baz)
which some shells (e.g. bash, dash) interpret as an unfinished arithmetic
evaluation $(( expr )).
Write this as
$({foo; bar; } | baz)
which is unambiguous and also avoids an unnecessary subshell.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
t/t7800-difftool.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
index 7fc2b3a..76a8b70 100755
--- a/t/t7800-difftool.sh
+++ b/t/t7800-difftool.sh
@@ -289,7 +289,7 @@ test_expect_success PERL 'setup with 2 files different' '
'
test_expect_success PERL 'say no to the first file' '
- diff=$((echo n; echo) | git difftool -x cat branch) &&
+ diff=$({ echo n; echo; } | git difftool -x cat branch) &&
echo "$diff" | stdin_contains m2 &&
echo "$diff" | stdin_contains br2 &&
@@ -298,7 +298,7 @@ test_expect_success PERL 'say no to the first file' '
'
test_expect_success PERL 'say no to the second file' '
- diff=$((echo; echo n) | git difftool -x cat branch) &&
+ diff=$({ echo; echo n; } | git difftool -x cat branch) &&
echo "$diff" | stdin_contains master &&
echo "$diff" | stdin_contains branch &&
--
1.7.7.338.g0156b
^ permalink raw reply related
* Re: [PATCH 2/9] completion: optimize refs completion
From: SZEDER Gábor @ 2011-10-14 12:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Shawn O. Pearce, Jonathan Nieder
In-Reply-To: <1318085683-29830-3-git-send-email-szeder@ira.uka.de>
On Sat, Oct 08, 2011 at 04:54:36PM +0200, SZEDER Gábor wrote:
> So, add a specialized variant of __gitcomp() that only deals with
> possible completion words separated by a newline
> @@ -2635,7 +2659,7 @@ _git ()
> "
> ;;
> *) __git_compute_porcelain_commands
> - __gitcomp "$__git_porcelain_commands $(__git_aliases)" ;;
> + __gitcomp_nl "$__git_porcelain_commands $(__git_aliases)" ;;
> esac
> return
> fi
Oops, this last hunk is wrong.
I made the thinko that $__git_porcelain_commands is NL-separated and
the output of __git_aliases() is NL-separated, so we can pass the two
together to the new __gitcomp_nl() function. But of course not,
because the SP between the two joins the last command and the first
alias.
I will resend in the evening with this hunk removed and the commit
message updated.
Gábor
^ permalink raw reply
* [BUG] send-email: alias expansion broken
From: Michael J Gruber @ 2011-10-14 12:29 UTC (permalink / raw)
To: Git Mailing List, Cord Seele
cec5dae (use new Git::config_path() for aliasesfile, 2011-09-30)
broke the expansion of aliases for me:
./git-send-email --cc=junio --dry-run
0001-t7800-avoid-arithmetic-expansion-notation.patch
0001-t7800-avoid-arithmetic-expansion-notation.patch
Who should the emails appear to be from? [Michael J Gruber
<git@drmicha.warpmail.net>]
Emails will be sent from: Michael J Gruber <git@drmicha.warpmail.net>
Dry-OK. Log says:
Sendmail: /home/mjg/bin/msmtp-fastmail-git -i git@vger.kernel.org junio
git@drmicha.warpmail.net
From: Michael J Gruber <git@drmicha.warpmail.net>
To: git@vger.kernel.org
Cc: junio
...
Happens with both "--cc junio" and "--cc=junio".
Reverting cec5dae brings my aliases back. Relevant config:
git config --get-regexp sendemail.alias\*
sendemail.aliasesfile /home/mjg/git/gitauthors
sendemail.aliasfiletype mutt
Can I please have alias expansion back?
No, I don't know what cec5dae tries to achieve, and I lack the perl fu
to fix it.
Michael
^ permalink raw reply
* Re: [RFC/PATCH 1/2] bundle: allowing to read from an unseekable fd
From: Phil Hord @ 2011-10-14 12:31 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O. Pearce, git
In-Reply-To: <7vpqi034l0.fsf@alter.siamese.dyndns.org>
On Thu, Oct 13, 2011 at 6:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
> The current code opens a given file with fopen(), reads it until the end
> of the header and runs ftell(), and reopens the same file with open() and
> seeks to skip the header. This structure makes it hard to retarget the
> code to read from input that is not seekable, such as a network socket.
>
> This patch by itself does not reach that goal yet, but I think it is a
> right step in that direction.
>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>
> * It would be nice if we can avoid byte-by-byte reading from the file
> descriptor by over-reading into the strbuf and pass the remainder to
> the caller of read_bundle_header(), but I suspect that it would require
> us to carry the "here is the remainder from the previous read" buffer
> around throughout the transport layer. Parsing of the header wouldn't
> be performance critical compared to the computation cost of actually
> reading the rest of the bundle, hopefully, so...
>
> bundle.c | 99 ++++++++++++++++++++++++++++++++++++++++----------------------
> 1 files changed, 64 insertions(+), 35 deletions(-)
>
> diff --git a/bundle.c b/bundle.c
> index f48fd7d..3aa715c 100644
> --- a/bundle.c
> +++ b/bundle.c
> @@ -23,49 +23,78 @@ static void add_to_ref_list(const unsigned char *sha1, const char *name,
> list->nr++;
> }
>
> -/* returns an fd */
> +/* Eventually this should go to strbuf.[ch] */
> +static int strbuf_readline_fd(struct strbuf *sb, int fd)
A size limiter would be useful here. Since it's readline, maybe the
limit can even be hardcoded.
Without a limit, calling this with something stupid like "/dev/zero"
will consume all memory and never return.
Phil
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox