* [PATCH][v2] http authentication via prompts (with correct line lengths)
From: Mike Gaffney @ 2009-03-10 0:08 UTC (permalink / raw)
To: git
Currently git over http only works with a .netrc file which required
that you store your password on the file system in plaintext. This
commit adds to configuration options for http for a username and an
optional password. If a http.username is set, then the .netrc file
is ignored and the username is used instead. If a http.password is
set, then that is used as well, otherwise the user is prompted for
their password.
With the old .netrc working, this patch provides backwards
compatibility while adding a more secure option for users whose
http password may be sensitive (such as if its a domain controller
password) and do not wish to have it on the filesystem.
Signed-off-by: Mike Gaffney <mike@uberu.com>
---
Documentation/config.txt | 7 +++
Documentation/howto/setup-git-server-over-http.txt | 38 ++++++++++++++++--
http.c | 41 ++++++++++++++++++-
http.h | 2 +
4 files changed, 81 insertions(+), 7 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index f5152c5..821bf48 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -920,6 +920,13 @@ help.autocorrect::
value is 0 - the command will be just shown but not executed.
This is the default.
+http.username, http.password:
+ The username and password for http authentication. http.username is
+ required, http.password is optional. If supplied, the .netrc file will
+ be ignored. If a password is not supplied, git will prompt for it.
+ Be careful when configuring a password as it will be stored in plain text
+ on the filesystem.
+
http.proxy::
Override the HTTP proxy, normally configured using the 'http_proxy'
environment variable (see linkgit:curl[1]). This can be overridden
diff --git a/Documentation/howto/setup-git-server-over-http.txt b/Documentation/howto/setup-git-server-over-http.txt
index 622ee5c..462a9d4 100644
--- a/Documentation/howto/setup-git-server-over-http.txt
+++ b/Documentation/howto/setup-git-server-over-http.txt
@@ -189,8 +189,19 @@ Make sure that you have HTTP support, i.e. your git was built with
libcurl (version more recent than 7.10). The command 'git http-push' with
no argument should display a usage message.
-Then, add the following to your $HOME/.netrc (you can do without, but will be
-asked to input your password a _lot_ of times):
+There are 2 ways to authenticate with git http, netrc and via the git config.
+The netrc option requires that you put the username and password for the connection
+in $HOME/.netrc. The configuration method allows you to specify a username and
+optionally a password. If the password is not supplied then git will prompt you
+for the password. The downside to the netrc method is that you must have your
+username and password in plaintext on the filesystem, albeit in a protected file.
+If the username/password combo is a sensitive one, you may wish to use the
+git config method. The downside of the config method is that you will be prompted
+for your password every time you push or pull to the remote repository.
+
+Using netrc:
+
+Using your favourite ext editor, add the following to your $HOME/.netrc:
machine <servername>
login <username>
@@ -204,7 +215,7 @@ instead of the server name.
To check whether all is OK, do:
- curl --netrc --location -v http://<username>@<servername>/my-new-repo.git/HEAD
+ curl --netrc --location -v http://<servername>/my-new-repo.git/HEAD
...this should give something like 'ref: refs/heads/master', which is
the content of the file HEAD on the server.
@@ -213,12 +224,31 @@ Now, add the remote in your existing repository which contains the project
you want to export:
$ git-config remote.upload.url \
- http://<username>@<servername>/my-new-repo.git/
+ http://<servername>/my-new-repo.git/
It is important to put the last '/'; Without it, the server will send
a redirect which git-http-push does not (yet) understand, and git-http-push
will repeat the request infinitely.
+Using git config:
+
+curl --user <username>:<password> --location -v http://<servername>/my-new-repo.git/HEAD
+
+...this should give something like 'ref: refs/heads/master', which is
+the content of the file HEAD on the server.
+
+Now, add the remote in your existing repository which contains the project
+you want to export:
+
+ $ git-config remote.upload.url \
+ http://<servername>/my-new-repo.git/
+
+Also, add in your username with:
+ $ git-config http.username <username>
+
+And optionally your password (you will be prompted for it if you do not):
+ $ git-config http.password <password>
+
Step 4: make the initial push
-----------------------------
diff --git a/http.c b/http.c
index ee58799..348b9fb 100644
--- a/http.c
+++ b/http.c
@@ -26,6 +26,9 @@ static long curl_low_speed_time = -1;
static int curl_ftp_no_epsv = 0;
static const char *curl_http_proxy = NULL;
+static const char *curl_http_username = NULL;
+static const char *curl_http_password = NULL;
+
static struct curl_slist *pragma_header;
static struct active_request_slot *active_queue_head = NULL;
@@ -153,11 +156,45 @@ static int http_options(const char *var, const char *value, void *cb)
return git_config_string(&curl_http_proxy, var, value);
return 0;
}
+ if (!strcmp("http.username", var)) {
+ if (curl_http_username == NULL)
+ {
+ return git_config_string(&curl_http_username, var, value);
+ }
+ return 0;
+ }
+ if (!strcmp("http.password", var)) {
+ if (curl_http_password == NULL)
+ {
+ return git_config_string(&curl_http_password, var, value);
+ }
+ return 0;
+ }
/* Fall back on the default ones */
return git_default_config(var, value, cb);
}
+static void init_curl_http_auth(CURL* result){
+#if LIBCURL_VERSION_NUM >= 0x070907
+ struct strbuf userpass;
+ strbuf_init(&userpass, 0);
+ if (curl_http_username != NULL) {
+ strbuf_addstr(&userpass, curl_http_username);
+ strbuf_addstr(&userpass, ":");
+ if (curl_http_password != NULL) {
+ strbuf_addstr(&userpass, curl_http_password);
+ } else {
+ strbuf_addstr(&userpass, getpass("Password: "));
+ }
+ curl_easy_setopt(result, CURLOPT_USERPWD, userpass.buf);
+ curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_IGNORED);
+ } else {
+ curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
+ }
+#endif
+}
+
static CURL* get_curl_handle(void)
{
CURL* result = curl_easy_init();
@@ -172,9 +209,7 @@ static CURL* get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
}
-#if LIBCURL_VERSION_NUM >= 0x070907
- curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
-#endif
+ init_curl_http_auth(result);
if (ssl_cert != NULL)
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
diff --git a/http.h b/http.h
index 905b462..71320d1 100644
--- a/http.h
+++ b/http.h
@@ -5,6 +5,8 @@
#include <curl/curl.h>
#include <curl/easy.h>
+#include <termios.h>
+#include <stdio.h>
#include "strbuf.h"
#include "remote.h"
--
1.6.1.2
^ permalink raw reply related
* Re: [RFC/PATCH] git push usability improvements and default change
From: Junio C Hamano @ 2009-03-10 0:12 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Finn Arne Gangstad, git
In-Reply-To: <alpine.DEB.1.00.0903100033400.6358@intel-tinevez-2-302>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> git push default change:
>>
>> git push will by default push "nothing" instead of "matching".
>
> Hasn't this been shot down already? I do not want that change. I think
> it is harmful.
>
> At least without a proper way to prepare existing users for the end of the
> world.
I haven't actually read the patch, but my reading of the cover lette ris
that the four-patch sequence 4-to-7 is (meant to be, at least) structured
that way.
^ permalink raw reply
* Google Summer of Code 2009 - Organization Application
From: Shawn O. Pearce @ 2009-03-10 0:16 UTC (permalink / raw)
To: git
Folks, its that time of year again. We need to apply to be a
mentoring organization for Google Summer of Code 2009.
Deadline is this Friday around noon PST.
I have updated the application document on the wiki with the
current questions and more up-to-date answers:
http://git.or.cz/gitwiki/SoC2009Application
Please make any comments in the next day or so, so that we can
address them and have time to upload the completed application
before their cut-off deadline.
--
Shawn.
^ permalink raw reply
* Re: [RFC/PATCH] git push usability improvements and default change
From: Junio C Hamano @ 2009-03-10 0:19 UTC (permalink / raw)
To: Finn Arne Gangstad; +Cc: git
In-Reply-To: <7vfxhmdyvn.fsf@gitster.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> - Even if the answer to the above question is "no", are there other
> commands that we currently do not allow a quick shorthand to mean
> "the default thing", but would benefit from having one? If so, how
> good does it look to use '-' as such a short-hand?
I need " for these other commands" before the question mark at the end of
this sentence.
> In other words, is it safe to establish a precedent to use '-' to
> denote "the default thing"? Would we later regret, saying that
> "'git-frotz command would benefit from a short-hand notation for 'the
> default thing', but - is already taken -- it means send the output to
> the stdout"?
I need ", or something like that" before the question mark at the end of
this sentence.
> - Do we use a short-hand '-' to mean something entirely different in
> the UI, making this new use of '-' to mean the default confusing?
>
> I think '-' for checkout means "the previous one", which already
> answers this question somewhat.
I am wondering if we can handle this by DWIMming the command line
arguments better. For example, in all of these:
$ git push HEAD
$ git push :
$ git push master
when "HEAD", ":", or "master" can only be refspec, we know that the user
said "I do not bother saying which repository to --- you know what I
mean." It would be natural to DWIM it to "the default remote" without
even having to use your '-' notation.
^ permalink raw reply
* Re: [PATCH 4/7] git push: Display warning on unconfigured default push
From: Jay Soffian @ 2009-03-10 0:25 UTC (permalink / raw)
To: Finn Arne Gangstad; +Cc: git
In-Reply-To: <1236638151-6465-5-git-send-email-finnag@pvv.org>
On Mon, Mar 9, 2009 at 6:35 PM, Finn Arne Gangstad <finnag@pvv.org> wrote:
> + " 'nothing' : Do not push anythig",
s/anythig/anything/
j.
^ permalink raw reply
* Re: [PATCH][v2] http authentication via prompts (with correct line lengths)
From: Junio C Hamano @ 2009-03-10 0:37 UTC (permalink / raw)
To: Mike Gaffney; +Cc: git
In-Reply-To: <49B5AF67.6050508@gmail.com>
It appears that none of the issues I raised in my response to your earlier
round was addressed in this patch, except for the line rewrapping of the
proposed commit log message.
^ permalink raw reply
* [PATCH] winansi: support ESC [ K (erase in line)
From: Johannes Schindelin @ 2009-03-10 0:41 UTC (permalink / raw)
To: git, gitster; +Cc: Peter Harris, Johannes Sixt, Sebastian Schuberth
In-Reply-To: <cover.1236639280u.git.johannes.schindelin@gmx.de>
To make use of it during a fetch, write() needs to be overridden, too.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
This fixes the last bit of msysGit issue 124 for me:
http://code.google.com/p/msysgit/issues/detail?id=124
which annoyed me one time to many today.
I had an earlier version which was smaller, but pretty hacky, in
that it checked if fprintf is #define'd in xwrite(), and had
special handling for that case.
This patch is only slightly hacky, in that it assumes that you do
not try to output something that ends in an incomplete ESC [
sequence.
compat/mingw.h | 2 ++
compat/winansi.c | 51 +++++++++++++++++++++++++++++++++++++++------------
2 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/compat/mingw.h b/compat/mingw.h
index b82903c..9aac4e1 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -192,9 +192,11 @@ sig_handler_t mingw_signal(int sig, sig_handler_t handler);
int winansi_fputs(const char *str, FILE *stream);
int winansi_printf(const char *format, ...) __attribute__((format (printf, 1, 2)));
int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3)));
+int winansi_write(int fd, const void *buf, size_t len);
#define fputs winansi_fputs
#define printf(...) winansi_printf(__VA_ARGS__)
#define fprintf(...) winansi_fprintf(__VA_ARGS__)
+#define write winansi_write
/*
* git specific compatibility
diff --git a/compat/winansi.c b/compat/winansi.c
index e2d96df..a9d981c 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -11,15 +11,13 @@
#undef printf
#undef fprintf
#undef fputs
-/* TODO: write */
+#undef write
/*
ANSI codes used by git: m, K
This file is git-specific. Therefore, this file does not attempt
to implement any codes that are not used by git.
-
- TODO: K
*/
static HANDLE console;
@@ -79,6 +77,20 @@ static void set_console_attr(void)
SetConsoleTextAttribute(console, attributes);
}
+static void erase_in_line(void)
+{
+ CONSOLE_SCREEN_BUFFER_INFO sbi;
+
+ if (!console)
+ return;
+
+ GetConsoleScreenBufferInfo(console, &sbi);
+ FillConsoleOutputCharacterA(console, ' ',
+ sbi.dwSize.X - sbi.dwCursorPosition.X, sbi.dwCursorPosition,
+ NULL);
+}
+
+
static const char *set_attr(const char *str)
{
const char *func;
@@ -218,7 +230,7 @@ static const char *set_attr(const char *str)
set_console_attr();
break;
case 'K':
- /* TODO */
+ erase_in_line();
break;
default:
/* Unsupported code */
@@ -228,13 +240,16 @@ static const char *set_attr(const char *str)
return func + 1;
}
-static int ansi_emulate(const char *str, FILE *stream)
+static int ansi_emulate(const char *str, ssize_t len, FILE *stream)
{
int rv = 0;
const char *pos = str;
- while (*pos) {
- pos = strstr(str, "\033[");
+ if (len < 0)
+ len = strlen(str);
+
+ while (rv < len) {
+ pos = memmem(str, len - rv, "\033[", 2);
if (pos) {
size_t len = pos - str;
@@ -254,10 +269,11 @@ static int ansi_emulate(const char *str, FILE *stream)
rv += pos - str;
str = pos;
} else {
- rv += strlen(str);
- fputs(str, stream);
- return rv;
+ fwrite(str, len - rv, 1, stream);
+ return len;
}
+ if (rv > len)
+ die ("Invalid use of ESC [ sequence detected");
}
return rv;
}
@@ -274,7 +290,7 @@ int winansi_fputs(const char *str, FILE *stream)
if (!console)
return fputs(str, stream);
- rv = ansi_emulate(str, stream);
+ rv = ansi_emulate(str, -1, stream);
if (rv >= 0)
return 0;
@@ -309,7 +325,7 @@ static int winansi_vfprintf(FILE *stream, const char *format, va_list list)
len = vsnprintf(buf, len + 1, format, list);
}
- rv = ansi_emulate(buf, stream);
+ rv = ansi_emulate(buf, -1, stream);
if (buf != small_buf)
free(buf);
@@ -343,3 +359,14 @@ int winansi_printf(const char *format, ...)
return rv;
}
+
+int winansi_write(int fd, const void *buf, size_t len)
+{
+ if (isatty(fd)) {
+ init();
+ if (console)
+ return ansi_emulate((const char *)buf, len,
+ fd == 2 ? stderr : stdout);
+ }
+ return write(fd, buf, len);
+}
--
1.6.2.240.g23c7
^ permalink raw reply related
* Re: [PATCH][v2] http authentication via prompts (with correct line lengths)
From: Johannes Schindelin @ 2009-03-10 0:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Mike Gaffney, git
In-Reply-To: <7v1vt6dxg9.fsf@gitster.siamese.dyndns.org>
Hi,
On Mon, 9 Mar 2009, Junio C Hamano wrote:
> It appears that none of the issues I raised in my response to your
> earlier round was addressed in this patch, except for the line
> rewrapping of the proposed commit log message.
AFAICT my concerns were not addressed either: misleading subject unless
the patch is split into two, remote specific config variable instead of
global one, security issues.
Ciao,
Dscho
^ permalink raw reply
* Re: [GSoC] Google Summer of Code 2009 - new ideas
From: Shawn O. Pearce @ 2009-03-10 0:49 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git
In-Reply-To: <200903070144.17457.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> wrote:
> I'd like to add a few ideas to SoC2009Ideas wiki page, but before I do
> this I'd like to ask for comments. (The proposals also lacks proposed
> mentor).
>
> I am wondering if it would be worth it to make a separate class between
> "New to Git?" easy tasks, and "Larger Projects" hard tasks...
Done, there is now a "Medium" category. Folks should start to
repaint the bikeshed if they disagre with my current choices
in colors.
> BTW. some of ideas didn't make it from SoC2008Ideas wiki page to current
> year page, namely:
> * Apply sparse To Fix Errors
> * Lazy clone / remote alternates
> * Implement git-submodule using .gitlink file
> * Teach git-apply the 3-way merge fallback git-am knows
> * Better Emacs integration
> Was this ommision deliberate or accidental?
Accidental. Most have been added back. Of note I did not add back
the emacs integration as we have multiple emacs packages.
--
Shawn.
^ permalink raw reply
* [RFH/Patch 1/2] http.c: style cleanups
From: Junio C Hamano @ 2009-03-10 2:19 UTC (permalink / raw)
To: git
The file is littered with coding style violations; this cleans-up before I
touch it with the next patch.
- We do not initialize statics to NULL/0; we let BSS take care of it
instead.
- Asterisk that means a pointerness comes next to variable, not type;
i.e. a decl looks like "type *variable", not "type* variable".
- A single-statement in true/false clause of an "if () ... else ...;"
statement comes on its own line, without curlies {} around it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* This is not what I am asking for help by sending the series, but the
next one is.
http.c | 44 +++++++++++++++++++++-----------------------
1 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/http.c b/http.c
index 56f18f1..d1ead66 100644
--- a/http.c
+++ b/http.c
@@ -1,7 +1,7 @@
#include "http.h"
int data_received;
-int active_requests = 0;
+int active_requests;
#ifdef USE_CURL_MULTI
static int max_requests = -1;
@@ -13,22 +13,22 @@ static CURL *curl_default;
char curl_errorstr[CURL_ERROR_SIZE];
static int curl_ssl_verify = -1;
-static const char *ssl_cert = NULL;
+static const char *ssl_cert;
#if LIBCURL_VERSION_NUM >= 0x070902
-static const char *ssl_key = NULL;
+static const char *ssl_key;
#endif
#if LIBCURL_VERSION_NUM >= 0x070908
-static const char *ssl_capath = NULL;
+static const char *ssl_capath;
#endif
-static const char *ssl_cainfo = NULL;
+static const char *ssl_cainfo;
static long curl_low_speed_limit = -1;
static long curl_low_speed_time = -1;
-static int curl_ftp_no_epsv = 0;
-static const char *curl_http_proxy = NULL;
+static int curl_ftp_no_epsv;
+static const char *curl_http_proxy;
static struct curl_slist *pragma_header;
-static struct active_request_slot *active_queue_head = NULL;
+static struct active_request_slot *active_queue_head;
size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb, void *buffer_)
{
@@ -94,9 +94,8 @@ static void process_curl_messages(void)
static int http_options(const char *var, const char *value, void *cb)
{
if (!strcmp("http.sslverify", var)) {
- if (curl_ssl_verify == -1) {
+ if (curl_ssl_verify == -1)
curl_ssl_verify = git_config_bool(var, value);
- }
return 0;
}
@@ -158,9 +157,9 @@ static int http_options(const char *var, const char *value, void *cb)
return git_default_config(var, value, cb);
}
-static CURL* get_curl_handle(void)
+static CURL *get_curl_handle(void)
{
- CURL* result = curl_easy_init();
+ CURL *result = curl_easy_init();
if (!curl_ssl_verify) {
curl_easy_setopt(result, CURLOPT_SSL_VERIFYPEER, 0);
@@ -322,15 +321,14 @@ struct active_request_slot *get_active_slot(void)
/* Wait for a slot to open up if the queue is full */
while (active_requests >= max_requests) {
curl_multi_perform(curlm, &num_transfers);
- if (num_transfers < active_requests) {
+ if (num_transfers < active_requests)
process_curl_messages();
- }
}
#endif
- while (slot != NULL && slot->in_use) {
+ while (slot != NULL && slot->in_use)
slot = slot->next;
- }
+
if (slot == NULL) {
newslot = xmalloc(sizeof(*newslot));
newslot->curl = NULL;
@@ -341,9 +339,8 @@ struct active_request_slot *get_active_slot(void)
if (slot == NULL) {
active_queue_head = newslot;
} else {
- while (slot->next != NULL) {
+ while (slot->next != NULL)
slot = slot->next;
- }
slot->next = newslot;
}
slot = newslot;
@@ -404,7 +401,7 @@ struct fill_chain {
struct fill_chain *next;
};
-static struct fill_chain *fill_cfg = NULL;
+static struct fill_chain *fill_cfg;
void add_fill_function(void *data, int (*fill)(void *))
{
@@ -535,9 +532,8 @@ static void finish_active_slot(struct active_request_slot *slot)
}
/* Run callback if appropriate */
- if (slot->callback_func != NULL) {
+ if (slot->callback_func != NULL)
slot->callback_func(slot->callback_data);
- }
}
void finish_all_active_slots(void)
@@ -567,8 +563,10 @@ static inline int needs_quote(int ch)
static inline int hex(int v)
{
- if (v < 10) return '0' + v;
- else return 'A' + v - 10;
+ if (v < 10)
+ return '0' + v;
+ else
+ return 'A' + v - 10;
}
static char *quote_ref_url(const char *base, const char *ref)
--
1.6.2.206.g5bda76
^ permalink raw reply related
* [RFH Patch 2/2] http_init(): Fix config file parsing
From: Junio C Hamano @ 2009-03-10 2:19 UTC (permalink / raw)
To: git
We honor the command line options, environment variables, variables in
repository configuration file, variables in user's global configuration
file, variables in the system configuration file, and then finally use
built-in default. To implement this semantics, the code should:
- start from built-in default values;
- call git_config() with the configuration parser callback, which
implements "later definition overrides earlier ones" logic
(git_config() reads the system's, user's and then repository's
configuration file in this order);
- override the result from the above with environment variables if set;
- override the result from the above with command line options.
The initialization code http_init() for http transfer got this wrong, and
implemented a "first one wins, ignoring the later ones" in http_options(),
to compensate this mistake, read environment variables before calling
git_config(). This is all wrong.
As a second class citizen, the http codepath hasn't been audited as
closely as other parts of the system, but we should try to bring sanity to
the existing codebase before inviting contributors to improve on it.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
* This is what I need help from people who actually do use http transport
and extra set of eyeballs to spot silly mistakes.
http.c | 66 +++++++++++++++++++++++----------------------------------------
1 files changed, 24 insertions(+), 42 deletions(-)
diff --git a/http.c b/http.c
index d1ead66..f4f0bf6 100644
--- a/http.c
+++ b/http.c
@@ -94,52 +94,33 @@ static void process_curl_messages(void)
static int http_options(const char *var, const char *value, void *cb)
{
if (!strcmp("http.sslverify", var)) {
- if (curl_ssl_verify == -1)
- curl_ssl_verify = git_config_bool(var, value);
- return 0;
- }
-
- if (!strcmp("http.sslcert", var)) {
- if (ssl_cert == NULL)
- return git_config_string(&ssl_cert, var, value);
+ curl_ssl_verify = git_config_bool(var, value);
return 0;
}
+ if (!strcmp("http.sslcert", var))
+ return git_config_string(&ssl_cert, var, value);
#if LIBCURL_VERSION_NUM >= 0x070902
- if (!strcmp("http.sslkey", var)) {
- if (ssl_key == NULL)
- return git_config_string(&ssl_key, var, value);
- return 0;
- }
+ if (!strcmp("http.sslkey", var))
+ return git_config_string(&ssl_key, var, value);
#endif
#if LIBCURL_VERSION_NUM >= 0x070908
- if (!strcmp("http.sslcapath", var)) {
- if (ssl_capath == NULL)
- return git_config_string(&ssl_capath, var, value);
- return 0;
- }
+ if (!strcmp("http.sslcapath", var))
+ return git_config_string(&ssl_capath, var, value);
#endif
- if (!strcmp("http.sslcainfo", var)) {
- if (ssl_cainfo == NULL)
- return git_config_string(&ssl_cainfo, var, value);
- return 0;
- }
-
+ if (!strcmp("http.sslcainfo", var))
+ return git_config_string(&ssl_cainfo, var, value);
#ifdef USE_CURL_MULTI
if (!strcmp("http.maxrequests", var)) {
- if (max_requests == -1)
- max_requests = git_config_int(var, value);
+ max_requests = git_config_int(var, value);
return 0;
}
#endif
-
if (!strcmp("http.lowspeedlimit", var)) {
- if (curl_low_speed_limit == -1)
- curl_low_speed_limit = (long)git_config_int(var, value);
+ curl_low_speed_limit = (long)git_config_int(var, value);
return 0;
}
if (!strcmp("http.lowspeedtime", var)) {
- if (curl_low_speed_time == -1)
- curl_low_speed_time = (long)git_config_int(var, value);
+ curl_low_speed_time = (long)git_config_int(var, value);
return 0;
}
@@ -147,11 +128,8 @@ static int http_options(const char *var, const char *value, void *cb)
curl_ftp_no_epsv = git_config_bool(var, value);
return 0;
}
- if (!strcmp("http.proxy", var)) {
- if (curl_http_proxy == NULL)
- return git_config_string(&curl_http_proxy, var, value);
- return 0;
- }
+ if (!strcmp("http.proxy", var))
+ return git_config_string(&curl_http_proxy, var, value);
/* Fall back on the default ones */
return git_default_config(var, value, cb);
@@ -217,6 +195,8 @@ void http_init(struct remote *remote)
char *low_speed_limit;
char *low_speed_time;
+ git_config(http_options, NULL);
+
curl_global_init(CURL_GLOBAL_ALL);
if (remote && remote->http_proxy)
@@ -241,14 +221,18 @@ void http_init(struct remote *remote)
if (getenv("GIT_SSL_NO_VERIFY"))
curl_ssl_verify = 0;
- ssl_cert = getenv("GIT_SSL_CERT");
+ if (getenv("GIT_SSL_CERT"))
+ ssl_cert = getenv("GIT_SSL_CERT");
#if LIBCURL_VERSION_NUM >= 0x070902
- ssl_key = getenv("GIT_SSL_KEY");
+ if (getenv("GIT_SSL_KEY"))
+ ssl_key = getenv("GIT_SSL_KEY");
#endif
#if LIBCURL_VERSION_NUM >= 0x070908
- ssl_capath = getenv("GIT_SSL_CAPATH");
+ if (getenv("GIT_SSL_CAPATH"))
+ ssl_capath = getenv("GIT_SSL_CAPATH");
#endif
- ssl_cainfo = getenv("GIT_SSL_CAINFO");
+ if (getenv("GIT_SSL_CAINFO"))
+ ssl_cainfo = getenv("GIT_SSL_CAINFO");
low_speed_limit = getenv("GIT_HTTP_LOW_SPEED_LIMIT");
if (low_speed_limit != NULL)
@@ -257,8 +241,6 @@ void http_init(struct remote *remote)
if (low_speed_time != NULL)
curl_low_speed_time = strtol(low_speed_time, NULL, 10);
- git_config(http_options, NULL);
-
if (curl_ssl_verify == -1)
curl_ssl_verify = 1;
--
1.6.2.206.g5bda76
^ permalink raw reply related
* Re: [RFH Patch 2/2] http_init(): Fix config file parsing
From: Jay Soffian @ 2009-03-10 3:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vfxhmce67.fsf@gitster.siamese.dyndns.org>
On Mon, Mar 9, 2009 at 10:19 PM, Junio C Hamano <gitster@pobox.com> wrote:
> * This is what I need help from people who actually do use http transport
> and extra set of eyeballs to spot silly mistakes.
It looks sane to me.
> @@ -241,14 +221,18 @@ void http_init(struct remote *remote)
> if (getenv("GIT_SSL_NO_VERIFY"))
> curl_ssl_verify = 0;
>
> - ssl_cert = getenv("GIT_SSL_CERT");
> + if (getenv("GIT_SSL_CERT"))
> + ssl_cert = getenv("GIT_SSL_CERT");
> #if LIBCURL_VERSION_NUM >= 0x070902
> - ssl_key = getenv("GIT_SSL_KEY");
> + if (getenv("GIT_SSL_KEY"))
> + ssl_key = getenv("GIT_SSL_KEY");
> #endif
> #if LIBCURL_VERSION_NUM >= 0x070908
> - ssl_capath = getenv("GIT_SSL_CAPATH");
> + if (getenv("GIT_SSL_CAPATH"))
> + ssl_capath = getenv("GIT_SSL_CAPATH");
> #endif
> - ssl_cainfo = getenv("GIT_SSL_CAINFO");
> + if (getenv("GIT_SSL_CAINFO"))
> + ssl_cainfo = getenv("GIT_SSL_CAINFO");
Would these be a little cleaner with a temporary variable. e.g.
char *value;
if ((value = getenv("GIT_SSL_CERT")))
ssl_cert = value;
j.
^ permalink raw reply
* Remove leading/trailing whitespace from commit messages when importing from Subversion?
From: Mike Swanson @ 2009-03-10 3:14 UTC (permalink / raw)
To: git
I was wondering if it's possible to removing leading and trailing
whitespace (tabs, newlines, spaces) from commit messages when importing
from Subversion via git-svn.
I've got a repository with tens of thousands of commits, and not all of
the messages are entered... sanely. I need to know whether it is
possible to clean these up when transfering the repository to Git.
Thanks.
^ permalink raw reply
* Re: [PATCH][v2] http authentication via prompts (with correct line lengths)
From: Mike Gaffney @ 2009-03-10 3:25 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, git
In-Reply-To: <alpine.DEB.1.00.0903100143550.6358@intel-tinevez-2-302>
I guess it makes sense to split the config out into two patches. I wanted both to help with automated builds, and as it's a read only account I wasn't worried about someone reading the password. I'm not very impressed with the permissions on the .netrc file actually providing security so I can see not allowing the password in the config either. In my system at work, we have shared machines but all developers have root access, so file permissions don't really secure anything for us. It's also why we can't really use keys (there is no way to enforce that a key is secured afaik).
I wanted to do a remote specific config as well but a global works well in many environments where your push repo is under http as you don't keep having to configure it. I also couldn't see a good way to do a remote specific config without changing the remote struct (which seemd like putting specific in a general). I would love some advice on this and where to put it.
I can see your security points but I would argue that if that's what we are worried about then we should not allow the netrc file at all. I added notes in the config documentation about this. I'm open to discussion on this point.
Johannes Schindelin wrote:
> Hi,
>
> On Mon, 9 Mar 2009, Junio C Hamano wrote:
>
>> It appears that none of the issues I raised in my response to your
>> earlier round was addressed in this patch, except for the line
>> rewrapping of the proposed commit log message.
>
> AFAICT my concerns were not addressed either: misleading subject unless
> the patch is split into two, remote specific config variable instead of
> global one, security issues.
>
> Ciao,
> Dscho
>
--
-Mike Gaffney (http://rdocul.us)
^ permalink raw reply
* [PATCHv5] Make git-clone respect branch.autosetuprebase
From: Pat Notz @ 2009-03-10 3:26 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
In-Reply-To: <1cd1989b0903060621w60124401s9986507e356783b1@mail.gmail.com>
From: Junio C Hamano <gitster@pobox.com>
When git-clone creates an initial branch it was not checking the
branch.autosetuprebase configuration option (which may exist in
~/.gitconfig). Refactor the code used by "git branch" to create
a new branch, and use it instead of the insufficiently duplicated code
in builtin-clone.
Minor modification of the patch from Junio Hamano.
---
This version fixes the verbose output to be more human friendly. Before,
the branch being tracked was printed as 'refs/heads/frotz' regardless of
wether that was a local or remote branch. Now, a local branch is just
printed as 'frotz' and a remote branch is printed as 'origin/frotz'
branch.c | 49 +++++++++++++++++++++++++++++++++----------------
branch.h | 7 +++++++
builtin-clone.c | 18 +++---------------
t/t5601-clone.sh | 15 +++++++++++++++
4 files changed, 58 insertions(+), 31 deletions(-)
diff --git a/branch.c b/branch.c
index 1f00e44..d20fb04 100644
--- a/branch.c
+++ b/branch.c
@@ -32,21 +32,48 @@ static int find_tracked_branch(struct remote *remote, void *priv)
return 0;
}
-static int should_setup_rebase(const struct tracking *tracking)
+static int should_setup_rebase(const char *origin)
{
switch (autorebase) {
case AUTOREBASE_NEVER:
return 0;
case AUTOREBASE_LOCAL:
- return tracking->remote == NULL;
+ return origin == NULL;
case AUTOREBASE_REMOTE:
- return tracking->remote != NULL;
+ return origin != NULL;
case AUTOREBASE_ALWAYS:
return 1;
}
return 0;
}
+void install_branch_config(int flag, const char *local, const char *origin, const char *remote)
+{
+ struct strbuf key = STRBUF_INIT;
+ int rebasing = should_setup_rebase(origin);
+
+ strbuf_addf(&key, "branch.%s.remote", local);
+ git_config_set(key.buf, origin ? origin : ".");
+
+ strbuf_reset(&key);
+ strbuf_addf(&key, "branch.%s.merge", local);
+ git_config_set(key.buf, remote);
+
+ if (rebasing) {
+ strbuf_reset(&key);
+ strbuf_addf(&key, "branch.%s.rebase", local);
+ git_config_set(key.buf, "true");
+ }
+
+ if (flag & BRANCH_CONFIG_VERBOSE)
+ printf("Branch %s set up to track %s branch %s %s.\n",
+ local,
+ origin ? "remote" : "local",
+ remote,
+ rebasing ? "by rebasing" : "by merging");
+ strbuf_release(&key);
+}
+
/*
* This is called when new_ref is branched off of orig_ref, and tries
* to infer the settings for branch.<new_ref>.{remote,merge} from the
@@ -55,7 +82,6 @@ static int should_setup_rebase(const struct tracking *tracking)
static int setup_tracking(const char *new_ref, const char *orig_ref,
enum branch_track track)
{
- char key[1024];
struct tracking tracking;
if (strlen(new_ref) > 1024 - 7 - 7 - 1)
@@ -80,19 +106,10 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,
return error("Not tracking: ambiguous information for ref %s",
orig_ref);
- sprintf(key, "branch.%s.remote", new_ref);
- git_config_set(key, tracking.remote ? tracking.remote : ".");
- sprintf(key, "branch.%s.merge", new_ref);
- git_config_set(key, tracking.src ? tracking.src : orig_ref);
- printf("Branch %s set up to track %s branch %s.\n", new_ref,
- tracking.remote ? "remote" : "local", orig_ref);
- if (should_setup_rebase(&tracking)) {
- sprintf(key, "branch.%s.rebase", new_ref);
- git_config_set(key, "true");
- printf("This branch will rebase on pull.\n");
- }
- free(tracking.src);
+ install_branch_config(BRANCH_CONFIG_VERBOSE, new_ref, tracking.remote,
+ tracking.src ? tracking.src : orig_ref);
+ free(tracking.src);
return 0;
}
diff --git a/branch.h b/branch.h
index 9f0c2a2..eed817a 100644
--- a/branch.h
+++ b/branch.h
@@ -21,4 +21,11 @@ void create_branch(const char *head, const char *name, const char *start_name,
*/
void remove_branch_state(void);
+/*
+ * Configure local branch "local" to merge remote branch "remote"
+ * taken from origin "origin".
+ */
+#define BRANCH_CONFIG_VERBOSE 01
+extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);
+
#endif
diff --git a/builtin-clone.c b/builtin-clone.c
index 92826cd..687df9a 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -20,6 +20,7 @@
#include "dir.h"
#include "pack-refs.h"
#include "sigchain.h"
+#include "branch.h"
/*
* Overall FIXMEs:
@@ -350,19 +351,6 @@ static struct ref *write_remote_refs(const struct ref *refs,
return local_refs;
}
-static void install_branch_config(const char *local,
- const char *origin,
- const char *remote)
-{
- struct strbuf key = STRBUF_INIT;
- strbuf_addf(&key, "branch.%s.remote", local);
- git_config_set(key.buf, origin);
- strbuf_reset(&key);
- strbuf_addf(&key, "branch.%s.merge", local);
- git_config_set(key.buf, remote);
- strbuf_release(&key);
-}
-
int cmd_clone(int argc, const char **argv, const char *prefix)
{
int is_bundle = 0;
@@ -547,7 +535,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
remote_head = NULL;
option_no_checkout = 1;
if (!option_bare)
- install_branch_config("master", option_origin,
+ install_branch_config(0, "master", option_origin,
"refs/heads/master");
}
@@ -577,7 +565,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
head_points_at->peer_ref->name,
reflog_msg.buf);
- install_branch_config(head, option_origin,
+ install_branch_config(0, head, option_origin,
head_points_at->name);
}
} else if (remote_head) {
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 44793f2..2335d8b 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -159,4 +159,19 @@ test_expect_success 'clone a void' '
test_cmp target-6/.git/config target-7/.git/config
'
+test_expect_success 'clone respects global branch.autosetuprebase' '
+ (
+ HOME=$(pwd) &&
+ export HOME &&
+ test_config="$HOME/.gitconfig" &&
+ unset GIT_CONFIG_NOGLOBAL &&
+ git config -f "$test_config" branch.autosetuprebase remote &&
+ rm -fr dst &&
+ git clone src dst &&
+ cd dst &&
+ actual="z$(git config branch.master.rebase)" &&
+ test ztrue = $actual
+ )
+'
+
test_done
--
1.6.2
^ permalink raw reply related
* [PATCHv6] Make git-clone respect branch.autosetuprebase
From: Pat Notz @ 2009-03-10 4:24 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
In-Reply-To: <1236655610-14236-1-git-send-email-pknotz@sandia.gov>
From: Junio C Hamano <gitster@pobox.com>
When git-clone creates an initial branch it was not checking the
branch.autosetuprebase configuration option (which may exist in
~/.gitconfig). Refactor the code used by "git branch" to create
a new branch, and use it instead of the insufficiently duplicated code
in builtin-clone.
Minor modification of the patch from Junio Hamano.
---
Ugh. Another resend... I need to stop working at night.
This version fixes the verbose output to be more human friendly. Before,
the branch being tracked was printed as 'refs/heads/frotz' regardless of
wether that was a local or remote branch. Now, a local branch is just
printed as 'frotz' and a remote branch is printed as 'origin/frotz'
branch.c | 55 ++++++++++++++++++++++++++++++++++++++---------------
branch.h | 7 ++++++
builtin-clone.c | 18 ++--------------
t/t5601-clone.sh | 15 ++++++++++++++
4 files changed, 64 insertions(+), 31 deletions(-)
diff --git a/branch.c b/branch.c
index 1f00e44..eecda64 100644
--- a/branch.c
+++ b/branch.c
@@ -32,21 +32,54 @@ static int find_tracked_branch(struct remote *remote, void *priv)
return 0;
}
-static int should_setup_rebase(const struct tracking *tracking)
+static int should_setup_rebase(const char *origin)
{
switch (autorebase) {
case AUTOREBASE_NEVER:
return 0;
case AUTOREBASE_LOCAL:
- return tracking->remote == NULL;
+ return origin == NULL;
case AUTOREBASE_REMOTE:
- return tracking->remote != NULL;
+ return origin != NULL;
case AUTOREBASE_ALWAYS:
return 1;
}
return 0;
}
+void install_branch_config(int flag, const char *local, const char *origin, const char *remote)
+{
+ struct strbuf key = STRBUF_INIT;
+ int rebasing = should_setup_rebase(origin);
+
+ strbuf_addf(&key, "branch.%s.remote", local);
+ git_config_set(key.buf, origin ? origin : ".");
+
+ strbuf_reset(&key);
+ strbuf_addf(&key, "branch.%s.merge", local);
+ git_config_set(key.buf, remote);
+
+ if (rebasing) {
+ strbuf_reset(&key);
+ strbuf_addf(&key, "branch.%s.rebase", local);
+ git_config_set(key.buf, "true");
+ }
+
+ if (flag & BRANCH_CONFIG_VERBOSE){
+ strbuf_reset(&key);
+ if(origin)
+ strbuf_addf(&key, "%s/%s", origin, remote+11);
+ else
+ strbuf_addf(&key, "%s", remote+11);
+ printf("Branch %s set up to track %s branch %s %s.\n",
+ local,
+ origin ? "remote" : "local",
+ key.buf,
+ rebasing ? "by rebasing" : "by merging");
+ }
+ strbuf_release(&key);
+}
+
/*
* This is called when new_ref is branched off of orig_ref, and tries
* to infer the settings for branch.<new_ref>.{remote,merge} from the
@@ -55,7 +88,6 @@ static int should_setup_rebase(const struct tracking *tracking)
static int setup_tracking(const char *new_ref, const char *orig_ref,
enum branch_track track)
{
- char key[1024];
struct tracking tracking;
if (strlen(new_ref) > 1024 - 7 - 7 - 1)
@@ -80,19 +112,10 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,
return error("Not tracking: ambiguous information for ref %s",
orig_ref);
- sprintf(key, "branch.%s.remote", new_ref);
- git_config_set(key, tracking.remote ? tracking.remote : ".");
- sprintf(key, "branch.%s.merge", new_ref);
- git_config_set(key, tracking.src ? tracking.src : orig_ref);
- printf("Branch %s set up to track %s branch %s.\n", new_ref,
- tracking.remote ? "remote" : "local", orig_ref);
- if (should_setup_rebase(&tracking)) {
- sprintf(key, "branch.%s.rebase", new_ref);
- git_config_set(key, "true");
- printf("This branch will rebase on pull.\n");
- }
- free(tracking.src);
+ install_branch_config(BRANCH_CONFIG_VERBOSE, new_ref, tracking.remote,
+ tracking.src ? tracking.src : orig_ref);
+ free(tracking.src);
return 0;
}
diff --git a/branch.h b/branch.h
index 9f0c2a2..eed817a 100644
--- a/branch.h
+++ b/branch.h
@@ -21,4 +21,11 @@ void create_branch(const char *head, const char *name, const char *start_name,
*/
void remove_branch_state(void);
+/*
+ * Configure local branch "local" to merge remote branch "remote"
+ * taken from origin "origin".
+ */
+#define BRANCH_CONFIG_VERBOSE 01
+extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);
+
#endif
diff --git a/builtin-clone.c b/builtin-clone.c
index 92826cd..687df9a 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -20,6 +20,7 @@
#include "dir.h"
#include "pack-refs.h"
#include "sigchain.h"
+#include "branch.h"
/*
* Overall FIXMEs:
@@ -350,19 +351,6 @@ static struct ref *write_remote_refs(const struct ref *refs,
return local_refs;
}
-static void install_branch_config(const char *local,
- const char *origin,
- const char *remote)
-{
- struct strbuf key = STRBUF_INIT;
- strbuf_addf(&key, "branch.%s.remote", local);
- git_config_set(key.buf, origin);
- strbuf_reset(&key);
- strbuf_addf(&key, "branch.%s.merge", local);
- git_config_set(key.buf, remote);
- strbuf_release(&key);
-}
-
int cmd_clone(int argc, const char **argv, const char *prefix)
{
int is_bundle = 0;
@@ -547,7 +535,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
remote_head = NULL;
option_no_checkout = 1;
if (!option_bare)
- install_branch_config("master", option_origin,
+ install_branch_config(0, "master", option_origin,
"refs/heads/master");
}
@@ -577,7 +565,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
head_points_at->peer_ref->name,
reflog_msg.buf);
- install_branch_config(head, option_origin,
+ install_branch_config(0, head, option_origin,
head_points_at->name);
}
} else if (remote_head) {
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 44793f2..2335d8b 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -159,4 +159,19 @@ test_expect_success 'clone a void' '
test_cmp target-6/.git/config target-7/.git/config
'
+test_expect_success 'clone respects global branch.autosetuprebase' '
+ (
+ HOME=$(pwd) &&
+ export HOME &&
+ test_config="$HOME/.gitconfig" &&
+ unset GIT_CONFIG_NOGLOBAL &&
+ git config -f "$test_config" branch.autosetuprebase remote &&
+ rm -fr dst &&
+ git clone src dst &&
+ cd dst &&
+ actual="z$(git config branch.master.rebase)" &&
+ test ztrue = $actual
+ )
+'
+
test_done
--
1.6.2
^ permalink raw reply related
* Re: [PATCH][v2] http authentication via prompts (with correct line lengths)
From: Mike Gaffney @ 2009-03-10 4:46 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7v1vt6dxg9.fsf@gitster.siamese.dyndns.org>
Junio,
Just spent about 30 minutes replying to your points until the last one
made most moot. I agree that putting the info into the url will fix the bug,
which I have never seen (see #3 below), and make the howto easier to read. So a
few things I wanted to discuss or ask for help on:
1) Note that I'm not a C guy so:
Junio wrote:
>> +static const char *curl_http_username = NULL;
>> +static const char *curl_http_password = NULL;
>> +
> Please do not introduce new initializations of static variables to 0 or
> NULL. As a clean-up, before your patch, you can send in a patch to fix
> existing such initializations.
I'm not sure what you mean here. Should I just declare them as:
static const char *curl_http_password; ?
Also do you mean that during after the patch phase they get changed to:
static const char *curl_http_password = NULL; ?
Or do you mean that I can send in a patch to fix other static variables
(not mine) which are being initialized to NULL?
2) Being that I'm not a big C guy, I'm not sure the best way to go about
parsing the username out of the URL to pull it into a variable to pass
to CURLOPT_USERPASS. Any advice from the community would be greatly
appreciated.
3) From my experience with curl, many of the options do
not work the same across versions or platforms. For example, the new
CURLOPT_USERNAME/PASSWORD options worked fine in 7.19.4 on cygwin but not
on FC9, which is why I used the older USERPWD. Also, my curl never prompted
me for the password when I supplied a username in the URL which is what
prompted me to do this patch in the first place. As such, I think it is
better to pull the username & password prompting logic into git make this
stable and fix the bug.
4) I'm not really impressed that file permissions actually make the .netrc
file a secure option. However, it's already in there and would break
backwards compatibility to take it out. I also realize that there is a need
for automated builds to be able to pull the source. So I would like to add a nice
warning section to the http docs explaining the repercussions of using it.
Thanks for the help,
Mike
^ permalink raw reply
* Re: Remove leading/trailing whitespace from commit messages when importing from Subversion?
From: Marcel M. Cary @ 2009-03-10 5:38 UTC (permalink / raw)
To: Mike Swanson; +Cc: git@vger.kernel.org
In-Reply-To: <49B5DB01.8080206@gmail.com>
Mike Swanson wrote:
> I was wondering if it's possible to removing leading and trailing
> whitespace (tabs, newlines, spaces) from commit messages when importing
> from Subversion via git-svn.
>
> I've got a repository with tens of thousands of commits, and not all of
> the messages are entered... sanely. I need to know whether it is
> possible to clean these up when transfering the repository to Git.
Try "git filter-branch --msg-filter your-filter-command".
Marcel
^ permalink raw reply
* Re: [PATCH 0/5] grep: color search patterns
From: Nguyen Thai Ngoc Duy @ 2009-03-10 6:01 UTC (permalink / raw)
To: René Scharfe; +Cc: Git Mailing List, Junio C Hamano, Thiago Alves
In-Reply-To: <1236428699.6486.41.camel@ubuntu.ubuntu-domain>
On 3/7/09, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote:
> Match coloring is a major missing feature of git grep. It makes reading
> the output much easier and brings grep onto the same visual level as the
> other colorized git commands.
"git --color test" did not colorize the result for me. "git --color
--no-ext-grep test" did. Maybe you should ignore external grep unless
it is explicitly requested, like in the last patch. I have very
limited net access these days. Let's see if I can work out something
for tomorrow, unless you beat me to it.
--
Duy
^ permalink raw reply
* Re: Remove leading/trailing whitespace from commit messages when importing from Subversion?
From: Mike Swanson @ 2009-03-10 6:15 UTC (permalink / raw)
To: git@vger.kernel.org
In-Reply-To: <49B5FCD3.8060707@oak.homeunix.org>
Marcel M. Cary wrote:
> Try "git filter-branch --msg-filter your-filter-command".
>
> Marcel
>
Thank you, after-the-fact works fine too. :)
If anyone else searches the archives and wonders how I did it, this sed
command is it: sed -e "s/^[ \t]*//;s/[ \t]*$//;/^$/d"
Unix rules!
^ permalink raw reply
* Re: [PATCH][v2] http authentication via prompts (with correct line lengths)
From: Junio C Hamano @ 2009-03-10 6:34 UTC (permalink / raw)
To: Mike Gaffney; +Cc: git
In-Reply-To: <49B5F0BA.3070806@gmail.com>
Mike Gaffney <mr.gaffo@gmail.com> writes:
>>> +static const char *curl_http_username = NULL;
>>> +static const char *curl_http_password = NULL;
>>> +
>> Please do not introduce new initializations of static variables to 0 or
>> NULL. As a clean-up, before your patch, you can send in a patch to fix
>> existing such initializations.
> ...
> Or do you mean that I can send in a patch to fix other static variables
> (not mine) which are being initialized to NULL?
Yeah, a preparatory patch to clean things up, like the one I sent out
earlier this evening, was what I meant.
> 2) Being that I'm not a big C guy, I'm not sure the best way to go about
> parsing the username out of the URL to pull it into a variable to pass
> to CURLOPT_USERPASS. Any advice from the community would be greatly
> appreciated.
I am sort of a C guy, but I am by no means a libcurl person. A quick and
dirty patch is attached, which is partly based on yours, but is stripped
of version dependency and also I suspect it handles only the http-walker
side. It is on top of the two clean-up patch I sent this evening.
It hasn't seen any test, but I just ran this once:
$ git clone http://junio@my.private.machine/test-repo.git/
from a repository that requires authentication but I have no .netrc and no
http.password configuration; I was asked for the password once, of course.
> 3) From my experience with curl, many of the options do
> not work the same across versions or platforms. For example, the new
> CURLOPT_USERNAME/PASSWORD options worked fine in 7.19.4 on cygwin but not
> on FC9, which is why I used the older USERPWD. Also, my curl never prompted
> me for the password when I supplied a username in the URL which is what
> prompted me to do this patch in the first place. As such, I think it is
> better to pull the username & password prompting logic into git make this
> stable and fix the bug.
Heh, 7.19.4 was only released on a few days ago if I am reading its
download page correctly.
The version of libcurl on my box is 7.18.something, and it does not seem
to ask for password when the URL has only username but not colon-password.
I also expected it to ask for password when $HOME/.netrc has login but not
password for a given machine, but that does not seem to happen either.
Perhaps the version is too old.
> 4) I'm not really impressed that file permissions actually make the .netrc
> file a secure option. However, it's already in there and would break
> backwards compatibility to take it out. I also realize that there is a need
> for automated builds to be able to pull the source. So I would like to add a nice
> warning section to the http docs explaining the repercussions of using it.
I agree with the first two sentences and am not happy with http.password
because of it.
---
http.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/http.c b/http.c
index f4f0bf6..3d5caa6 100644
--- a/http.c
+++ b/http.c
@@ -25,6 +25,7 @@ static long curl_low_speed_limit = -1;
static long curl_low_speed_time = -1;
static int curl_ftp_no_epsv;
static const char *curl_http_proxy;
+static char *user_name, *user_pass;
static struct curl_slist *pragma_header;
@@ -135,6 +136,20 @@ static int http_options(const char *var, const char *value, void *cb)
return git_default_config(var, value, cb);
}
+static void init_curl_http_auth(CURL *result)
+{
+ if (!user_name)
+ curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
+ else {
+ struct strbuf up = STRBUF_INIT;
+ if (!user_pass)
+ user_pass = xstrdup(getpass("Password: "));
+ strbuf_addf(&up, "%s:%s", user_name, user_pass);
+ curl_easy_setopt(result, CURLOPT_USERPWD,
+ strbuf_detach(&up, NULL));
+ }
+}
+
static CURL *get_curl_handle(void)
{
CURL *result = curl_easy_init();
@@ -153,6 +168,8 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
#endif
+ init_curl_http_auth(result);
+
if (ssl_cert != NULL)
curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
#if LIBCURL_VERSION_NUM >= 0x070902
@@ -190,6 +207,46 @@ static CURL *get_curl_handle(void)
return result;
}
+static void http_auth_init(const char *url)
+{
+ char *at, *colon, *cp, *slash;
+ int len;
+
+ cp = strstr(url, "://");
+ if (!cp)
+ return;
+
+ /*
+ * Ok, the URL looks like "proto://something". Which one?
+ * "proto://<user>:<pass>@<host>/...",
+ * "proto://<user>@<host>/...", or just
+ * "proto://<host>/..."?
+ */
+ cp += 3;
+ at = strchr(cp, '@');
+ colon = strchr(cp, ':');
+ slash = strchrnul(cp, '/');
+ if (!at || slash <= at)
+ 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';
+ user_pass = NULL;
+ } else {
+ len = colon - cp;
+ user_name = xmalloc(len + 1);
+ memcpy(user_name, cp, len);
+ user_name[len] = '\0';
+ len = at - (colon + 1);
+ user_pass = xmalloc(len + 1);
+ memcpy(user_pass, colon + 1, len);
+ user_pass[len] = '\0';
+ }
+}
+
void http_init(struct remote *remote)
{
char *low_speed_limit;
@@ -252,6 +309,9 @@ 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]);
+
#ifndef NO_CURL_EASY_DUPHANDLE
curl_default = get_curl_handle();
#endif
^ permalink raw reply related
* Re: filter-branch --subdirectory-filter prematurely truncating history?
From: Johannes Sixt @ 2009-03-10 7:00 UTC (permalink / raw)
To: Cap Petschulat; +Cc: git
In-Reply-To: <loom.20090309T230424-857@post.gmane.org>
Cap Petschulat schrieb:
> I'd like to spin a subdirectory of an existing git repo off in to its
> own repo while preserving history. From what I've read, I should be
> able to do this with a fresh clone followed by git filter-branch
> --subdirectory-filter MYSUBDIR, assuming I don't care about other
> branches or tags. This runs, and when it's done, I have a repo that
> contains the subdir's contents as its root. So far so good.
>
> I would expect to see the subdir's full history when I run git log,
> but instead it cuts off prematurely, showing the first commit to be
> some relatively recent minor change I'll call FOO. In gitk, I can see
> that history prior to FOO is still around, but FOO has no parents, and
> the commit before FOO has no children. In the original repo, FOO's
> parent was the merge of a branch which no longer exists, if this
> matters.
A bug in this area was fixed in git v1.6.0-rc3. Which version are you using?
-- Hannes
^ permalink raw reply
* Re: [PATCH] contrib/difftool: use a separate config namespace for difftool commands
From: David Aguilar @ 2009-03-10 7:01 UTC (permalink / raw)
To: Jay Soffian; +Cc: Junio C Hamano, git
In-Reply-To: <76718490903090852se7fc756m818f5d8ba49278b5@mail.gmail.com>
On 0, Jay Soffian <jaysoffian@gmail.com> wrote:
> On Mon, Mar 9, 2009 at 5:12 AM, David Aguilar <davvid@gmail.com> wrote:
> > contrib/difftool/git-difftool | 6 +++---
>
> Aside, (for Junio I guess...), what's the reason this command is in
> contrib, and by what criteria might it graduate to being installed
> with the rest of the git commands?
>
> j.
My thoughts (also for Junio, I guess..):
If y'all feel that it can live with the rest of the git
commands then that would be great =)
I'm definitely willing to help maintain difftool.
It's a low-maintance script and making it easily available
means more testing which is good. I should probably look
at the regression tests in place for mergetool and
see if I can start actually testing difftool using a
similar strategy.
--
David
^ permalink raw reply
* Re: Generalised bisection
From: Christian Couder @ 2009-03-10 7:08 UTC (permalink / raw)
To: Ealdwulf Wuffinga; +Cc: Git List, John Tapsell, Ingo Molnar
In-Reply-To: <efe2b6d70903081840v18e77aa7w2dac2bed553d0d6a@mail.gmail.com>
Le lundi 9 mars 2009, Ealdwulf Wuffinga a écrit :
> [whoops, mail server does not like html. trying again...]
>
> Hi,
>
> I have developed a generalised bisection algorithm, for the case where
> a bug is intermittent. The code may be found at
> git://github.com/Ealdwulf/bbchop.git. It should be considered
> experimental.
I will try to have a look at the end of this week.
But do you want it to be integrated with Git or do you want it to be an
independant project that works with many different version control system?
Best regards,
Christian.
^ permalink raw reply
* Re: [PATCH] winansi: support ESC [ K (erase in line)
From: Johannes Sixt @ 2009-03-10 7:15 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, gitster, Peter Harris, Sebastian Schuberth
In-Reply-To: <e2b19f6c7c50e5b0a652c40b0d8e4947134ed669.1236639280u.git.johannes.schindelin@gmx.de>
Johannes Schindelin schrieb:
> This fixes the last bit of msysGit issue 124 for me:
>
> http://code.google.com/p/msysgit/issues/detail?id=124
>
> which annoyed me one time to many today.
>
> I had an earlier version which was smaller, but pretty hacky, in
> that it checked if fprintf is #define'd in xwrite(), and had
> special handling for that case.
>
> This patch is only slightly hacky, in that it assumes that you do
> not try to output something that ends in an incomplete ESC [
> sequence.
Good that I read mail before I start hacking. I was about to do something
about this in a moment. ;)
> To make use of it during a fetch, write() needs to be overridden, too.
No, that's not necessary with the patch that I'm about to send in a
moment. To replace write() for ANSI emulation really goes too far.
-- Hannes
^ 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