* [PATCH 4/4] push: allow configuring default for --show-subjects
From: Owen Taylor @ 2009-09-13 23:31 UTC (permalink / raw)
To: git; +Cc: Owen W. Taylor
In-Reply-To: <1252884685-9169-4-git-send-email-otaylor@redhat.com>
From: Owen W. Taylor <otaylor@fishsoup.net>
A new configuration variable push.show-subjects sets the default
behavior for whether 'git push' should show a commit synopsis with
each updated ref.
Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
---
Documentation/config.txt | 4 ++++
builtin-push.c | 2 ++
cache.h | 1 +
config.c | 4 ++++
environment.c | 1 +
5 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 3bb632f..83bc5a5 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1320,6 +1320,10 @@ push.default::
* `tracking` push the current branch to its upstream branch.
* `current` push the current branch to a branch of the same name.
+push.show-subjects::
+ If set to true, linkgit:git-push[1] will act as if the --show-subjects
+ option was passed, unless overriden with --no-show-subjects.
+
rebase.stat::
Whether to show a diffstat of what changed upstream since the last
rebase. False by default.
diff --git a/builtin-push.c b/builtin-push.c
index 7c9e394..e3dc579 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -197,6 +197,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
if (push_confirm)
flags |= TRANSPORT_PUSH_CONFIRM;
+ if (push_show_subjects)
+ flags |= TRANSPORT_PUSH_SHOW_SUBJECTS;
argc = parse_options(argc, argv, prefix, options, push_usage, 0);
diff --git a/cache.h b/cache.h
index ef8606d..9e6a1e6 100644
--- a/cache.h
+++ b/cache.h
@@ -559,6 +559,7 @@ extern enum branch_track git_branch_track;
extern enum rebase_setup_type autorebase;
extern enum push_default_type push_default;
extern int push_confirm;
+extern int push_show_subjects;
enum object_creation_mode {
OBJECT_CREATION_USES_HARDLINKS = 0,
diff --git a/config.c b/config.c
index 1bc8e6f..bc78876 100644
--- a/config.c
+++ b/config.c
@@ -597,6 +597,10 @@ static int git_default_push_config(const char *var, const char *value)
}
return 0;
}
+ if (!strcmp(var, "push.show-subjects")) {
+ push_show_subjects = git_config_bool(var, value);
+ return 0;
+ }
/* Add other config variables here and to Documentation/config.txt. */
return 0;
diff --git a/environment.c b/environment.c
index e1c82b9..303c54f 100644
--- a/environment.c
+++ b/environment.c
@@ -46,6 +46,7 @@ enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
int push_confirm;
enum push_default_type push_default = PUSH_DEFAULT_MATCHING;
+int push_show_subjects;
#ifndef OBJECT_CREATION_MODE
#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
#endif
--
1.6.2.5
^ permalink raw reply related
* [PATCH 3/4] push: add --show-subjects option to show commit synopsis
From: Owen Taylor @ 2009-09-13 23:31 UTC (permalink / raw)
To: git; +Cc: Owen W. Taylor
In-Reply-To: <1252884685-9169-3-git-send-email-otaylor@redhat.com>
From: Owen W. Taylor <otaylor@fishsoup.net>
When --show-subjects is specified, include a synopsis of added
and removed with each OK or REJECT_NONFASTFORWARD reference update.
(The code for printing the synposis is borrowed and adapted from
builtin-fmt-merge-msg.c)
Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
---
Documentation/git-push.txt | 4 +
builtin-push.c | 3 +-
transport.c | 174 +++++++++++++++++++++++++++++++++++++++++---
transport.h | 1 +
4 files changed, 171 insertions(+), 11 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index c0bbf16..c9fd033 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -142,6 +142,10 @@ useful if you write an alias or script around 'git-push'.
--verbose::
Run verbosely.
+--show-subjects::
+ When displaying ref updates, include a synopsis of what
+ commits are being added and removed.
+
include::urls-remotes.txt[]
OUTPUT
diff --git a/builtin-push.c b/builtin-push.c
index 63a0bb0..7c9e394 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] [--confirm] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git push [--all | --mirror] [--dry-run] [--confirm] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [--show-subjects] [<repository> <refspec>...]",
NULL,
};
@@ -177,6 +177,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
struct option options[] = {
OPT_BIT('q', "quiet", &flags, "be quiet", TRANSPORT_PUSH_QUIET),
OPT_BIT('v', "verbose", &flags, "be verbose", TRANSPORT_PUSH_VERBOSE),
+ OPT_BIT(0, "show-subjects", &flags, "show commit subjects", TRANSPORT_PUSH_SHOW_SUBJECTS),
OPT_STRING( 0 , "repo", &repo, "repository", "repository"),
OPT_BIT( 0 , "all", &flags, "push all refs", TRANSPORT_PUSH_ALL),
OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
diff --git a/transport.c b/transport.c
index aa1852d..c07291e 100644
--- a/transport.c
+++ b/transport.c
@@ -1,4 +1,6 @@
#include "cache.h"
+#include "commit.h"
+#include "diff.h"
#include "transport.h"
#include "run-command.h"
#include "pkt-line.h"
@@ -8,6 +10,7 @@
#include "bundle.h"
#include "dir.h"
#include "refs.h"
+#include "revision.h"
/* rsync support */
@@ -619,7 +622,151 @@ static const char *status_abbrev(unsigned char sha1[20])
return find_unique_abbrev(sha1, DEFAULT_ABBREV);
}
-static void print_ok_ref_status(struct ref *ref, int porcelain)
+struct list {
+ char **list;
+ unsigned nr, alloc;
+};
+
+static void append_to_list(struct list *list, char *value)
+{
+ if (list->nr == list->alloc) {
+ list->alloc += 32;
+ list->list = xrealloc(list->list, sizeof(char *) * list->alloc);
+ }
+ list->list[list->nr++] = value;
+}
+
+static void free_list(struct list *list)
+{
+ int i;
+
+ if (list->alloc == 0)
+ return;
+
+ for (i = 0; i < list->nr; i++) {
+ free(list->list[i]);
+ }
+ free(list->list);
+ list->nr = list->alloc = 0;
+}
+
+static void shortlog(struct commit *from, struct commit *to,
+ const char *heading, int limit)
+{
+ struct rev_info rev;
+ int i, count = 0;
+ struct commit *commit;
+ struct list subjects = { NULL, 0, 0 };
+ int flags = UNINTERESTING | TREESAME | SEEN | SHOWN | ADDED;
+ const char *prefix;
+
+ init_revisions(&rev, NULL);
+ rev.commit_format = CMIT_FMT_ONELINE;
+ rev.limited = 1;
+ rev.ignore_merges = 0;
+
+ setup_revisions(0, NULL, &rev, NULL);
+
+ add_pending_object(&rev, &from->object, "");
+ add_pending_object(&rev, &to->object, "");
+ from->object.flags |= UNINTERESTING;
+ if (prepare_revision_walk(&rev))
+ die("revision walk setup failed");
+ while ((commit = get_revision(&rev)) != NULL) {
+ char *oneline, *bol, *eol;
+
+ count++;
+ if (subjects.nr > limit)
+ continue;
+
+ bol = strstr(commit->buffer, "\n\n");
+ if (bol) {
+ unsigned char c;
+ do {
+ c = *++bol;
+ } while (isspace(c));
+ if (!c)
+ bol = NULL;
+ }
+
+ if (!bol) {
+ append_to_list(&subjects, xstrdup(sha1_to_hex(commit->object.sha1)));
+ continue;
+ }
+
+ eol = strchr(bol, '\n');
+ if (eol) {
+ oneline = xmemdupz(bol, eol - bol);
+ } else {
+ oneline = xstrdup(bol);
+ }
+ append_to_list(&subjects, oneline);
+ }
+
+ if (heading || count > limit) {
+ fprintf(stderr, " ");
+ if (heading)
+ fprintf(stderr, "%s", heading);
+ if (heading && count > limit)
+ fprintf(stderr, " (%d)", count);
+ else if (count > limit)
+ fprintf(stderr, "%d commits", count);
+ fprintf(stderr, ":\n");
+ prefix = " ";
+ } else {
+ prefix = " ";
+ }
+
+ for (i = 0; i < count && i < limit; i++)
+ if (i == limit - 1 && count > limit)
+ fprintf(stderr, "%s...\n", prefix);
+ else
+ fprintf(stderr, "%s%s\n", prefix, subjects.list[i]);
+
+ clear_commit_marks(from, flags);
+ clear_commit_marks(to, flags);
+ free_commit_list(rev.commits);
+ rev.commits = NULL;
+ rev.pending.nr = 0;
+
+ free_list(&subjects);
+}
+
+/* Maximum lines number of subjects to show (including ...) */
+#define SUBJECTS_LIMIT 8
+
+static void print_subjects(struct ref *ref)
+{
+ struct commit *old;
+ struct commit *new;
+ struct commit_list *merge_bases;
+ int added = 1;
+ int removed = 1;
+
+ old = lookup_commit_reference_gently(ref->old_sha1, 1);
+ if (!old) {
+ fprintf(stderr, " Unknown changes (please run 'git fetch')\n");
+ return;
+ }
+ new = lookup_commit_reference(ref->new_sha1);
+
+ merge_bases = get_merge_bases(old, new, 1);
+ if (merge_bases && !merge_bases->next && merge_bases->item == old)
+ removed = 0;
+ if (merge_bases && !merge_bases->next && merge_bases->item == new)
+ added = 0;
+
+ if (added && !removed) {
+ shortlog(old, new, NULL, SUBJECTS_LIMIT);
+ } else {
+ if (added)
+ shortlog(old, new, "Added commits", SUBJECTS_LIMIT);
+ if (removed)
+ shortlog(new, old, "Removed commits", SUBJECTS_LIMIT);
+ }
+}
+
+static void print_ok_ref_status(struct ref *ref, int porcelain, int show_subjects)
{
if (ref->deletion)
print_ref_status('-', "[deleted]", ref, NULL, NULL, porcelain);
@@ -646,10 +793,13 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
strcat(quickref, status_abbrev(ref->new_sha1));
print_ref_status(type, quickref, ref, ref->peer_ref, msg, porcelain);
+
+ if (show_subjects)
+ print_subjects(ref);
}
}
-static int print_one_push_status(struct ref *ref, const char *dest, int count, int porcelain)
+static int print_one_push_status(struct ref *ref, const char *dest, int count, int show_subjects, int porcelain)
{
if (!count)
fprintf(stderr, "To %s\n", dest);
@@ -669,6 +819,8 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count, i
case REF_STATUS_REJECT_NONFASTFORWARD:
print_ref_status('!', "[rejected]", ref, ref->peer_ref,
"non-fast forward", porcelain);
+ if (show_subjects)
+ print_subjects(ref);
break;
case REF_STATUS_REMOTE_REJECT:
print_ref_status('!', "[remote rejected]", ref,
@@ -681,7 +833,7 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count, i
"remote failed to report status", porcelain);
break;
case REF_STATUS_OK:
- print_ok_ref_status(ref, porcelain);
+ print_ok_ref_status(ref, porcelain, show_subjects);
break;
}
@@ -689,7 +841,7 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count, i
}
static void print_push_status(const char *dest, struct ref *refs,
- int verbose, int porcelain, int * nonfastforward)
+ int verbose, int show_subjects, int porcelain, int * nonfastforward)
{
struct ref *ref;
int n = 0;
@@ -697,19 +849,19 @@ static void print_push_status(const char *dest, struct ref *refs,
if (verbose) {
for (ref = refs; ref; ref = ref->next)
if (ref->status == REF_STATUS_UPTODATE)
- n += print_one_push_status(ref, dest, n, porcelain);
+ n += print_one_push_status(ref, dest, n, show_subjects, porcelain);
}
for (ref = refs; ref; ref = ref->next)
if (ref->status == REF_STATUS_OK)
- n += print_one_push_status(ref, dest, n, porcelain);
+ n += print_one_push_status(ref, dest, n, show_subjects, porcelain);
*nonfastforward = 0;
for (ref = refs; ref; ref = ref->next) {
if (ref->status != REF_STATUS_NONE &&
ref->status != REF_STATUS_UPTODATE &&
ref->status != REF_STATUS_OK)
- n += print_one_push_status(ref, dest, n, porcelain);
+ n += print_one_push_status(ref, dest, n, show_subjects, porcelain);
if (ref->status == REF_STATUS_REJECT_NONFASTFORWARD)
*nonfastforward = 1;
}
@@ -912,6 +1064,7 @@ int transport_push(struct transport *transport,
int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
int dry_run = flags & TRANSPORT_PUSH_DRY_RUN;
int confirm = flags & TRANSPORT_PUSH_CONFIRM;
+ int show_subjects = flags & TRANSPORT_PUSH_SHOW_SUBJECTS;
int ret;
if (flags & TRANSPORT_PUSH_ALL)
@@ -942,7 +1095,7 @@ int transport_push(struct transport *transport,
* confirmed, send the porcelain-formatted output to stdout.
*/
print_push_status(transport->url, remote_refs,
- verbose, 0,
+ verbose, show_subjects, 0,
nonfastforward);
if (ret)
@@ -970,8 +1123,9 @@ int transport_push(struct transport *transport,
*/
if (!(quiet || (confirm && !porcelain)) || push_had_errors(remote_refs))
print_push_status(transport->url, remote_refs,
- verbose | porcelain, porcelain,
- nonfastforward);
+ verbose | porcelain,
+ show_subjects && !confirm && !porcelain,
+ porcelain, nonfastforward);
if (!dry_run) {
struct ref *ref;
diff --git a/transport.h b/transport.h
index 1d691d7..6a002a3 100644
--- a/transport.h
+++ b/transport.h
@@ -38,6 +38,7 @@ struct transport {
#define TRANSPORT_PUSH_PORCELAIN 32
#define TRANSPORT_PUSH_QUIET 64
#define TRANSPORT_PUSH_CONFIRM 128
+#define TRANSPORT_PUSH_SHOW_SUBJECTS 256
/* Returns a transport suitable for the url */
struct transport *transport_get(struct remote *, const char *);
--
1.6.2.5
^ permalink raw reply related
* [PATCH 2/4] push: allow configuring default for --confirm
From: Owen Taylor @ 2009-09-13 23:31 UTC (permalink / raw)
To: git; +Cc: Owen W. Taylor
In-Reply-To: <1252884685-9169-2-git-send-email-otaylor@redhat.com>
From: Owen W. Taylor <otaylor@fishsoup.net>
A new configuration variable push.confirm sets the default
behavior for whether 'git push' should show prompt the user
interactively before proceeding to update refs.
Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
---
Documentation/config.txt | 4 ++++
builtin-push.c | 6 +++++-
cache.h | 1 +
config.c | 4 ++++
environment.c | 1 +
5 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index be0b8ca..3bb632f 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1303,6 +1303,10 @@ pull.octopus::
pull.twohead::
The default merge strategy to use when pulling a single branch.
+push.confirm::
+ If set to true, linkgit:git-push[1] will act as if the --confirm
+ option was passed, unless overriden with --no-confirm.
+
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
diff --git a/builtin-push.c b/builtin-push.c
index 231be5d..63a0bb0 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -66,7 +66,6 @@ static void setup_push_tracking(void)
static void setup_default_push_refspecs(void)
{
- git_config(git_default_config, NULL);
switch (push_default) {
default:
case PUSH_DEFAULT_MATCHING:
@@ -193,6 +192,11 @@ int cmd_push(int argc, const char **argv, const char *prefix)
OPT_END()
};
+ git_config(git_default_config, NULL);
+
+ if (push_confirm)
+ flags |= TRANSPORT_PUSH_CONFIRM;
+
argc = parse_options(argc, argv, prefix, options, push_usage, 0);
if (tags)
diff --git a/cache.h b/cache.h
index 1a6412d..ef8606d 100644
--- a/cache.h
+++ b/cache.h
@@ -558,6 +558,7 @@ enum push_default_type {
extern enum branch_track git_branch_track;
extern enum rebase_setup_type autorebase;
extern enum push_default_type push_default;
+extern int push_confirm;
enum object_creation_mode {
OBJECT_CREATION_USES_HARDLINKS = 0,
diff --git a/config.c b/config.c
index c644061..1bc8e6f 100644
--- a/config.c
+++ b/config.c
@@ -575,6 +575,10 @@ static int git_default_branch_config(const char *var, const char *value)
static int git_default_push_config(const char *var, const char *value)
{
+ if (!strcmp(var, "push.confirm")) {
+ push_confirm = git_config_bool(var, value);
+ return 0;
+ }
if (!strcmp(var, "push.default")) {
if (!value)
return config_error_nonbool(var);
diff --git a/environment.c b/environment.c
index 5de6837..e1c82b9 100644
--- a/environment.c
+++ b/environment.c
@@ -44,6 +44,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;
+int push_confirm;
enum push_default_type push_default = PUSH_DEFAULT_MATCHING;
#ifndef OBJECT_CREATION_MODE
#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
--
1.6.2.5
^ permalink raw reply related
* [PATCH 1/4] push: add --confirm option to ask before sending updates
From: Owen Taylor @ 2009-09-13 23:31 UTC (permalink / raw)
To: git; +Cc: Owen W. Taylor
In-Reply-To: <1252884685-9169-1-git-send-email-otaylor@redhat.com>
From: Owen W. Taylor <otaylor@fishsoup.net>
When --confirm is specified, the refs being updated are displayed
to the user first, and the user is prompted whether to proceed
or not.
Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
---
Documentation/git-push.txt | 9 ++++-
builtin-push.c | 8 +++--
builtin-send-pack.c | 4 ++-
send-pack.h | 3 +-
transport.c | 87 ++++++++++++++++++++++++++++++++++++++++----
transport.h | 3 +-
6 files changed, 98 insertions(+), 16 deletions(-)
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 58d2bd5..c0bbf16 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -9,8 +9,9 @@ git-push - Update remote refs along with associated objects
SYNOPSIS
--------
[verse]
-'git push' [--all | --mirror | --tags] [--dry-run] [--receive-pack=<git-receive-pack>]
- [--repo=<repository>] [-f | --force] [-v | --verbose]
+'git push' [--all | --mirror | --tags] [--dry-run] [--confirm]
+ [--receive-pack=<git-receive-pack>] [--repo=<repository>]
+ [-f | --force] [-v | --verbose]
[<repository> <refspec>...]
DESCRIPTION
@@ -85,6 +86,10 @@ nor in any Push line of the corresponding remotes file---see below).
--dry-run::
Do everything except actually send the updates.
+--confirm::
+ Print a summary of what will be done, and then ask the user
+ interactively before actually sending the updates.
+
--porcelain::
Produce machine-readable output. The output status line for each ref
will be tab-separated and sent to stdout instead of stderr. The full
diff --git a/builtin-push.c b/builtin-push.c
index 6eda372..231be5d 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] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
+ "git push [--all | --mirror] [--dry-run] [--confirm] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
NULL,
};
@@ -141,6 +141,7 @@ static int do_push(const char *repo, int flags)
transport_get(remote, url[i]);
int err;
int nonfastforward;
+ int disconfirmed;
if (receivepack)
transport_set_option(transport,
TRANS_OPT_RECEIVEPACK, receivepack);
@@ -150,10 +151,10 @@ static int do_push(const char *repo, int flags)
if (flags & TRANSPORT_PUSH_VERBOSE)
fprintf(stderr, "Pushing to %s\n", url[i]);
err = transport_push(transport, refspec_nr, refspec, flags,
- &nonfastforward);
+ &nonfastforward, &disconfirmed);
err |= transport_disconnect(transport);
- if (!err)
+ if (!err || disconfirmed)
continue;
error("failed to push some refs to '%s'", url[i]);
@@ -182,6 +183,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
(TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
+ OPT_BIT( 0 , "confirm", &flags, "ask before pushing", TRANSPORT_PUSH_CONFIRM),
OPT_BIT( 0 , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
OPT_BIT( 0, "porcelain", &flags, "machine-readable output", TRANSPORT_PUSH_PORCELAIN),
OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE),
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 37e528e..0264180 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -406,7 +406,9 @@ int send_pack(struct send_pack_args *args,
REF_STATUS_OK;
}
- packet_flush(out);
+ /* Don't flush until the second pass of 'git push --confirm' */
+ if (!(args->dry_run && args->confirm))
+ packet_flush(out);
if (new_refs && !args->dry_run) {
if (pack_objects(out, remote_refs, extra_have, args) < 0) {
for (ref = remote_refs; ref; ref = ref->next)
diff --git a/send-pack.h b/send-pack.h
index 8b3cf02..f2b9292 100644
--- a/send-pack.h
+++ b/send-pack.h
@@ -8,7 +8,8 @@ struct send_pack_args {
force_update:1,
use_thin_pack:1,
use_ofs_delta:1,
- dry_run:1;
+ dry_run:1,
+ confirm:1;
};
int send_pack(struct send_pack_args *args,
diff --git a/transport.c b/transport.c
index 4cb8077..aa1852d 100644
--- a/transport.c
+++ b/transport.c
@@ -766,14 +766,18 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
args.verbose = !!(flags & TRANSPORT_PUSH_VERBOSE);
args.quiet = !!(flags & TRANSPORT_PUSH_QUIET);
args.dry_run = !!(flags & TRANSPORT_PUSH_DRY_RUN);
+ args.confirm = !!(flags & TRANSPORT_PUSH_CONFIRM);
ret = send_pack(&args, data->fd, data->conn, remote_refs,
&data->extra_have);
- close(data->fd[1]);
- close(data->fd[0]);
- ret |= finish_connect(data->conn);
- data->conn = NULL;
+ /* On the first dry-run pass of --confirm, we need to leave the connection open */
+ if (!((flags & TRANSPORT_PUSH_CONFIRM) && (flags & TRANSPORT_PUSH_DRY_RUN))) {
+ close(data->fd[1]);
+ close(data->fd[0]);
+ ret |= finish_connect(data->conn);
+ data->conn = NULL;
+ }
return ret;
}
@@ -867,14 +871,37 @@ int transport_set_option(struct transport *transport,
return 1;
}
+static int prompt_yesno(const char *prompt)
+{
+ while (1) {
+ char buf[128];
+
+ fprintf(stderr, prompt);
+ if (!fgets(buf, sizeof(buf), stdin))
+ return 0;
+ if (buf[0] == 'y' || buf[0] == 'Y')
+ return 1;
+ else if (buf[0] == 'n' || buf[0] == 'N')
+ return 0;
+ }
+}
+
int transport_push(struct transport *transport,
int refspec_nr, const char **refspec, int flags,
- int * nonfastforward)
+ int * nonfastforward, int * disconfirmed)
{
+ *disconfirmed = 0;
+
verify_remote_names(refspec_nr, refspec);
- if (transport->push)
+ if (transport->push) {
+ if (flags & TRANSPORT_PUSH_CONFIRM) {
+ fprintf(stderr, "--confirm cannot be used with remote URL %s\n", transport->url);
+ return -1;
+ }
+
return transport->push(transport, refspec_nr, refspec, flags);
+ }
if (transport->push_refs) {
struct ref *remote_refs =
transport->get_refs_list(transport, 1);
@@ -883,6 +910,8 @@ int transport_push(struct transport *transport,
int verbose = flags & TRANSPORT_PUSH_VERBOSE;
int quiet = flags & TRANSPORT_PUSH_QUIET;
int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
+ int dry_run = flags & TRANSPORT_PUSH_DRY_RUN;
+ int confirm = flags & TRANSPORT_PUSH_CONFIRM;
int ret;
if (flags & TRANSPORT_PUSH_ALL)
@@ -895,14 +924,56 @@ int transport_push(struct transport *transport,
return -1;
}
+ /* --confirm is a no-op when --dry-run is also specified */
+ if (confirm && (dry_run || !isatty(0))) {
+ confirm = 0;
+ flags &= ~TRANSPORT_PUSH_CONFIRM;
+ }
+
+ if (confirm) {
+ struct ref *ref;
+ int proceed = 0;
+
+ ret = transport->push_refs(transport, remote_refs,
+ flags | TRANSPORT_PUSH_DRY_RUN);
+
+ /* Interaction with --porcelain: we do the first pass interactively
+ * to stderr with normal formatting, and then once the user has
+ * confirmed, send the porcelain-formatted output to stdout.
+ */
+ print_push_status(transport->url, remote_refs,
+ verbose, 0,
+ nonfastforward);
+
+ if (ret)
+ return ret;
+
+ if (!refs_pushed(remote_refs)) {
+ fprintf(stderr, "Everything up-to-date\n");
+ return 0;
+ }
+
+ proceed = prompt_yesno("Proceed [y/n]? ");
+ if (!proceed) {
+ *disconfirmed = 1;
+ return -1;
+ }
+
+ for (ref = remote_refs; ref; ref = ref->next)
+ ref->status = REF_STATUS_NONE;
+ }
+
ret = transport->push_refs(transport, remote_refs, flags);
- if (!quiet || push_had_errors(remote_refs))
+ /* For --confirm, we don't need to print the details again unless
+ * something unexpected happened (denyNonFastforwards=true perhaps)
+ */
+ if (!(quiet || (confirm && !porcelain)) || push_had_errors(remote_refs))
print_push_status(transport->url, remote_refs,
verbose | porcelain, porcelain,
nonfastforward);
- if (!(flags & TRANSPORT_PUSH_DRY_RUN)) {
+ if (!dry_run) {
struct ref *ref;
for (ref = remote_refs; ref; ref = ref->next)
update_tracking_ref(transport->remote, ref, verbose);
diff --git a/transport.h b/transport.h
index c14da6f..1d691d7 100644
--- a/transport.h
+++ b/transport.h
@@ -37,6 +37,7 @@ struct transport {
#define TRANSPORT_PUSH_VERBOSE 16
#define TRANSPORT_PUSH_PORCELAIN 32
#define TRANSPORT_PUSH_QUIET 64
+#define TRANSPORT_PUSH_CONFIRM 128
/* Returns a transport suitable for the url */
struct transport *transport_get(struct remote *, const char *);
@@ -70,7 +71,7 @@ int transport_set_option(struct transport *transport, const char *name,
int transport_push(struct transport *connection,
int refspec_nr, const char **refspec, int flags,
- int * nonfastforward);
+ int * nonfastforward, int * disconfirmed);
const struct ref *transport_get_remote_refs(struct transport *transport);
--
1.6.2.5
^ permalink raw reply related
* Patches for git-push --confirm and --show-subjects
From: Owen Taylor @ 2009-09-13 23:31 UTC (permalink / raw)
To: git
Here's a first try at something like what was discussed. Various notes:
* I didn't try to implement --confirm for rsync and http pushes; it would
require completely different code and it sounds like they will eventually
be switched to the "push_refs" code path as well.
* I picked the name --show-subjects for the that option because
--show-commits/--log-commits implied a closer connection to 'git show'
or 'git log'. --show-subjects implies (to me) something more free-form.
* --show-subjects might actually benefit from having a short option
but I omitted that for now.
* I ripped off a big hunk of code from builtin-fmt-merge-msg.c to do the
commit synopsis without completely understanding it. There are quite
a few differences from the original and it was beyond my knowledge of
the git code base to figure out whether some shared utility could be
added.
Along with differences in the input parameters and the output, there's
one "bug fix" I made to the code - in the orginal, if you have exactly
21 commits it will show:
(21 commits):
<commit 1>
<commit 2>
[...]
<commit 20>
...
So the last commit is pointlessly substituted with '...'; that's more
annoying if you are showing just a few commits, so I fixed it in the
adapted code.
* Passing three booleans 'int verbose, int show_subjects, int porcelain'
between functions in transport.c is somewhat error-prone, but I didn't
want to switch to flags, since it would have made the patches here
less incremental.
* The interaction between --confirm and --show-subjects and --porcelain
is a bit tricky, but I think what I ended up with right - the basic
idea is that that '--confirm --porcelain' should let the user confirm
then output what actually got done to the wrapper script on stdout in
porcelain format. Didn't try to describe the details in the docs.
* My first attempt at changing the git code, so probably some stupidity
in there somewhere :-)
^ permalink raw reply
* Re: Confusing git pull error message
From: Jeff King @ 2009-09-13 22:39 UTC (permalink / raw)
To: Junio C Hamano; +Cc: John Tapsell, Git List
In-Reply-To: <7v7hw2pmtk.fsf@alter.siamese.dyndns.org>
On Sun, Sep 13, 2009 at 02:16:39PM -0700, Junio C Hamano wrote:
> I am _not_ going to commit the following patch, because it will interfere
> with this clarification effort, but I think we want to do something along
> this line after the "clarification" settles.
Please, yes. When I first suggested the advice.* mechanism, I had a
feeling in the back of my mind that there were several such messages
which had bothered me, but I didn't read through the code base looking
for them. But now that you mention it, this "no merge candidate" message
is definitely one of them (not even because it's wrong or anything, but
because of sheer _size_ of it).
> An observation I'd like to make is that this is way too ugly:
>
> [advice]
> pullNoMergeFound = false
> pushNonFastForward = false
> statusHints = false
>
> than
>
> [IKnowWhatIAmDoingThankYouVeryMuch]
> pullNoMergeFound
> pushNonFastForward
> statusHints
>
> but this feature is for people who know what they are doing, so I guess
> the current set-up would be fine.
Maybe a nice shorthand would be '!' for negative booleans. I.e.,
[advice]
!pullNoMergeFound
!pushNonFastForward
!statusHints
-Peff
^ permalink raw reply
* [PATCH] git-gui: search 4 directories to improve statistic of gc hint
From: Clemens Buchacher @ 2009-09-13 22:20 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, msysgit, Shawn O. Pearce, Jeff King
In-Reply-To: <20090913211916.GA5029@localhost>
On Windows, git-gui suggests running the garbage collector if it finds
1 or more files in .git/objects/42 (as opposed to 8 files on other
platforms). The probability of that happening if the repo contains
about 100 loose objects is 32%. The probability for the same to happen
when searching 4 directories is only 8%, which is bit more reasonable.
Also remove $objects_limit from the message, because we already know
that we are above (or close to) that limit. Telling the user about
that number does not really give him any useful information.
The following octave script shows the probability for at least m*q
objects to be found in q subdirectories of .git/objects if n is the
total number of objects.
q = 4;
m = [1 2 8];
n = 0:10:2000;
P = zeros(length(n), length(m));
for k = 1:length(n)
P(k, :) = 1-binocdf(q*m-1, n(k), q/(256-q));
end
plot(n, P);
n \ q 1 4
50 18% 1%
100 32% 8%
200 54% 39%
500 86% 96%
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
git-gui/lib/database.tcl | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/git-gui/lib/database.tcl b/git-gui/lib/database.tcl
index a18ac8b..d4e0bed 100644
--- a/git-gui/lib/database.tcl
+++ b/git-gui/lib/database.tcl
@@ -89,27 +89,26 @@ proc do_fsck_objects {} {
}
proc hint_gc {} {
- set object_limit 8
+ set ndirs 1
+ set limit 8
if {[is_Windows]} {
- set object_limit 1
+ set ndirs 4
+ set limit 1
}
- set objects_current [llength [glob \
- -directory [gitdir objects 42] \
+ set count [llength [glob \
-nocomplain \
- -tails \
-- \
- *]]
+ [gitdir objects 4\[0-[expr {$ndirs-1}]\]/*]]]
- if {$objects_current >= $object_limit} {
- set objects_current [expr {$objects_current * 250}]
- set object_limit [expr {$object_limit * 250}]
+ if {$count >= $limit * $ndirs} {
+ set objects_current [expr {$count * 256/$ndirs}]
if {[ask_popup \
[mc "This repository currently has approximately %i loose objects.
-To maintain optimal performance it is strongly recommended that you compress the database when more than %i loose objects exist.
+To maintain optimal performance it is strongly recommended that you compress the database.
-Compress the database now?" $objects_current $object_limit]] eq yes} {
+Compress the database now?" $objects_current]] eq yes} {
do_gc
}
}
--
1.6.5.rc0.164.g5f6b0
^ permalink raw reply related
* Re: [PATCH 4/4] reset: add test cases for "--merge-dirty" option
From: Paolo Bonzini @ 2009-09-13 22:15 UTC (permalink / raw)
To: Christian Couder
Cc: Daniel Barkalow, Junio C Hamano, git, Johannes Schindelin,
Stephan Beyer, Jakub Narebski, Linus Torvalds
In-Reply-To: <200909110705.35083.chriscool@tuxfamily.org>
> If they get merged, the option name '--merge-dirty" will probably be changed
> to something else like "--merge-safe" so I will have to change some patches
> anyway.
--merge-index or --merge-staged?
Also, it would be great if you would prepare tables like these for all
cases of git-reset.
Paolo
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 22:11 UTC (permalink / raw)
To: Jeff King; +Cc: John Tapsell, Git List
In-Reply-To: <20090913213609.GA6993@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
>> I think saying "does not exist" will repeat the same mistake of
>> overguessing you are trying to rectify.
>
> You are right, of course. I think your wording makes sense, then
> (otherwise we get stuck with "well, we didn't fetch it. Maybe because it
> didn't exist. Or maybe because your configuration didn't include it.").
Yeah, the saddest part of this whole story is that the message given by
the very original was succinct and accurate.
echo >&2 "Warning: No merge candidate found because value of config option
\"branch.${curr_branch}.merge\" does not match any remote branch fetched."
echo >&2 "No changes."
Then we piled up different messages for various cases, and it went
downhill from there.
- First, 8fc293c (Make git-pull complain and give advice when there is
nothing to merge with, 2007-10-02) made the message say essentially the
same thing, but with a lot more verbosity, covering only one _common_
case.
- Then 441ed41 ("git pull --tags": error out with a better message.,
2007-12-28) added a special case for --tags. The description before
8fc293c would have still been correct without this change. This was
necessary because 8fc293c talked only about the "I am on branch and
there is no configuration" case.
- Then 61e6108 (git-pull.sh: better warning message for "git pull" on
detached head., 2009-04-08) added another special case, again because
the "helpful" instruction given by 8fc293c did not make any sense in
the detached HEAD case.
It definitely is worth to further cover cases the message by 8fc293c did
not consider, as this thread suggested, but at the same time, I think the
advice mechanism should be used to bring back a succinct and to-the-point
message, close to the original one, e.g.
Warning: Not merging anything, as no default merge candidate ref
was fetched from the remote.
so that people who know what they are doing can squelch potentially
misleading "helpful" advices and diagnose/think for their own.
^ permalink raw reply
* Re: [PATCH 1/4] reset: add a few tests for "git reset --merge"
From: Tony Finch @ 2009-09-13 22:01 UTC (permalink / raw)
To: Christian Couder; +Cc: Jakub Narebski, git, Stephan Beyer, Daniel Barkalow
In-Reply-To: <200909110722.13331.chriscool@tuxfamily.org>
On Fri, 11 Sep 2009, Christian Couder wrote:
> On Thursday 10 September 2009, Jakub Narebski wrote:
> > Christian Couder wrote:
> > >
> > > exec </dev/null
> >
> > What does this do?
>
> Nothing! Yeah, this is a mistake.
It redirects stdin of the current shell.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.
^ permalink raw reply
* Re: Confusing git pull error message
From: Jeff King @ 2009-09-13 21:36 UTC (permalink / raw)
To: Junio C Hamano; +Cc: John Tapsell, Git List
In-Reply-To: <7vfxaqpnpa.fsf@alter.siamese.dyndns.org>
On Sun, Sep 13, 2009 at 01:57:37PM -0700, Junio C Hamano wrote:
> > What you have here is precisely what we observed. But I think one of the
> > complaints was to say more explicitly "that ref doesn't exist on the
> > remote", which I think should be the case if we have got to this point
> > (anything else would have triggered an error in fetch).
>
> Wouldn't you get into the situation with this?
>
> [remote "origin"]
> fetch = refs/heads/master:refs/heads/master
> [branch "master"]
> remote = origin
> merge = refs/heads/next
>
> I think saying "does not exist" will repeat the same mistake of
> overguessing you are trying to rectify.
You are right, of course. I think your wording makes sense, then
(otherwise we get stuck with "well, we didn't fetch it. Maybe because it
didn't exist. Or maybe because your configuration didn't include it.").
-Peff
^ permalink raw reply
* Re: rename tracking and file-name swapping
From: Yuri D'Elia @ 2009-09-13 21:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Bernardo Innocenti
In-Reply-To: <7viqfmsoej.fsf@alter.siamese.dyndns.org>
On 13 Sep 2009, at 20:14, Junio C Hamano wrote:
>> % mv file1.txt file3.txt
>> % mv file2.txt file1.txt
>> % mv file3.txt file2.txt
>> % git add file1.txt file2.txt
>> % git diff -M --stat --cached
>> file1.txt | 150 ++++++++++++++++++++++
>> +-------------------------------------
>> file2.txt | 150 ++++++++++++++++++++++++++++++++++++
>> +-----------------------
>> 2 files changed, 150 insertions(+), 150 deletions(-)
>
> By default, if the pathname that was present in the old version still
> appears in the new version, that path is not considered as a candiate
> for rename detection. Only "X used to be there but is gone" and "Y
> did
> not exist but appeared" are paired up and checked if they are similar.
>
> Give the command -B option, too, to break the filepair that does not
> disappear.
That does the trick. I'm curious, is there any other use for -B
besides rename handling?
Any reason of why it isn't a default when --find-copies-harder is in
effect?
^ permalink raw reply
* Re: [PATCH v2 2/2] teach git-archive to auto detect the output format
From: Junio C Hamano @ 2009-09-13 21:27 UTC (permalink / raw)
To: Dmitry Potapov; +Cc: git, John Tapsell
In-Reply-To: <20090913201701.GH30385@dpotapov.dyndns.org>
Dmitry Potapov <dpotapov@gmail.com> writes:
> On Sun, Sep 13, 2009 at 11:52:56AM -0700, Junio C Hamano wrote:
>> > + sprintf(fmt_opt, "--format=%s", format);
>> > + argv[argc++] = fmt_opt;
>> > + argv[argc] = NULL;
>>
> Either --output or --format option was used before, and this option is
> extracted from argv[] by parse_options(). So it should be space for at
> least one argument in argv.
To my taste, that is a unwarranted (on the borderline) assumption of what
parse_options() does, but I'll let it pass with some additional comment to
warn readers of the code.
Applied.
^ permalink raw reply
* Re: [PATCH] git-gui: suggest gc only when counting at least 2 objects
From: Clemens Buchacher @ 2009-09-13 21:19 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, git, msysgit, Shawn O. Pearce
In-Reply-To: <20090913204433.GA8796@coredump.intra.peff.net>
On Sun, Sep 13, 2009 at 04:44:33PM -0400, Jeff King wrote:
> On Sun, Sep 13, 2009 at 08:41:50PM +0200, Clemens Buchacher wrote:
>
> > On Sun, Sep 13, 2009 at 10:58:45AM -0700, Junio C Hamano wrote:
> > > Somebody cares to explain why this threashold number has to be different
> > > per platform in the first place?
> >
> > I really don't know. I vaguely remember someone claim that performance on
> > Windows suffered from many loose objects more than on other platforms. I
> > can't find any discussion of it though.
>
> Maybe 8ff487c?
Ok. But it's been 2 years since then and if I'm not mistaken, there have
been a number of performance improvements to msysgit. So maybe it's time to
revisit that threshold.
If, on the other hand, requiring 2 objects really is too many, we should
maybe check at least two or four directories, which would greatly improve
the statistic.
For example, the probability of q directories containing q objects, for n
objects total is
n \ q 1 4
50 18% 1%
100 32% 7%
200 54% 38%
500 86% 95%
Clemens
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 21:18 UTC (permalink / raw)
To: John Tapsell; +Cc: Jeff King, Git List
In-Reply-To: <43d8ce650909131357m50428ffbs9c939be051254eb7@mail.gmail.com>
John Tapsell <johnflux@gmail.com> writes:
> Yeah, it kinda sounds like git is just being lazy, and can't be
> bothered to fetch it :-)
Do you want it to say "you didn't tell us to fetch it"?
After all, we only do what the user instructs us to do, so I thought that
goes without saying it.
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 21:16 UTC (permalink / raw)
To: Jeff King; +Cc: John Tapsell, Git List
In-Reply-To: <20090913204231.GA8654@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:
>
>> I saw some discussion on improving the wording. Here is what I plan to
>> commit.
>
> Thanks for picking this up, I meant to re-post with improvements.
I am _not_ going to commit the following patch, because it will interfere
with this clarification effort, but I think we want to do something along
this line after the "clarification" settles.
An observation I'd like to make is that this is way too ugly:
[advice]
pullNoMergeFound = false
pushNonFastForward = false
statusHints = false
than
[IKnowWhatIAmDoingThankYouVeryMuch]
pullNoMergeFound
pushNonFastForward
statusHints
but this feature is for people who know what they are doing, so I guess
the current set-up would be fine.
git-pull.sh | 78 ++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 54 insertions(+), 24 deletions(-)
diff --git a/git-pull.sh b/git-pull.sh
index 0bbd5bf..101545e 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -76,14 +76,64 @@ do
shift
done
+advice_tags_only () {
+ if test -z "$1"
+ then
+ echo "Fetching tags only."
+ return
+ fi
+ echo "Fetching tags only, you probably meant:"
+ echo " git fetch --tags"
+}
+
+advice_detached_head () {
+ if test -z "$1"
+ then
+ echo "No default merge candidate on a detached HEAD."
+ return
+ fi
+ echo "You are not currently on a branch, so I cannot use any"
+ echo "'branch.<branchname>.merge' in your configuration file."
+ echo "Please specify which branch you want to merge on the command"
+ echo "line and try again (e.g. 'git pull <repository> <refspec>')."
+ echo "See git-pull(1) for details."
+}
+
+advice_no_merge_candidates () {
+ if test -z "$1"
+ then
+ echo "No merge candidate for the current branch fetched."
+ return
+ fi
+ cat <<EOF
+You asked me to pull without telling me which branch you
+want to merge with, and 'branch.$2.merge' in
+your configuration file does not tell me either. Please
+specify which branch you want to merge on the command line and
+try again (e.g. 'git pull <repository> <refspec>').
+See git-pull(1) for details.
+
+If you often merge with the same branch, you may want to
+configure the following variables in your configuration
+file:
+
+ branch.$2.remote = <nickname>
+ branch.$2.merge = <remote-ref>
+ remote.<nickname>.url = <url>"
+ remote.<nickname>.fetch = <refspec>
+
+See git-config(1) for details.
+EOF
+}
+
error_on_no_merge_candidates () {
exec >&2
+ advice=$(git config --bool advice.pullNoMergeFound)
for opt
do
case "$opt" in
-t|--t|--ta|--tag|--tags)
- echo "Fetching tags only, you probably meant:"
- echo " git fetch --tags"
+ advice_tags_only "$advice"
exit 1
esac
done
@@ -91,29 +141,9 @@ error_on_no_merge_candidates () {
curr_branch=${curr_branch#refs/heads/}
if [ -z "$curr_branch" ]; then
- echo "You are not currently on a branch, so I cannot use any"
- echo "'branch.<branchname>.merge' in your configuration file."
- echo "Please specify which branch you want to merge on the command"
- echo "line and try again (e.g. 'git pull <repository> <refspec>')."
- echo "See git-pull(1) for details."
+ advice_detached_head "$advice"
else
- echo "You asked me to pull without telling me which branch you"
- echo "want to merge with, and 'branch.${curr_branch}.merge' in"
- echo "your configuration file does not tell me either. Please"
- echo "specify which branch you want to merge on the command line and"
- echo "try again (e.g. 'git pull <repository> <refspec>')."
- echo "See git-pull(1) for details."
- echo
- echo "If you often merge with the same branch, you may want to"
- echo "configure the following variables in your configuration"
- echo "file:"
- echo
- echo " branch.${curr_branch}.remote = <nickname>"
- echo " branch.${curr_branch}.merge = <remote-ref>"
- echo " remote.<nickname>.url = <url>"
- echo " remote.<nickname>.fetch = <refspec>"
- echo
- echo "See git-config(1) for details."
+ advice_no_merge_candidate "$advice" "$curr_branch"
fi
exit 1
}
^ permalink raw reply related
* [ANNOUNCE] CGIT 0.8.3
From: Lars Hjemli @ 2009-09-13 21:00 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <8c5c35580909131355n78d817e0x67c15a1e19beb8c3@mail.gmail.com>
A new feature-release of cgit, a fast webinterface for git, is now
available for cloning from git://hjemli.net/pub/git/cgit (or browsing
on http://hjemli.net/git/cgit).
Some release highlights:
* support for output filters, e.g. syntax highlighting and bugtracker
integration - check subdirectory "filters" for examples
* support for automatic scanning for repositories and caching of the
resulting list
* improved support for mimetypes in "plain" view
* improved support for lightweight tags
* improved support for embedding cgit in site-specific layouts
* option to avoid printing author/committer/tagger email
* support for styling treeview based on filename extension (i.e. icons)
* lots of bugfixes
Thanks to everyone who contributed code and/or feedback.
Shortlog v0.8.2.1..v0.8.2.2
===========================
Lars Hjemli (4):
ui-tag.c: do not segfault when id is missing from query-string
cgit.c: do not segfault on unexpected query-string format
ui-plain.c: only return the blob with the specified path
CGIT 0.8.2.2
Matthew Metnetsky (1):
ui-shared: don't print header <img/> if there isn't a logo defined
Shortlog v0.8.2.2..v0.8.3
=========================
Simon Arlott (1):
truncate buffer before reading empty files
Diego Ongaro (2):
add cgit_httpscheme() -> http:// or https://
use cgit_httpscheme() for atom feed
Florian Pritz (2):
ui-tree.c: show line numbers when highlighting
Add 'linenumbers' config option
Lars Hjemli (62):
Add support for an 'embedded' option in cgitrc
cgitrc.5.txt: make the cgitrc options a valid asciidoc labeled list
cgitrc.5.txt: wrap the example file in an asciidoc LiteralBlock
cgitrc.5.txt: un-indent the name section
Add cgit-doc.css
Makefile: add doc-related targets
Add support for ETag in 'plain' view
Add support for HEAD requests
Fix doc-related glitches in Makefile and .gitignore
Return http statuscode 404 on unknown branch
ui-blob: return 'application/octet-stream' for binary blobs
cgitrc.5.txt: document 'head-include'
Add support for 'noheader' option
cgitrc.5.txt: document 'embedded' and 'noheader'
cgit.h: keep config flags sorted
Add support for mime type registration and lookup
Add generic filter/plugin infrastructure
ui-snapshot: use cgit_{open|close}_filter() to execute compressors
ui-tree: add support for source-filter option
ui-commit: add support for 'commit-filter' option
Add support for repo.commit-filter and repo.source-filter
cgit.c: allow repo.*-filter options to unset the current default
ui-summary: enable arbitrary paths below repo.readme
Add 'about-filter' and 'repo.about-filter' options
Add some example filter scripts
Cleanup handling of environment variables
ui-shared: add support for NO_HTTP=1/--nohttp
cgit.css: align commit message with subject in expanded log listing
cgit.c: make '/cgit.png' the default value for 'logo' option
cgitrc.5.txt: describe where/how cgit will locate cgitrc
ui-shared: add support for header/footer options when embedded=1
Use GIT-1.6.3.4
ui-log.c: handle lightweight tags when printing commit decorations
Add and use a common readfile() function
cgit.c: fix caching keyed on PATH_INFO with no QUERY_STRING
Rename "linenumbers" to "enable-tree-linenumbers", change default to "1"
cgit.css: make the blob display in tree view a bit prettier
cgitrc.5.txt: fix description and markup for 'snapshots' option
scan-tree: detect non-bare repository and stop scanning early
cgit.c: add support for cgitrc option 'repo.scan'
cache.h: export hash_str()
cgit.c: make print_repolist() and print_repo() reusable for caching
cgit.c: add support for caching autodetected repositories
cgitrc.5.txt: document repo.scan and cache-scanrc-ttl
Rename 'repo.scan' to 'scan-path'
Add support for --scan-path command line option
Introduce 'section' as canonical spelling for 'repo.group'
Add config option 'repo.section'
ui-repolist.c: sort by section name, repo name as default
cgit.c: refactor repo_config() from config_cb()
Add support for repo-local cgitrc file
ui-repolist: handle empty sections similar to NULL sections
cgitrc.5.txt: fix markup errors
Add config option 'enable-filter-overrides'
shared.c: initialize cgit_repo structs properly
cgit.c: add missing options to print_repo()
cgit.c: generate repo.snapshots in print_repo()
Add and use cgit_find_stats_periodname() in print_repo()
cgit.c: only print first line of repo.desc in print_repo()
cgit.c: respect repo-local 'snapshots' option for --scan-path
Use GIT-1.6.4.3
CGIT 0.8.3
Mark Lodato (1):
Add head-include configuration option.
Martin Szulecki (2):
Introduce noplainemail option to hide email adresses from spambots
Expose file extension in tree lists as class to allow nicer tree styling
Matt McCormick (thewtex) (1):
make cgitrc.5.txt asciidoc manpage compatible
Remko Tronçon (1):
ui-plain: Return 'application/octet-stream' for binary files.
Stefan Bühler (1):
ui-refs.c: improve handling of lightweight tags
Stefan Naewe (1):
scan-tree: split the pw_gecos field at the ',' to get the real name
^ permalink raw reply
* Re: Confusing git pull error message
From: John Tapsell @ 2009-09-13 20:57 UTC (permalink / raw)
To: Jeff King; +Cc: Junio C Hamano, Git List
In-Reply-To: <20090913204231.GA8654@coredump.intra.peff.net>
2009/9/13 Jeff King <peff@peff.net>:
> On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:
>
>> I saw some discussion on improving the wording. Here is what I plan to
>> commit.
>
> Thanks for picking this up, I meant to re-post with improvements.
>
>> + else
>> + echo "Your configuration specifies to merge the ref"
>> + echo "'${upstream#refs/heads/}' from the remote, but no such ref"
>> + echo "was fetched."
>
> What you have here is precisely what we observed. But I think one of the
> complaints was to say more explicitly "that ref doesn't exist on the
> remote", which I think should be the case if we have got to this point
> (anything else would have triggered an error in fetch).
Yeah, it kinda sounds like git is just being lazy, and can't be
bothered to fetch it :-)
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 20:57 UTC (permalink / raw)
To: Jeff King; +Cc: John Tapsell, Git List
In-Reply-To: <20090913204231.GA8654@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> What you have here is precisely what we observed. But I think one of the
> complaints was to say more explicitly "that ref doesn't exist on the
> remote", which I think should be the case if we have got to this point
> (anything else would have triggered an error in fetch).
Wouldn't you get into the situation with this?
[remote "origin"]
fetch = refs/heads/master:refs/heads/master
[branch "master"]
remote = origin
merge = refs/heads/next
I think saying "does not exist" will repeat the same mistake of
overguessing you are trying to rectify.
^ permalink raw reply
* Re: [PATCH] git-gui: suggest gc only when counting at least 2 objects
From: Jeff King @ 2009-09-13 20:44 UTC (permalink / raw)
To: Clemens Buchacher; +Cc: Junio C Hamano, git, msysgit, Shawn O. Pearce
In-Reply-To: <20090913184150.GA19209@localhost>
On Sun, Sep 13, 2009 at 08:41:50PM +0200, Clemens Buchacher wrote:
> On Sun, Sep 13, 2009 at 10:58:45AM -0700, Junio C Hamano wrote:
> > Somebody cares to explain why this threashold number has to be different
> > per platform in the first place?
>
> I really don't know. I vaguely remember someone claim that performance on
> Windows suffered from many loose objects more than on other platforms. I
> can't find any discussion of it though.
Maybe 8ff487c?
-Peff
^ permalink raw reply
* Re: Confusing git pull error message
From: Jeff King @ 2009-09-13 20:42 UTC (permalink / raw)
To: Junio C Hamano; +Cc: John Tapsell, Git List
In-Reply-To: <7v1vmar353.fsf@alter.siamese.dyndns.org>
On Sun, Sep 13, 2009 at 01:38:48PM -0700, Junio C Hamano wrote:
> I saw some discussion on improving the wording. Here is what I plan to
> commit.
Thanks for picking this up, I meant to re-post with improvements.
> + else
> + echo "Your configuration specifies to merge the ref"
> + echo "'${upstream#refs/heads/}' from the remote, but no such ref"
> + echo "was fetched."
What you have here is precisely what we observed. But I think one of the
complaints was to say more explicitly "that ref doesn't exist on the
remote", which I think should be the case if we have got to this point
(anything else would have triggered an error in fetch).
I don't have a strong feeling either way, though.
-Peff
^ permalink raw reply
* Re: [PATCH] completion: Replace config --list with --get-regexp
From: Junio C Hamano @ 2009-09-13 20:40 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: Todd Zullinger, Jeff King, james bardin, git
In-Reply-To: <20090912183139.GO1033@spearce.org>
Thanks, everybody. Will apply.
^ permalink raw reply
* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-09-13 20:38 UTC (permalink / raw)
To: Jeff King; +Cc: John Tapsell, Git List
In-Reply-To: <20090912211119.GA30966@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I think it is enough for git-pull to just check whether the config
> exists, and if so, guess that the ref was simply not fetched. IOW,
> this:
Thanks.
I saw some discussion on improving the wording. Here is what I plan to
commit.
diff --git a/git-pull.sh b/git-pull.sh
index 0bbd5bf..2c2fa79 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -89,6 +89,8 @@ error_on_no_merge_candidates () {
done
curr_branch=${curr_branch#refs/heads/}
+ upstream=$(git config "branch.$curr_branch.merge" ||
+ git config "branch.$curr_branch.rebase")
if [ -z "$curr_branch" ]; then
echo "You are not currently on a branch, so I cannot use any"
@@ -96,7 +98,7 @@ error_on_no_merge_candidates () {
echo "Please specify which branch you want to merge on the command"
echo "line and try again (e.g. 'git pull <repository> <refspec>')."
echo "See git-pull(1) for details."
- else
+ elif [ -z "$upstream" ]; then
echo "You asked me to pull without telling me which branch you"
echo "want to merge with, and 'branch.${curr_branch}.merge' in"
echo "your configuration file does not tell me either. Please"
@@ -114,6 +116,10 @@ error_on_no_merge_candidates () {
echo " remote.<nickname>.fetch = <refspec>"
echo
echo "See git-config(1) for details."
+ else
+ echo "Your configuration specifies to merge the ref"
+ echo "'${upstream#refs/heads/}' from the remote, but no such ref"
+ echo "was fetched."
fi
exit 1
}
^ permalink raw reply related
* [PATCH v2 2/2] teach git-archive to auto detect the output format
From: Dmitry Potapov @ 2009-09-13 20:17 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell
In-Reply-To: <7vzl8yr81j.fsf@alter.siamese.dyndns.org>
When I type something like this:
git archive -o my-v2.0.zip v2.0
it is almost certainly that I want to create a zip archive, and not
a tar file.
This patch teaches git-archive to auto detect the output format from the
file name. Currently, only '.zip' is supported. If the auto detect failed,
the tar format is used as before. The auto detect is not used when the
output format is specified explicitly.
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
---
I have corrected all remarks except this:
On Sun, Sep 13, 2009 at 11:52:56AM -0700, Junio C Hamano wrote:
> > + sprintf(fmt_opt, "--format=%s", format);
> > + argv[argc++] = fmt_opt;
> > + argv[argc] = NULL;
>
> Did you make sure you are allowed to write into argv[] and the array is
> large enough? You probably need to make a copy of the array.
Either --output or --format option was used before, and this option is
extracted from argv[] by parse_options(). So it should be space for at
least one argument in argv.
Documentation/git-archive.txt | 13 +++++++++++--
builtin-archive.c | 25 ++++++++++++++++++++++++-
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 1917f2e..3d1c1e7 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -34,8 +34,11 @@ OPTIONS
-------
--format=<fmt>::
- Format of the resulting archive: 'tar' or 'zip'. The default
- is 'tar'.
+ Format of the resulting archive: 'tar' or 'zip'. If this option
+ is not given, and the output file is specified, the format is
+ inferred from the filename if possible (e.g. writing to "foo.zip"
+ makes the output to be in the zip format). Otherwise the output
+ format is `tar`.
-l::
--list::
@@ -130,6 +133,12 @@ git archive --format=zip --prefix=git-docs/ HEAD:Documentation/ > git-1.4.0-docs
Put everything in the current head's Documentation/ directory
into 'git-1.4.0-docs.zip', with the prefix 'git-docs/'.
+git archive -o latest.zip HEAD::
+
+ Create a Zip archive that contains the contents of the latest
+ commit on the current branch. Note that the output format is
+ inferred by the extension of the output file.
+
SEE ALSO
--------
diff --git a/builtin-archive.c b/builtin-archive.c
index 565314b..6efba6f 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -60,6 +60,17 @@ static int run_remote_archiver(int argc, const char **argv,
return !!rv;
}
+static const char* format_from_name(const char *filename)
+{
+ const char *ext = strrchr(filename, '.');
+ if (!ext)
+ return NULL;
+ ext++;
+ if (!strcasecmp(ext, "zip"))
+ return "zip";
+ return NULL;
+}
+
#define PARSE_OPT_KEEP_ALL ( PARSE_OPT_KEEP_DASHDASH | \
PARSE_OPT_KEEP_ARGV0 | \
PARSE_OPT_KEEP_UNKNOWN | \
@@ -70,6 +81,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
const char *exec = "git-upload-archive";
const char *output = NULL;
const char *remote = NULL;
+ const char *format = NULL;
struct option local_opts[] = {
OPT_STRING('o', "output", &output, "file",
"write the archive to this file"),
@@ -77,14 +89,25 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
"retrieve the archive from remote repository <repo>"),
OPT_STRING(0, "exec", &exec, "cmd",
"path to the remote git-upload-archive command"),
+ OPT_STRING(0, "format", &format, "fmt", "archive format"),
OPT_END()
};
+ char fmt_opt[32];
argc = parse_options(argc, argv, prefix, local_opts, NULL,
PARSE_OPT_KEEP_ALL);
- if (output)
+ if (output) {
create_output_file(output);
+ if (!format)
+ format = format_from_name(output);
+ }
+
+ if (format) {
+ sprintf(fmt_opt, "--format=%s", format);
+ argv[argc++] = fmt_opt;
+ argv[argc] = NULL;
+ }
if (remote)
return run_remote_archiver(argc, argv, remote, exec);
--
1.6.5.rc1.2.g6bb993
^ permalink raw reply related
* [PATCH v2 1/2] git-archive: add '-o' as a alias for '--output'
From: Dmitry Potapov @ 2009-09-13 20:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, John Tapsell
In-Reply-To: <7v4or6sngc.fsf@alter.siamese.dyndns.org>
The '-o' option is commonly used in many tools to specify the output file.
Typing '--output' every time is a bit too long to be a practical alternative
to redirecting output. But specifying the output name has the advantage of
making possible to guess the desired output format by filename extension.
Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
---
On Sun, Sep 13, 2009 at 11:34:43AM -0700, Junio C Hamano wrote:
> I think this patch is very reasonable, except for this hunk, which would
> want to say "-o <file>::" instead.
Corrected.
Documentation/git-archive.txt | 3 ++-
archive.c | 2 +-
builtin-archive.c | 2 +-
3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-archive.txt b/Documentation/git-archive.txt
index 92444dd..1917f2e 100644
--- a/Documentation/git-archive.txt
+++ b/Documentation/git-archive.txt
@@ -10,7 +10,7 @@ SYNOPSIS
--------
[verse]
'git archive' [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
- [--output=<file>] [--worktree-attributes]
+ [-o | --output=<file>] [--worktree-attributes]
[--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
[path...]
@@ -48,6 +48,7 @@ OPTIONS
--prefix=<prefix>/::
Prepend <prefix>/ to each filename in the archive.
+-o <file>::
--output=<file>::
Write the archive to <file> instead of stdout.
diff --git a/archive.c b/archive.c
index 0bca9ca..73b8e8a 100644
--- a/archive.c
+++ b/archive.c
@@ -283,7 +283,7 @@ static int parse_archive_args(int argc, const char **argv,
OPT_STRING(0, "format", &format, "fmt", "archive format"),
OPT_STRING(0, "prefix", &base, "prefix",
"prepend prefix to each pathname in the archive"),
- OPT_STRING(0, "output", &output, "file",
+ OPT_STRING('o', "output", &output, "file",
"write the archive to this file"),
OPT_BOOLEAN(0, "worktree-attributes", &worktree_attributes,
"read .gitattributes in working directory"),
diff --git a/builtin-archive.c b/builtin-archive.c
index f9a4bea..565314b 100644
--- a/builtin-archive.c
+++ b/builtin-archive.c
@@ -71,7 +71,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
const char *output = NULL;
const char *remote = NULL;
struct option local_opts[] = {
- OPT_STRING(0, "output", &output, "file",
+ OPT_STRING('o', "output", &output, "file",
"write the archive to this file"),
OPT_STRING(0, "remote", &remote, "repo",
"retrieve the archive from remote repository <repo>"),
--
1.6.5.rc1.2.g6bb993
^ 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