* [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:07 UTC (permalink / raw)
To: Finn Arne Gangstad; +Cc: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
Finn Arne Gangstad <finnag@pvv.org> writes:
> "-" is now an alias for the current remote (the remote of the current
> branch or "origin" as a fallback). This works both for push, fetch,
> pull, remote (and possibly some others), creating a lot of nice
> shortcuts I think:
> git remote prune - : prune the current remote
> git push - HEAD : push the current branch to a branch of the same name
> git fetch - next : fetch the next branch from the current remote
>
> git push has learned two new command line options --matching and
> --current, which override any configuration. 'matching' pushes all
> branches that already exist at the remote, while 'current' pushes the
> current branch to whatever it is tracking
>
> I chose this behaviour for 'current', since it is the one that I find
> most useful, and there seems to be no good way of expressing it from
> the command line. Pushing a branch to an identically named branch on
> a remote can now easily be done by "git push - HEAD".
>
> Also added a new configuration option push.default, which can have values
> "nothing", "matching" and "current". This variable will only be used if
> you have not specificed any refspecs at all, no command line options imply
> any refspecs, and the current branch has no push configuration.
>
> This is implemented in 1-3
I think the last four are more or less sane, but I am not sure about the
first three, which makes it very unfortunate that the former depends on
the latter.
Some design issues and questions regarding the first three; not all of
them are objections:
* Do we use a short-hand for "the default thing" anywhere else in the
current UI (not just "git push" but in the "git" command set)?
- If the answer to the above question is "yes", does it use '-' as the
short-hand too? In other words, is this new short-hand consistent
with it, or is it introducing "git-push uses '-' as the short-hand
for the default, while git-frotz uses something else" confusion?
- 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?
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"?
- 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.
* What's the point of having --matching option, when you can already say
':', i.e.
$ git push origin :
* What's the point of having --current option, when you can already say
HEAD, i.e.
$ git push origin HEAD
* Is push.default still necessary if we had "remote.*.push" (where '*' is
literally an "asterisk") that is used as a fall-back default when there
is no "remote.<name>.push" for the remote we are about to push to?
^ permalink raw reply
* Re: [PATCH 3/7] git push: New options --matching and --current
From: Daniel Barkalow @ 2009-03-09 23:49 UTC (permalink / raw)
To: Finn Arne Gangstad; +Cc: git
In-Reply-To: <1236638151-6465-4-git-send-email-finnag@pvv.org>
On Mon, 9 Mar 2009, Finn Arne Gangstad wrote:
> diff --git a/transport.h b/transport.h
> index 6bbc1a8..b897d0c 100644
> --- a/transport.h
> +++ b/transport.h
> @@ -34,6 +34,15 @@ struct transport {
> #define TRANSPORT_PUSH_DRY_RUN 4
> #define TRANSPORT_PUSH_MIRROR 8
> #define TRANSPORT_PUSH_VERBOSE 16
> +#define TRANSPORT_PUSH_MATCHING 32
> +#define TRANSPORT_PUSH_CURRENT 64
> +/**
> + * All push flags that imply a certain set of refspecs to be pushed must
> + * be combined into TRANSPORT_PUSH_MODE_MASK
> + **/
> +#define TRANSPORT_PUSH_MODE_MASK \
> + (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR | TRANSPORT_PUSH_MATCHING | \
> + TRANSPORT_PUSH_CURRENT)
It's kind of odd that you define these flags as TRANSPORT_PUSH_*, but
implement them before entering transport_push(). I'm not sure which is
right, but the combination is odd. I think just taking care of it in
builtin-push with flags or options defined there is probably the best
thing, currently.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: [RFC/PATCH] git push usability improvements and default change
From: Johannes Schindelin @ 2009-03-09 23:35 UTC (permalink / raw)
To: Finn Arne Gangstad; +Cc: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
Hi,
On Mon, 9 Mar 2009, Finn Arne Gangstad wrote:
> 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.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] Append ampersand to "Target" of lnk files created by do_cygwin_shortcut
From: Shawn O. Pearce @ 2009-03-09 23:23 UTC (permalink / raw)
To: Phil Lawrence; +Cc: Johannes Schindelin, git
In-Reply-To: <530ac78e0903091509y5209dec9q4c716d1e400357f3@mail.gmail.com>
Phil Lawrence <prlawrence@gmail.com> wrote:
> From 0780db8d53bdd0bb02b154d23c3c80bcccc0d955 Mon Sep 17 00:00:00 2001
> From: Phil Lawrence <prlawrence@gmail.com>
> Date: Thu, 5 Mar 2009 17:56:58 -0600
> Subject: [PATCH] Append ampersand to "Target" of lnk files created by
> do_cygwin_shortcut
>
> The git-gui menu item "Repository | Create Desktop Icon" creates a
> shortcut (.lnk file) on the Windows desktop. The purpose of the
> created shortcut is to make it easy for a user to launch git-gui
> for a particular repo in the future.
Thanks. The patch was white space damaged, but being only 2
characters it was easier for me to just redo the change than
to ask you to resend the patch.
> @@ -54,7 +54,7 @@ proc do_cygwin_shortcut {} {
> $argv0]
> win32_create_lnk $fn [list \
> $sh -c \
> - "CHERE_INVOKING=1 source
> /etc/profile;[sq $me]" \
> + "CHERE_INVOKING=1 source
> /etc/profile;[sq $me] &" \
> ] \
> [file dirname [file normalize [gitdir]]]
> } err]} {
--
Shawn.
^ permalink raw reply
* [PATCH 5/7] git push: Document that "nothing" is the future push default
From: Finn Arne Gangstad @ 2009-03-09 22:35 UTC (permalink / raw)
To: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
Documentation/RelNotes-1.6.3.txt | 7 +++++++
builtin-push.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Documentation/RelNotes-1.6.3.txt b/Documentation/RelNotes-1.6.3.txt
index ee1fddb..87de02a 100644
--- a/Documentation/RelNotes-1.6.3.txt
+++ b/Documentation/RelNotes-1.6.3.txt
@@ -22,6 +22,13 @@ branch pointed at by its HEAD, gets a large warning. You can choose what
should happen upon such a push by setting the configuration variable
receive.denyDeleteCurrent in the receiving repository.
+In a future release, the default of "git push" without further
+arguments will be to push nothing. Currently, it will push all
+matching refspecs to the current remote. A configuration variable
+push.default has been introduced to select the default behaviour. To
+ease the transition, a big warning is issued if this is not configured
+and a git push without arguments is attempted.
+
Updates since v1.6.2
--------------------
diff --git a/builtin-push.c b/builtin-push.c
index b9fe206..7ef499f 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -79,11 +79,11 @@ static const char *warn_unconfigured_push_msg[] = {
"has not configured any push refspecs. The default action in this",
"case has been to push all matching refspecs, that is, all branches",
"that exist both locally and remotely will be updated.",
- "This default may change in the future.",
+ "This default will change in the future.",
"",
"You can specify what action you want to take in this case, and",
"avoid seeing this message again, by configuring 'push.default' to:",
- " 'nothing' : Do not push anythig",
+ " 'nothing' : Do not push anythig (the future default)",
" 'matching' : Push all matching branches (the current default)",
" 'current' : Push the current branch to whatever it is tracking",
""
--
1.6.2.105.g6ff1f.dirty
^ permalink raw reply related
* [PATCH 4/7] git push: Display warning on unconfigured default push
From: Finn Arne Gangstad @ 2009-03-09 22:35 UTC (permalink / raw)
To: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
As a preparation for a possible future "git push" default behaviour change,
display a prominent warning for operations that may change behaviour
in the future. The warning explains for the user how to configure this
permanently so the warning will not be seen again after proper configuration.
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
builtin-push.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/builtin-push.c b/builtin-push.c
index 5706c99..b9fe206 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -74,11 +74,34 @@ static void setup_push_current(struct remote *remote)
branch->merge[n]->src));
}
+static const char *warn_unconfigured_push_msg[] = {
+ "You did not specify any refspecs to push, and the current remote",
+ "has not configured any push refspecs. The default action in this",
+ "case has been to push all matching refspecs, that is, all branches",
+ "that exist both locally and remotely will be updated.",
+ "This default may change in the future.",
+ "",
+ "You can specify what action you want to take in this case, and",
+ "avoid seeing this message again, by configuring 'push.default' to:",
+ " 'nothing' : Do not push anythig",
+ " 'matching' : Push all matching branches (the current default)",
+ " 'current' : Push the current branch to whatever it is tracking",
+ ""
+};
+
+static void warn_unconfigured_push()
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(warn_unconfigured_push_msg); i++)
+ warning("%s", warn_unconfigured_push_msg[i]);
+}
+
static void handle_default_push(struct remote *remote, int *flags)
{
git_config(git_default_config, NULL);
switch (push_default) {
case PUSH_DEFAULT_UNSPECIFIED:
+ warn_unconfigured_push();
/* fallthrough */
case PUSH_DEFAULT_MATCHING:
--
1.6.2.105.g6ff1f.dirty
^ permalink raw reply related
* [PATCH 2/7] New config option push.default
From: Finn Arne Gangstad @ 2009-03-09 22:35 UTC (permalink / raw)
To: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
This option takes effect when no refspec is given explicitly or implicitly
by any of the command line arguments to push, and no refspec is configured
for the current remote. The possible values are:
* nothing - do not push anything
* current - push the current branch to whatever it is tracking
* matching - push all branches that already exist remotely (same name)
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
Documentation/config.txt | 18 ++++++++++++++++++
cache.h | 8 ++++++++
config.c | 23 +++++++++++++++++++++++
environment.c | 1 +
4 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index f5152c5..50bc1d0 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1160,6 +1160,24 @@ pull.octopus::
pull.twohead::
The default merge strategy to use when pulling a single branch.
+push.default::
+ Defines the action git push should take if no refspec is given
+ on the command line, no refspec is configured in the remote, and
+ no refspec is implied by any of the options given on the command
+ line.
+
+ The term `current remote` means the remote configured for the current
+ branch, or `origin` if no remote is configured. `origin` is also used
+ if you are not on any branch.
++
+* `nothing` do not push anything
+* `matching` push all matching branches to the current remote.
+ All branches having the same name in both ends are considered to be
+ matching. This is the default value.
+* `current` push the current branch to the branch it is tracking on
+ the remote
+
+
receive.fsckObjects::
If it is set to true, git-receive-pack will check all received
objects. It will abort in the case of a malformed object or a
diff --git a/cache.h b/cache.h
index 189151d..3a6acb8 100644
--- a/cache.h
+++ b/cache.h
@@ -541,8 +541,16 @@ enum rebase_setup_type {
AUTOREBASE_ALWAYS,
};
+enum push_default_type {
+ PUSH_DEFAULT_UNSPECIFIED = -1,
+ PUSH_DEFAULT_NOTHING = 0,
+ PUSH_DEFAULT_MATCHING,
+ PUSH_DEFAULT_CURRENT,
+};
+
extern enum branch_track git_branch_track;
extern enum rebase_setup_type autorebase;
+extern enum push_default_type push_default;
#define GIT_REPO_VERSION 0
extern int repository_format_version;
diff --git a/config.c b/config.c
index 0c8c76f..12d5a2b 100644
--- a/config.c
+++ b/config.c
@@ -565,6 +565,26 @@ static int git_default_branch_config(const char *var, const char *value)
return 0;
}
+static int git_default_push_config(const char *var, const char *value)
+{
+ if (!strcmp(var, "push.default")) {
+ if (!value)
+ return config_error_nonbool(var);
+ else if (!strcmp(value, "nothing"))
+ push_default = PUSH_DEFAULT_NOTHING;
+ else if (!strcmp(value, "current"))
+ push_default = PUSH_DEFAULT_CURRENT;
+ else if (!strcmp(value, "matching"))
+ push_default = PUSH_DEFAULT_MATCHING;
+ else
+ return error("Malformed value for %s", var);
+ return 0;
+ }
+
+ /* Add other config variables here and to Documentation/config.txt. */
+ return 0;
+}
+
static int git_default_mailmap_config(const char *var, const char *value)
{
if (!strcmp(var, "mailmap.file"))
@@ -588,6 +608,9 @@ int git_default_config(const char *var, const char *value, void *dummy)
if (!prefixcmp(var, "branch."))
return git_default_branch_config(var, value);
+ if (!prefixcmp(var, "push."))
+ return git_default_push_config(var, value);
+
if (!prefixcmp(var, "mailmap."))
return git_default_mailmap_config(var, value);
diff --git a/environment.c b/environment.c
index e278bce..4696885 100644
--- a/environment.c
+++ b/environment.c
@@ -42,6 +42,7 @@ enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
+enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
/* Parallel index stat data preload? */
int core_preload_index = 0;
--
1.6.2.105.g6ff1f.dirty
^ permalink raw reply related
* [PATCH 1/7] remote: Make "-" an alias for the current remote
From: Finn Arne Gangstad @ 2009-03-09 22:35 UTC (permalink / raw)
To: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
This creates a handy alias "-" for the remote of the current branch
(or origin if no such remote exists), which can be used in both
push, pull, fetch and remote to make many tasks easier. E.g.:
git push - HEAD : push the current branch
git remote prune - : prune the current remote
git fetch - next : get the next branch from the current remote
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
remote.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/remote.c b/remote.c
index d7079c6..3a6d002 100644
--- a/remote.c
+++ b/remote.c
@@ -645,7 +645,7 @@ struct remote *remote_get(const char *name)
struct remote *ret;
read_config();
- if (!name)
+ if (!name || !strcmp(name, "-"))
name = default_remote_name;
ret = make_remote(name, 0);
if (valid_remote_nick(name)) {
--
1.6.2.105.g6ff1f.dirty
^ permalink raw reply related
* [RFC/PATCH] git push usability improvements and default change
From: Finn Arne Gangstad @ 2009-03-09 22:35 UTC (permalink / raw)
To: git
Usability improvements:
"-" is now an alias for the current remote (the remote of the current
branch or "origin" as a fallback). This works both for push, fetch,
pull, remote (and possibly some others), creating a lot of nice
shortcuts I think:
git remote prune - : prune the current remote
git push - HEAD : push the current branch to a branch of the same name
git fetch - next : fetch the next branch from the current remote
git push has learned two new command line options --matching and
--current, which override any configuration. 'matching' pushes all
branches that already exist at the remote, while 'current' pushes the
current branch to whatever it is tracking
I chose this behaviour for 'current', since it is the one that I find
most useful, and there seems to be no good way of expressing it from
the command line. Pushing a branch to an identically named branch on
a remote can now easily be done by "git push - HEAD".
Also added a new configuration option push.default, which can have values
"nothing", "matching" and "current". This variable will only be used if
you have not specificed any refspecs at all, no command line options imply
any refspecs, and the current branch has no push configuration.
This is implemented in 1-3
git push default change:
git push will by default push "nothing" instead of "matching".
This is implemented in 4-7. 4-5 are for immediate consumption, 6 is for
next major release (or later), and 7 is even later.
4 Adds a warning if you have not configured push.default
5 Changes the wording to say that the default will change. 4 and 5 can
be applied immediately.
6 changes the deault to "nothing", but keeps the warning.
7 removes the warning entirely
Finn Arne Gangstad (7):
remote: Make "-" an alias for the current remote
New config option push.default
git push: New options --matching and --current
git push: Display warning on unconfigured default push
git push: Document that "nothing" is the future push default
git push: Change default for "git push" to nothing.
git push: Remove warning for "git push" default change
Documentation/RelNotes-1.6.3.txt | 7 +++
Documentation/config.txt | 18 ++++++++
Documentation/git-push.txt | 14 +++++--
builtin-push.c | 84 +++++++++++++++++++++++++++++--------
cache.h | 7 +++
config.c | 23 ++++++++++
environment.c | 1 +
remote.c | 2 +-
transport.h | 9 ++++
9 files changed, 142 insertions(+), 23 deletions(-)
- Finn Arne
^ permalink raw reply
* [PATCH 3/7] git push: New options --matching and --current
From: Finn Arne Gangstad @ 2009-03-09 22:35 UTC (permalink / raw)
To: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
--matching: Push all branches that already exist with the same name in
the remote
--current: Push the current branch to whatever it is tracking
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
Documentation/git-push.txt | 10 +++++-
builtin-push.c | 87 +++++++++++++++++++++++++++++++++++---------
transport.h | 9 +++++
3 files changed, 87 insertions(+), 19 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 4e7e5a7..cb7b3d2 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -9,7 +9,8 @@ git-push - Update remote refs along with associated objects
SYNOPSIS
--------
[verse]
-'git push' [--all | --mirror | --tags] [--dry-run] [--receive-pack=<git-receive-pack>]
+'git push' [--all | --mirror | --tags | --matching | --current]
+ [--dry-run] [--receive-pack=<git-receive-pack>]
[--repo=<repository>] [-f | --force] [-v | --verbose]
[<repository> <refspec>...]
@@ -82,6 +83,13 @@ nor in any Push line of the corresponding remotes file---see below).
if the configuration option `remote.<remote>.mirror` is
set.
+--matching::
+ For every branch on the local side, the remote side is updated if
+ a branch of the same name already exists there.
+
+--current::
+ Push the current branch to the branch it is tracking on the remote.
+
--dry-run::
Do everything except actually send the updates.
diff --git a/builtin-push.c b/builtin-push.c
index 122fdcf..5706c99 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,7 +10,7 @@
#include "parse-options.h"
static const char * const push_usage[] = {
- "git push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git push [--all | --mirror | --current | --matching] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
NULL,
};
@@ -48,6 +48,53 @@ static void set_refspecs(const char **refs, int nr)
}
}
+static const char *make_push_ref(const char *a, const char *b)
+{
+ char *buf = xmalloc(strlen(a) + strlen(b) + 2);
+ strcpy(buf, a);
+ strcat(buf, ":");
+ strcat(buf, b);
+ return buf;
+}
+
+static void setup_push_current(struct remote *remote)
+{
+ int n;
+ struct branch *branch = branch_get(NULL);
+ if (!branch)
+ die("You are not currently on a branch.");
+ if (!branch->merge_nr)
+ die("The current branch %s is not tracking anything.",
+ branch->name);
+ if (branch->remote != remote)
+ die("The current branch is tracking \"%s\", not \"%s\"!",
+ branch->remote->name, remote->name);
+ for (n = 0; n < branch->merge_nr; n++)
+ add_refspec(make_push_ref(branch->name,
+ branch->merge[n]->src));
+}
+
+static void handle_default_push(struct remote *remote, int *flags)
+{
+ git_config(git_default_config, NULL);
+ switch (push_default) {
+ case PUSH_DEFAULT_UNSPECIFIED:
+ /* fallthrough */
+
+ case PUSH_DEFAULT_MATCHING:
+ add_refspec(":");
+ break;
+
+ case PUSH_DEFAULT_CURRENT:
+ setup_push_current(remote);
+ break;
+
+ case PUSH_DEFAULT_NOTHING:
+ die("No refspec given, and none configured.");
+ break;
+ }
+}
+
static int do_push(const char *repo, int flags)
{
int i, errs;
@@ -59,29 +106,29 @@ static int do_push(const char *repo, int flags)
if (remote->mirror)
flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
- if ((flags & TRANSPORT_PUSH_ALL) && refspec) {
+ if ((flags & TRANSPORT_PUSH_MODE_MASK) && refspec) {
if (!strcmp(*refspec, "refs/tags/*"))
- return error("--all and --tags are incompatible");
- return error("--all can't be combined with refspecs");
+ return error("--tags cannot be combined with a push mode");
+ return error("push modes cannot be combined with explicit refspecs");
}
- if ((flags & TRANSPORT_PUSH_MIRROR) && refspec) {
- if (!strcmp(*refspec, "refs/tags/*"))
- return error("--mirror and --tags are incompatible");
- return error("--mirror can't be combined with refspecs");
- }
+ if (HAS_MULTI_BITS(flags & TRANSPORT_PUSH_MODE_MASK))
+ return error("Multiple push modes specified");
- if ((flags & (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) ==
- (TRANSPORT_PUSH_ALL|TRANSPORT_PUSH_MIRROR)) {
- return error("--all and --mirror are incompatible");
- }
+ if (flags & TRANSPORT_PUSH_CURRENT)
+ setup_push_current(remote);
+ else if (flags & TRANSPORT_PUSH_MATCHING)
+ add_refspec(":");
- if (!refspec
- && !(flags & TRANSPORT_PUSH_ALL)
- && remote->push_refspec_nr) {
- refspec = remote->push_refspec;
- refspec_nr = remote->push_refspec_nr;
+ if (!refspec && !(flags & TRANSPORT_PUSH_MODE_MASK)) {
+ if (remote->push_refspec_nr) {
+ refspec = remote->push_refspec;
+ refspec_nr = remote->push_refspec_nr;
+ } else {
+ handle_default_push(remote, &flags);
+ }
}
+
errs = 0;
for (i = 0; i < remote->url_nr; i++) {
struct transport *transport =
@@ -120,6 +167,10 @@ int cmd_push(int argc, const char **argv, const char *prefix)
OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL),
OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
(TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
+ OPT_BIT( 0 , "matching", &flags, "push all matching refs",
+ TRANSPORT_PUSH_MATCHING),
+ OPT_BIT( 0 , "current", &flags, "push current branch",
+ TRANSPORT_PUSH_CURRENT),
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
OPT_BIT( 0 , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE),
diff --git a/transport.h b/transport.h
index 6bbc1a8..b897d0c 100644
--- a/transport.h
+++ b/transport.h
@@ -34,6 +34,15 @@ struct transport {
#define TRANSPORT_PUSH_DRY_RUN 4
#define TRANSPORT_PUSH_MIRROR 8
#define TRANSPORT_PUSH_VERBOSE 16
+#define TRANSPORT_PUSH_MATCHING 32
+#define TRANSPORT_PUSH_CURRENT 64
+/**
+ * All push flags that imply a certain set of refspecs to be pushed must
+ * be combined into TRANSPORT_PUSH_MODE_MASK
+ **/
+#define TRANSPORT_PUSH_MODE_MASK \
+ (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR | TRANSPORT_PUSH_MATCHING | \
+ TRANSPORT_PUSH_CURRENT)
/* Returns a transport suitable for the url */
struct transport *transport_get(struct remote *, const char *);
--
1.6.2.105.g6ff1f.dirty
^ permalink raw reply related
* [PATCH 6/7] git push: Change default for "git push" to nothing.
From: Finn Arne Gangstad @ 2009-03-09 22:35 UTC (permalink / raw)
To: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
Documentation/config.txt | 4 ++--
Documentation/git-push.txt | 4 +---
builtin-push.c | 7 ++++---
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 50bc1d0..437216c 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1170,10 +1170,10 @@ push.default::
branch, or `origin` if no remote is configured. `origin` is also used
if you are not on any branch.
+
-* `nothing` do not push anything
+* `nothing` do not push anything. This is new the default value.
* `matching` push all matching branches to the current remote.
All branches having the same name in both ends are considered to be
- matching. This is the default value.
+ matching. This used to be the default value.
* `current` push the current branch to the branch it is tracking on
the remote
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index cb7b3d2..149c1f0 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -64,9 +64,7 @@ the remote repository.
The special refspec `:` (or `{plus}:` to allow non-fast forward updates)
directs git to push "matching" branches: for every branch that exists on
the local side, the remote side is updated if a branch of the same name
-already exists on the remote side. This is the default operation mode
-if no explicit refspec is found (that is neither on the command line
-nor in any Push line of the corresponding remotes file---see below).
+already exists on the remote side.
--all::
Instead of naming each ref to push, specifies that all
diff --git a/builtin-push.c b/builtin-push.c
index 7ef499f..93f12a8 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -104,6 +104,10 @@ static void handle_default_push(struct remote *remote, int *flags)
warn_unconfigured_push();
/* fallthrough */
+ case PUSH_DEFAULT_NOTHING:
+ die("No refspec given, and none configured.");
+ break;
+
case PUSH_DEFAULT_MATCHING:
add_refspec(":");
break;
@@ -112,9 +116,6 @@ static void handle_default_push(struct remote *remote, int *flags)
setup_push_current(remote);
break;
- case PUSH_DEFAULT_NOTHING:
- die("No refspec given, and none configured.");
- break;
}
}
--
1.6.2.105.g6ff1f.dirty
^ permalink raw reply related
* [PATCH 7/7] git push: Remove warning for "git push" default change
From: Finn Arne Gangstad @ 2009-03-09 22:35 UTC (permalink / raw)
To: git
In-Reply-To: <1236638151-6465-1-git-send-email-finnag@pvv.org>
Signed-off-by: Finn Arne Gangstad <finnag@pvv.org>
---
Documentation/config.txt | 4 ++--
builtin-push.c | 27 ---------------------------
cache.h | 1 -
environment.c | 2 +-
4 files changed, 3 insertions(+), 31 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 437216c..d110edc 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1170,10 +1170,10 @@ push.default::
branch, or `origin` if no remote is configured. `origin` is also used
if you are not on any branch.
+
-* `nothing` do not push anything. This is new the default value.
+* `nothing` do not push anything. This is the default value.
* `matching` push all matching branches to the current remote.
All branches having the same name in both ends are considered to be
- matching. This used to be the default value.
+ matching.
* `current` push the current branch to the branch it is tracking on
the remote
diff --git a/builtin-push.c b/builtin-push.c
index 93f12a8..d0ab76d 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -74,36 +74,10 @@ static void setup_push_current(struct remote *remote)
branch->merge[n]->src));
}
-static const char *warn_unconfigured_push_msg[] = {
- "You did not specify any refspecs to push, and the current remote",
- "has not configured any push refspecs. The default action in this",
- "case has been to push all matching refspecs, that is, all branches",
- "that exist both locally and remotely will be updated.",
- "This default will change in the future.",
- "",
- "You can specify what action you want to take in this case, and",
- "avoid seeing this message again, by configuring 'push.default' to:",
- " 'nothing' : Do not push anythig (the future default)",
- " 'matching' : Push all matching branches (the current default)",
- " 'current' : Push the current branch to whatever it is tracking",
- ""
-};
-
-static void warn_unconfigured_push()
-{
- int i;
- for (i = 0; i < ARRAY_SIZE(warn_unconfigured_push_msg); i++)
- warning("%s", warn_unconfigured_push_msg[i]);
-}
-
static void handle_default_push(struct remote *remote, int *flags)
{
git_config(git_default_config, NULL);
switch (push_default) {
- case PUSH_DEFAULT_UNSPECIFIED:
- warn_unconfigured_push();
- /* fallthrough */
-
case PUSH_DEFAULT_NOTHING:
die("No refspec given, and none configured.");
break;
@@ -115,7 +89,6 @@ static void handle_default_push(struct remote *remote, int *flags)
case PUSH_DEFAULT_CURRENT:
setup_push_current(remote);
break;
-
}
}
diff --git a/cache.h b/cache.h
index 3a6acb8..f3f8e28 100644
--- a/cache.h
+++ b/cache.h
@@ -542,7 +542,6 @@ enum rebase_setup_type {
};
enum push_default_type {
- PUSH_DEFAULT_UNSPECIFIED = -1,
PUSH_DEFAULT_NOTHING = 0,
PUSH_DEFAULT_MATCHING,
PUSH_DEFAULT_CURRENT,
diff --git a/environment.c b/environment.c
index 4696885..6766394 100644
--- a/environment.c
+++ b/environment.c
@@ -42,7 +42,7 @@ enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
-enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
+enum push_default_type push_default = PUSH_DEFAULT_NOTHING;
/* Parallel index stat data preload? */
int core_preload_index = 0;
--
1.6.2.105.g6ff1f.dirty
^ permalink raw reply related
* filter-branch --subdirectory-filter prematurely truncating history?
From: Cap Petschulat @ 2009-03-09 23:08 UTC (permalink / raw)
To: git
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.
Am I expecting filter-branch to do something unreasonable? Is there an
easy way to reconnect the orphaned history? Am I using the wrong tool
for the job?
^ permalink raw reply
* [EGIT PATCH] Make commit amend work when a resource is selected
From: Robin Rosenberg @ 2009-03-09 22:35 UTC (permalink / raw)
To: spearce; +Cc: git, Robin Rosenberg
We previously made it possible to commit when any resource
was selected. Due to the internal workings of the commit
action the patch was not enough to extend this functionality
into the amend mode.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../egit/ui/internal/actions/CommitAction.java | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
index 5996596..03649c6 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/CommitAction.java
@@ -175,7 +175,7 @@ private void performCommit(CommitDialog commitDialog, String commitMessage)
} catch (IOException e) {
throw new TeamException("Committing changes", e);
}
- for (IProject proj : getSelectedProjects()) {
+ for (IProject proj : getProjectsForSelectedResources()) {
RepositoryMapping.getMapping(proj).fireRepositoryChanged();
}
}
@@ -230,7 +230,7 @@ private void prepareTrees(IFile[] selectedItems,
UnsupportedEncodingException {
if (selectedItems.length == 0) {
// amending commit - need to put something into the map
- for (IProject proj : getSelectedProjects()) {
+ for (IProject proj : getProjectsForSelectedResources()) {
Repository repo = RepositoryMapping.getMapping(proj).getRepository();
if (!treeMap.containsKey(repo))
treeMap.put(repo, repo.mapTree(Constants.HEAD));
--
1.6.1.285.g35d8b
^ permalink raw reply related
* [PATCH] Append ampersand to "Target" of lnk files created by do_cygwin_shortcut
From: Phil Lawrence @ 2009-03-09 22:09 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
On Mon, Mar 9, 2009 at 4:12 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> <snip!>
>
> Could you add those explanations to the commit message?
Done:
>From 0780db8d53bdd0bb02b154d23c3c80bcccc0d955 Mon Sep 17 00:00:00 2001
From: Phil Lawrence <prlawrence@gmail.com>
Date: Thu, 5 Mar 2009 17:56:58 -0600
Subject: [PATCH] Append ampersand to "Target" of lnk files created by
do_cygwin_shortcut
The git-gui menu item "Repository | Create Desktop Icon" creates a
shortcut (.lnk file) on the Windows desktop. The purpose of the
created shortcut is to make it easy for a user to launch git-gui
for a particular repo in the future.
A Windows user would expect to see git gui launch when they click
the shortcut; they would not expect (nor want) to see a cmd window
open and remain open in the background.
msysGit avoids opening a command window altogether when it's Git GUI
shortcut is used. Ideally, git on cygwin would also have shortcuts
that simply open the GUI, but as a first step, this change allows
the shell window to politely disappear after starting git gui as a
background process.
Signed-off-by: Phil Lawrence <prlawrence@gmail.com>
---
lib/shortcut.tcl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/shortcut.tcl b/lib/shortcut.tcl
index 38c3151..2f20eb3 100644
--- a/lib/shortcut.tcl
+++ b/lib/shortcut.tcl
@@ -54,7 +54,7 @@ proc do_cygwin_shortcut {} {
$argv0]
win32_create_lnk $fn [list \
$sh -c \
- "CHERE_INVOKING=1 source
/etc/profile;[sq $me]" \
+ "CHERE_INVOKING=1 source
/etc/profile;[sq $me] &" \
] \
[file dirname [file normalize [gitdir]]]
} err]} {
--
1.6.1.9.g97c34
Phil Lawrence
^ permalink raw reply related
* Re: [RFC PATCH] git-svn does not support intermediate directories?
From: Eric Wong @ 2009-03-09 21:54 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Michael Lai
In-Reply-To: <21fc26450903091402u60d6cfcepd67ba7510af8f4a3@mail.gmail.com>
Michael Lai <myllai@gmail.com> wrote:
> > Your patch was whitespace damaged and lacked a proposed commit message.
> > Please read Documentation/SubmittingPatches next time.
> Hey Eric,
>
> Sorry, I didn't notice that; I've read through it and hopefully my
> patches should conform from now on.
>
> >
> > Anyhow, I fixed your patch up a bit. Can you sign-off on it
> > if its right to you or let me know if it's broken? Thanks.
>
> I looked through the patch and that would work, but at the same time I
> had another idea which may be a little cleaner. Let me know what you
> think.
Thanks Michael, looks good to me,
Acked and pushed out to git://git.bogomips.org/git-svn
> From ae38acf85cfc86c075578c1c3f3c204d91d1d1f4 Mon Sep 17 00:00:00 2001
> From: Michael Lai <myllai@gmail.com>
> Date: Mon, 9 Mar 2009 11:45:47 -0700
> Subject: [PATCH] git-svn: support intermediate paths when matching tags/branches
>
> For repositories laid out like the following:
>
> [svn-remote "svn"]
> url = http://foo.com/svn/repos/bar
> fetch = myproject/trunk:refs/remotes/trunk
> branches = bar/myproject/branches/*:refs/remotes/*
> tags = bar/myproject/tags/*:refs/remotes/tags/*
>
> The "bar" component above is considered the intermediate path
> and was not handled correctly.
>
> Signed-off-by: Michael Lai <myllai@gmail.com>
> ---
> git-svn.perl | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index 959eb52..8be6be0 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2351,7 +2351,10 @@ sub match_paths {
> if (my $path = $paths->{"/$self->{path}"}) {
> return ($path->{action} eq 'D') ? 0 : 1;
> }
> - $self->{path_regex} ||= qr/^\/\Q$self->{path}\E\//;
> + my $repos_root = $self->ra->{repos_root};
> + my $extended_path = $self->{url} . '/' . $self->{path};
> + $extended_path =~ s#^\Q$repos_root\E(/|$)##;
> + $self->{path_regex} ||= qr/^\/\Q$extended_path\E\//;
> if (grep /$self->{path_regex}/, keys %$paths) {
> return 1;
> }
> --
> 1.6.2
^ permalink raw reply
* Re: [PATCH 2/3] config: set help text for --bool-or-int
From: Felipe Contreras @ 2009-03-09 21:50 UTC (permalink / raw)
To: Jeff King; +Cc: git, Junio C Hamano
In-Reply-To: <20090307224807.GA18548@coredump.intra.peff.net>
On Sun, Mar 8, 2009 at 12:48 AM, Jeff King <peff@peff.net> wrote:
> On Sat, Mar 07, 2009 at 11:07:46PM +0200, Felipe Contreras wrote:
>
>> On Sat, Mar 7, 2009 at 7:14 PM, Jeff King <peff@peff.net> wrote:
>> > The conversion to parse_opt left this as NULL; on glibc
>> > systems, the usage message prints
>> >
>> > --bool-or-int (null)
>> >
>> > and on other ones, segfaults.
>>
>> Shouldn't then OPT_BIT make sure there is no crash?
>
> Perhaps, but it doesn't (and I assume you mean usage_with_help, as
> OPT_BIT is just filling in the struct). It's not clear what a NULL help
> parameter should do, though. Hide the option? Show no help description?
> There are already ways to accomplish both of those.
Yeah, I meant usage_with_help. I don't know what should be done, but I
think two things should be achieved:
a) don't crash
b) encourage the options to always have a description
Perhaps not showing the option at all, or perhaps showing "**EMPTY**".
>> I was surprised when it didn't complain. I thought on making it "" but
>> I wanted to make it visible that there was no documentation for that,
>> which is the reason I left it that way.
>
> OK. I think there are really valid options:
>
> 1. it's there with a description (which is what my patch does)
>
> 2. it's there without a description, because it's obvious what it does
> coming after --bool and --int
I don't think it's obvious, that partly why I didn't fill the description.
> 3. it's hidden
>
> I really don't care which. But what is there now is broken.
Definitely, your patch must be applied ASAP.
Minor nitpick: "value is interpreted either as bool or int"
The value is what it is, the --boo-or-int option doesn't change the
value, just how it is interpreted.
--
Felipe Contreras
^ permalink raw reply
* Re: [PATCH] git-gui: Append ampersand to Target of lnk files created by do_cygwin_shortcut.
From: Johannes Schindelin @ 2009-03-09 21:12 UTC (permalink / raw)
To: Phil Lawrence; +Cc: git
In-Reply-To: <530ac78e0903091357v248895ack63588ae6e5e6b57a@mail.gmail.com>
Hi,
On Mon, 9 Mar 2009, Phil Lawrence wrote:
> On Mon, Mar 9, 2009 at 3:13 PM, Johannes Schindelin wrote:
>
> > Now, with the technical stuff out of the way: are you not changing
> > behavior? It seems that Linux users expect an program called by a
> > menu item to block the application until the program returns, so that
> > an error can be caught.
>
> The menu item in question is "Repository | Create Desktop Icon". It
> does not launch a program, but rather creates a shortcut (.lnk file)
> on the Windows desktop.
>
> The purpose of the created shortcut is to make it easy for a user to
> launch git-gui for a particular repo in the future.
>
> > Maybe the expectation is different on Windows? But then, we'd still like
> > to catch errors and warn the user about it, right?
>
> I believe a windows user would expect to see git gui launch when they
> click the shortcut; they would not expect (nor want) to see a cmd
> window open and remain open in the background.
>
> msysGit avoids opening a command window altogether when it's Git GUI
> shortcut is used. Ideally git on cygwin would also have shortcuts
> that simply open the GUI, but as a first step I saw we could at least
> make the command window politely disappear.
Thank you!
Could you add those explanations to the commit message?
Thanks,
Dscho
^ permalink raw reply
* Re: [EGIT PATCH] Prevent an exception if the user tries to push a non-existing ref.
From: Robin Rosenberg @ 2009-03-09 21:29 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Daniel Cheng, git
In-Reply-To: <20090309155049.GE11989@spearce.org>
måndag 09 mars 2009 16:50:49 skrev "Shawn O. Pearce" <spearce@spearce.org>:
> After reading that code again, I'm tempted to apply this instead.
> Its a much larger patch, but I think the result is a lot easier
> to follow.
I wouldn't say "a lot", but a little perhaps.
-- robin
^ permalink raw reply
* Re: [PATCH 2/2] grep Added --blame so that grep can show result tagged with blame entries
From: René Scharfe @ 2009-03-09 21:22 UTC (permalink / raw)
To: pi song; +Cc: git, gitster
In-Reply-To: <49B517A3.9050209@gmail.com>
pi song schrieb:
> This part:-
> 1) Implementation & man for grep --blame option
I read the list via Gmane and I can't find patch 1/2. But if this here
is part 1, perhaps there is no "1/2"?
>
> Signed-off-by: Pi Song <pi.songs@gmail.com>
> ---
> Documentation/git-grep.txt | 5 ++
> builtin-grep.c | 10 ++++-
> grep.c | 98
> ++++++++++++++++++++++++++++++++++++-------
> grep.h | 1 +
> 4 files changed, 96 insertions(+), 18 deletions(-)
>
> diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
> index 553da6c..23dae7f 100644
> --- a/Documentation/git-grep.txt
> +++ b/Documentation/git-grep.txt
> @@ -18,6 +18,7 @@ SYNOPSIS
> [-z | --null]
> [-c | --count] [--all-match]
> [-A <post-context>] [-B <pre-context>] [-C <context>]
> + [-b | --blame ]
Your mailer seems to have butchered all tabs. There is a paragraph in
Documentation/SubmittingPatches about Gmail; seeing your email address I
think it might interest you.
> [-f <file>] [-e] <pattern>
> [--and|--or|--not|(|)|-e <pattern>...] [<tree>...]
> [--] [<path>...]
> @@ -105,6 +106,10 @@ OPTIONS
> Instead of showing every matched line, show the number of
> lines that match.
>
> +-b::
> +--blame::
> + Show blame of every matched line and context
> +
Sounds interesting and useful.
> -[ABC] <context>::
> Show `context` trailing (`A` -- after), or leading (`B`
> -- before), or both (`C` -- context) lines, and place a
> diff --git a/builtin-grep.c b/builtin-grep.c
> index 3f12ba3..c6cffa0 100644
> --- a/builtin-grep.c
> +++ b/builtin-grep.c
> @@ -630,6 +630,11 @@ int cmd_grep(int argc, const char **argv, const
> char *prefix)
> opt.word_regexp = 1;
> continue;
> }
> + if (!strcmp("-b", arg) ||
> + !strcmp("--blame", arg)) {
> + opt.include_blame = 1;
> + continue;
> + }
> if (!prefixcmp(arg, "-A") ||
> !prefixcmp(arg, "-B") ||
> !prefixcmp(arg, "-C") ||
> diff --git a/grep.c b/grep.c
> index 062b2b6..0514384 100644
> --- a/grep.c
> +++ b/grep.c
> @@ -1,3 +1,4 @@
> +#include "blame.h"
> #include "cache.h"
> #include "grep.h"
> #include "xdiff-interface.h"
> @@ -252,14 +253,17 @@ static int word_char(char ch)
> }
>
> static void show_line(struct grep_opt *opt, const char *bol, const char
> *eol,
> - const char *name, unsigned lno, char sign)
> + const char *name, unsigned lno, char sign,
> + char sign2, char* suspect)
> {
> if (opt->null_following_name)
> sign = '\0';
> if (opt->pathname)
> printf("%s%c", name, sign);
> + if ((opt->include_blame) && (suspect!=NULL))
> + printf("%s%c", suspect);
> if (opt->linenum)
> - printf("%d%c", lno, sign);
> + printf("%d%c", lno, sign2);
> printf("%.*s\n", (int)(eol-bol), bol);
> }
Please be aware of recent changes to that code to add match coloring (in
next and pu). Could you please rebase your changes on top of next?
>
> @@ -442,6 +446,14 @@ static int match_line(struct grep_opt *opt, char
> *bol, char *eol,
> return 0;
> }
>
> +static int setup_revision_by_revId(char *revId, struct rev_info *revs)
> +{
> + const char *args[] = {"grep", revId};
> + init_revisions(revs, NULL);
> + setup_revisions(2, args, revs, NULL);
> + return 1 ;
> +};
> +
> static int grep_buffer_1(struct grep_opt *opt, const char *name,
> char *buf, unsigned long size, int collect_hits)
> {
> @@ -457,6 +469,7 @@ static int grep_buffer_1(struct grep_opt *opt, const
> char *name,
> int binary_match_only = 0;
> const char *hunk_mark = "";
> unsigned count = 0;
> + int blame_calculated = 0 ;
> enum grep_context ctx = GREP_CONTEXT_HEAD;
>
> if (buffer_is_binary(buf, size)) {
> @@ -477,6 +490,8 @@ static int grep_buffer_1(struct grep_opt *opt, const
> char *name,
> if (opt->pre_context || opt->post_context)
> hunk_mark = "--\n";
>
> + /* List of blame tags */
> + struct blame_tag *blame_tags = NULL;
Please put declarations at the start of a block to make the code
compatible with older (non-C99) compilers.
> while (left) {
> char *eol, ch;
> int hit;
> @@ -505,6 +520,35 @@ static int grep_buffer_1(struct grep_opt *opt,
> const char *name,
> return 0;
> goto next_line;
> }
> +
> + /* Calculate blame if necessary */
> + if (hit && opt->include_blame && !blame_calculated)
> + {
Style:
if (condition) {
> + struct blame_stat blame_stat ;
> + struct rev_info revs;
> + char filename[128] ;
> + char revId[41] ;
> + char *splitterPtr ;
> + + if ((splitterPtr=strstr(name,
> ":")) != NULL)
> + {
> + strcpy(filename, splitterPtr + 1) ;
> + strncpy(revId, name, splitterPtr - name) ;
> + revId[40] = '\0' ;
> + setup_revision_by_revId(revId, &revs) ;
> + }
> + else
> + {
Style:
} else {
> + const char *args[] = {};
> + strcpy(filename, name) ;
> + init_revisions(&revs, NULL);
> + setup_revisions(0, args, &revs, NULL);
> + }
> +
> + blame_tags = retrieve_blame_tags(&revs,
> &blame_stat, filename) ;
retrieve_blame_tags() doesn't exist currently, so I guess it is
introduced in patch 1/2.
> + blame_calculated = 1 ;
> + }
> +
> if (hit) {
> count++;
> if (opt->status_only)
> @@ -533,30 +577,47 @@ static int grep_buffer_1(struct grep_opt *opt,
> const char *name,
> from = last_shown + 1;
> if (last_shown && from != last_shown + 1)
> fputs(hunk_mark, stdout);
> - while (from < lno) {
> +
> + /* This prints the precontext*/
> + while (from < lno)
> + {
Style:
while (condition) {
> pcl = &prev[lno-from-1];
> show_line(opt, pcl->bol, pcl->eol,
> - name, from, '-');
> + name, from, ':', '-',
> + blame_tags==NULL?
> + NULL:
> blame_tags[from-1].author);
> from++;
> }
> last_shown = lno-1;
> }
> if (last_shown && lno != last_shown + 1)
> fputs(hunk_mark, stdout);
> - if (!opt->count)
> - show_line(opt, bol, eol, name, lno, ':');
> +
> + if (!opt->count) {
> + /* The matching line */
> + show_line(opt, bol, eol, name, lno,
> + ':', ':',
> + blame_tags==NULL?
> + NULL:blame_tags[lno-1].author);
> + }
> + last_shown = last_hit = lno;
> }
> - else if (last_hit &&
> - lno <= last_hit + opt->post_context) {
> - /* If the last hit is within the post context,
> - * we need to show this line.
> - */
> - if (last_shown && lno != last_shown + 1)
> - fputs(hunk_mark, stdout);
> - show_line(opt, bol, eol, name, lno, '-');
> - last_shown = lno;
> - }
> + else if (last_hit && lno <= last_hit + opt->post_context)
> + {
> + /* If the last hit is within the post context,
> + * we need to show this line.
> + */
> + if (last_shown && lno != last_shown + 1)
> + fputs(hunk_mark, stdout);
> +
> + show_line(opt, bol, eol, name, lno, ':', '-',
> + blame_tags==NULL?
> + NULL:blame_tags[lno-1].author);
> + + last_shown = lno;
> + }
> +
> if (opt->pre_context) {
> memmove(prev+1, prev,
> (opt->pre_context-1) * sizeof(*prev));
> @@ -572,6 +633,11 @@ static int grep_buffer_1(struct grep_opt *opt,
> const char *name,
> lno++;
> }
>
> + if (blame_calculated)
> + {
> + free(blame_tags) ;
> + }
> +
Style:
if (condition)
single_line_expression;
> free(prev);
> if (collect_hits)
> return 0;
> diff --git a/grep.h b/grep.h
> index 5102ce3..2e12e03 100644
> --- a/grep.h
> +++ b/grep.h
> @@ -79,6 +79,7 @@ struct grep_opt {
> int regflags;
> unsigned pre_context;
> unsigned post_context;
> + unsigned include_blame;
> };
>
> extern void append_grep_pattern(struct grep_opt *opt, const char *pat,
> const char *origin, int no, enum grep_pat_token t);
^ permalink raw reply
* Re: [RFC PATCH] git push: Push nothing if no refspecs are given or configured
From: Jeff King @ 2009-03-09 21:10 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Markus Heidelberg, git
In-Reply-To: <alpine.DEB.1.00.0903092148040.6358@intel-tinevez-2-302>
On Mon, Mar 09, 2009 at 09:48:31PM +0100, Johannes Schindelin wrote:
> > > The two spaces after the full stop were not actually a typo.
> >
> > What's its purpose? Just recently I added "set nojoinspaces" to my
> > .vimrc to not insert two spaces when joining sentences.
>
> It was explained to me as "English grammar". Two spaces after a full
> stop.
It's not grammar, but rather a typographical convention dating to
monospaced print fonts. It's mostly outdated these days for computer
input, as markup languages will put in the "right" amount of space
automatically (e.g., one and two spaces after a period are equivalent in
both TeX and HTML) and proportional fonts and justification mean your
spacing isn't standard, anyway. So as a rule, it seems to be dying out.
You can google "two spaces after period" to see the ensuing flamewars.
In this particular instance, we consider the pre-markup version
something readable (since that is the point of asciidoc), and people
will tend to view it in a monospaced fonts. So it at least makes a
difference here (and you can then have a flamewar about how it looks).
-Peff
^ permalink raw reply
* Re: [RFC PATCH] git push: Push nothing if no refspecs are given or configured
From: Markus Heidelberg @ 2009-03-09 21:10 UTC (permalink / raw)
To: Johannes Schindelin
Cc: Finn Arne Gangstad, git, John Tapsell, Andreas Ericsson
In-Reply-To: <alpine.DEB.1.00.0903092148040.6358@intel-tinevez-2-302>
Johannes Schindelin, 09.03.2009:
> Hi,
>
> On Mon, 9 Mar 2009, Markus Heidelberg wrote:
>
> > Johannes Schindelin, 06.03.2009:
> > > > -already exists on the remote side. This is the default operation mode
> > > > +already exists on the remote side. Nothing will be pushed
> > >
> > > The two spaces after the full stop were not actually a typo.
> >
> > What's its purpose? Just recently I added "set nojoinspaces" to my
> > .vimrc to not insert two spaces when joining sentences.
>
> It was explained to me as "English grammar". Two spaces after a full
> stop.
I should have tried searching, I didn't think I'd get useful results
with "two spaces after sentence" as search item, but I did.
http://en.wikipedia.org/wiki/Full_stop#Spacing_after_full_stop
Two spaces between sentences. But no space between
text and the dash---strange.
Markus
^ permalink raw reply
* Re: [PATCH] git-gui: Append ampersand to Target of lnk files created by do_cygwin_shortcut.
From: Phil Lawrence @ 2009-03-09 20:57 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <alpine.DEB.1.00.0903092109360.6358@intel-tinevez-2-302>
On Mon, Mar 9, 2009 at 3:13 PM, Johannes Schindelin wrote:
> Hi,
>
> <snip!>
>
> A few comments.
>
> Usually we try to use that subject as the subject of the mail, and we also
> try to keep the subject shorter than 77 characters (so that "git log" on
> an 80-column display does not need to wrap lines).
> Also, we like authors to provide Signed-off-by: lines.
OK, thank you.
> Now, with the technical stuff out of the way: are you not changing
> behavior? It seems that Linux users expect an program called by a menu
> item to block the application until the program returns, so that an error
> can be caught.
The menu item in question is "Repository | Create Desktop Icon". It
does not launch a program, but rather creates a shortcut (.lnk file)
on the Windows desktop.
The purpose of the created shortcut is to make it easy for a user to
launch git-gui for a particular repo in the future.
> Maybe the expectation is different on Windows? But then, we'd still like
> to catch errors and warn the user about it, right?
I believe a windows user would expect to see git gui launch when they
click the shortcut; they would not expect (nor want) to see a cmd
window open and remain open in the background.
msysGit avoids opening a command window altogether when it's Git GUI
shortcut is used. Ideally git on cygwin would also have shortcuts
that simply open the GUI, but as a first step I saw we could at least
make the command window politely disappear.
Phil Lawrence
^ permalink raw reply
* Re: [RFC PATCH] git-svn does not support intermediate directories?
From: Michael Lai @ 2009-03-09 21:02 UTC (permalink / raw)
To: Eric Wong; +Cc: git
In-Reply-To: <20090308044318.GA31205@untitled>
> Your patch was whitespace damaged and lacked a proposed commit message.
> Please read Documentation/SubmittingPatches next time.
Hey Eric,
Sorry, I didn't notice that; I've read through it and hopefully my
patches should conform from now on.
>
> Anyhow, I fixed your patch up a bit. Can you sign-off on it
> if its right to you or let me know if it's broken? Thanks.
I looked through the patch and that would work, but at the same time I
had another idea which may be a little cleaner. Let me know what you
think.
From ae38acf85cfc86c075578c1c3f3c204d91d1d1f4 Mon Sep 17 00:00:00 2001
From: Michael Lai <myllai@gmail.com>
Date: Mon, 9 Mar 2009 11:45:47 -0700
Subject: [PATCH] git-svn: support intermediate paths when matching tags/branches
For repositories laid out like the following:
[svn-remote "svn"]
url = http://foo.com/svn/repos/bar
fetch = myproject/trunk:refs/remotes/trunk
branches = bar/myproject/branches/*:refs/remotes/*
tags = bar/myproject/tags/*:refs/remotes/tags/*
The "bar" component above is considered the intermediate path
and was not handled correctly.
Signed-off-by: Michael Lai <myllai@gmail.com>
---
git-svn.perl | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 959eb52..8be6be0 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2351,7 +2351,10 @@ sub match_paths {
if (my $path = $paths->{"/$self->{path}"}) {
return ($path->{action} eq 'D') ? 0 : 1;
}
- $self->{path_regex} ||= qr/^\/\Q$self->{path}\E\//;
+ my $repos_root = $self->ra->{repos_root};
+ my $extended_path = $self->{url} . '/' . $self->{path};
+ $extended_path =~ s#^\Q$repos_root\E(/|$)##;
+ $self->{path_regex} ||= qr/^\/\Q$extended_path\E\//;
if (grep /$self->{path_regex}/, keys %$paths) {
return 1;
}
--
1.6.2
>
> From cddc7e5bde060eb963534156ae0daaf41c87c21a Mon Sep 17 00:00:00 2001
> From: Eric Wong <normalperson@yhbt.net>
> Date: Sat, 7 Mar 2009 20:22:29 -0800
> Subject: [PATCH] git-svn: support intermediate paths when matching tags/branches
> MIME-Version: 1.0
> Content-Type: text/plain; charset=utf-8
> Content-Transfer-Encoding: 8bit
>
> For repositories laid out like the following:
>
>> [svn-remote "svn"]
>> url = http://foo.com/svn/repos/bar
>> fetch = myproject/trunk:refs/remotes/trunk
>> branches = bar/myproject/branches/*:refs/remotes/*
>> tags = bar/myproject/tags/*:refs/remotes/tags/*
>
> The "bar" component above is considered the intermediate path
> and was not handled correctly.
>
> This patch was originally by Michael Lai (without a commit
> message) with some minor fixes:
>
> * extraneous slash removed from $intermediate_path,
> this was causing tests to fail.
>
> * fixed a case where $intermediate_path could be "0" and
> considered false by Perl, preventing the necessary
> slash from being appended.
>
> Signed-off-by: Eric Wong <normalperson@yhbt.net>
> ---
> git-svn.perl | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index 959eb52..745dd03 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2351,7 +2351,11 @@ sub match_paths {
> if (my $path = $paths->{"/$self->{path}"}) {
> return ($path->{action} eq 'D') ? 0 : 1;
> }
> - $self->{path_regex} ||= qr/^\/\Q$self->{path}\E\//;
> + my $repos_root = $self->ra->{repos_root};
> + my $intermediate_path = $self->{url};
> + $intermediate_path =~ s#^\Q$repos_root\E(/|$)##;
> + $intermediate_path .= '/' if length($intermediate_path) > 0;
> + $self->{path_regex} ||= qr/^\/\Q$intermediate_path$self->{path}\E\//;
> if (grep /$self->{path_regex}/, keys %$paths) {
> return 1;
> }
> --
> Eric Wong
>
^ permalink raw reply related
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