* Re: [PATCH v2] push: point to 'git pull' and 'git push --force' in case of non-fast forward
From: Matthieu Moy @ 2009-08-10 8:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Teemu Likonen, git
In-Reply-To: <7v1vnk3vgc.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Matthieu Moy <Matthieu.Moy@imag.fr> writes:
>
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>>> If you read "Integrate them with your changes" and understand that it is
>>> talking about "git pull" or "git pull --rebase", then you do not have to
>>> read the doc. It should "click".
>>
>> But what's the point is being so vague, while you could just add "(see
>> git pull)"? See what you've just wrote: one should "understand that it
>> is about ...". So, why write Y thinking that the user should
>> understand that it is about X while you could write X directly?
>
> In order to cover both "pull" and "pull --rebase"?
"git pull" also covers both. "pull" is the command, "--rebase" is an
option of it.
--
Matthieu
^ permalink raw reply
* Re: gitweb stops working sometimes
From: Jakub Narebski @ 2009-08-10 8:58 UTC (permalink / raw)
To: Erez Zilber; +Cc: git
In-Reply-To: <ce513bcc0908100101u70ade553h9d7dc413cb6a276d@mail.gmail.com>
Erez Zilber <erezzi.list@gmail.com> writes:
> I'm running gitweb on a centos 5.3 server and it works well 99% of the
> time. Sometimes, I see the following behavior:
> 1. I'm able to load the page that shows all git trees.
> 2. When I click on one of the links that should show a specific tree,
> it opens a page with the following text: "<div
> class="title"> </div>
> "
>
> If I restart httpd, it doesn't help. The only solution that I found so
> far is to reboot the server and then everything works. However,
> rebooting the server is a bad solution.
>
> Any idea?
No idea what might be the cause of that.
1. Do you run gitweb as CGI script, or as mod_perl
(ModPerl::Registry) script?
2. Which version of git you are using?
3. Which version of gitweb you are using?
All of this info can be found in "generator" meta header on pages
generated by (modern) gitweb.
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply
* Re: [PATCH] git-instaweb: fix mod_perl detection for apache2
From: Jakub Narebski @ 2009-08-10 8:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Mark A Rada, git
In-Reply-To: <7vprb45ty7.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Mark A Rada <marada@uwaterloo.ca> writes:
>
> > The script was looking for something that matched the '^our $gitbin'
> > regex, which no longer exists in gitweb.cgi.
> >
> > Now it looks for 'MOD_PERL', which should be on the line that checks
> > to see if the script is running in a mod_perl environment.
>
> Thanks. That sounds like an ancient bug that in turn perhaps suggests
> nobody uses instaweb. Will apply to 'maint'..
Hmmm... taking a peek at current "Git User's Survey 2009" results
http://www.survs.com/shareResults?survey=2PIMZGU0&rndm=678J66QRA2
11. What Git interfaces, implementations, frontends and tools do you
use?
git-instaweb 3% 77 / 2712
16. How often do you use the following forms of git commands or extra
git tools?
git instaweb
never: 1983 - 79%
rarely: 208 - 8%
sometimes: 50 - 2%
often: 9 - 0%
Total respondents 2506
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply
* [PATCH v3 7/8] git stat: pathspec limits, unlike traditional "git status"
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
In-Reply-To: <1249894465-11018-7-git-send-email-gitster@pobox.com>
The "git stat" command is not "preview of commit with the same arguments";
the path parameters are not paths to be added to the pristine index (aka
"--only" option), but are taken as pathspecs to limit the output.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin-commit.c | 3 +++
wt-status.c | 6 ++++++
wt-status.h | 1 +
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index bc780a8..9c2a70c 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -917,6 +917,9 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
builtin_stat_usage, 0);
handle_untracked_files_arg(&s);
+ if (*argv)
+ s.pathspec = get_pathspec(prefix, argv);
+
read_cache();
refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
diff --git a/wt-status.c b/wt-status.c
index a5dbdcc..aea3bbb 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -269,6 +269,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = wt_status_collect_changed_cb;
rev.diffopt.format_callback_data = s;
+ rev.prune_data = s->pathspec;
run_diff_files(&rev, 0);
}
@@ -285,6 +286,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)
rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = 200;
rev.diffopt.break_opt = 0;
+ rev.prune_data = s->pathspec;
run_diff_index(&rev, 1);
}
@@ -297,6 +299,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
struct wt_status_change_data *d;
struct cache_entry *ce = active_cache[i];
+ if (!ce_path_match(ce, s->pathspec))
+ continue;
it = string_list_insert(ce->name, &s->change);
d = it->util;
if (!d) {
@@ -330,6 +334,8 @@ static void wt_status_collect_untracked(struct wt_status *s)
struct dir_entry *ent = dir.entries[i];
if (!cache_name_is_other(ent->name, ent->len))
continue;
+ if (!match_pathspec(s->pathspec, ent->name, ent->len, 0, NULL))
+ continue;
s->workdir_untracked = 1;
string_list_insert(ent->name, &s->untracked);
}
diff --git a/wt-status.h b/wt-status.h
index 44c40ff..6dcb739 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -31,6 +31,7 @@ struct wt_status {
int is_initial;
char *branch;
const char *reference;
+ const char **pathspec;
int verbose;
int amend;
int nowarn;
--
1.6.4.173.g72959
^ permalink raw reply related
* [PATCH v3 8/8] git stat -s: short status output
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
In-Reply-To: <1249894465-11018-8-git-send-email-gitster@pobox.com>
Give -s(hort) option to "git stat" that shows the status of paths in a
more concise way.
XY PATH1 -> PATH2
format to be more machine readable than output from "git status", which is
about previewing of "git commit" with the same arguments.
PATH1 is the path in the HEAD, and " -> PATH2" part is shown only when
PATH1 corresponds to a different path in the index/worktree.
For unmerged entries, X shows the status of stage #2 (i.e. ours) and Y
shows the status of stage #3 (i.e. theirs). For entries that do not have
conflicts, X shows the status of the index, and Y shows the status of the
work tree. For untracked paths, XY are "??".
X Y Meaning
-------------------------------------------------
[MD] not updated
M [ MD] updated in index
A [ MD] added to index
D [ MD] deleted from index
R [ MD] renamed in index
C [ MD] copied in index
[MARC] index and work tree matches
[ MARC] M work tree changed since index
[ MARC] D deleted in work tree
D D unmerged, both deleted
A U unmerged, added by us
U D unmerged, deleted by them
U A unmerged, added by them
D U unmerged, deleted by us
A A unmerged, both added
U U unmerged, both modified
? ? untracked
When given -z option, the records are terminated by NUL characters for
better machine readability.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin-commit.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 96 insertions(+), 1 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 9c2a70c..0ed0d71 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -898,11 +898,86 @@ static int git_status_config(const char *k, const char *v, void *cb)
return git_diff_ui_config(k, v, NULL);
}
+#define quote_path quote_path_relative
+
+static void short_unmerged(int null_termination, struct string_list_item *it,
+ struct wt_status *s)
+{
+ struct wt_status_change_data *d = it->util;
+ const char *how = "??";
+
+ switch (d->stagemask) {
+ case 1: how = "DD"; break; /* both deleted */
+ case 2: how = "AU"; break; /* added by us */
+ case 3: how = "UD"; break; /* deleted by them */
+ case 4: how = "UA"; break; /* added by them */
+ case 5: how = "DU"; break; /* deleted by us */
+ case 6: how = "AA"; break; /* both added */
+ case 7: how = "UU"; break; /* both modified */
+ }
+ printf("%s ", how);
+ if (null_termination) {
+ fprintf(stdout, "%s%c", it->string, 0);
+ } else {
+ struct strbuf onebuf = STRBUF_INIT;
+ const char *one;
+ one = quote_path(it->string, -1, &onebuf, s->prefix);
+ printf("%s\n", one);
+ strbuf_release(&onebuf);
+ }
+}
+
+static void short_status(int null_termination, struct string_list_item *it,
+ struct wt_status *s)
+{
+ struct wt_status_change_data *d = it->util;
+
+ printf("%c%c ",
+ !d->index_status ? ' ' : d->index_status,
+ !d->worktree_status ? ' ' : d->worktree_status);
+ if (null_termination) {
+ fprintf(stdout, "%s%c", it->string, 0);
+ if (d->head_path)
+ fprintf(stdout, "%s%c", d->head_path, 0);
+ } else {
+ struct strbuf onebuf = STRBUF_INIT;
+ const char *one;
+ if (d->head_path) {
+ one = quote_path(d->head_path, -1, &onebuf, s->prefix);
+ printf("%s -> ", one);
+ strbuf_release(&onebuf);
+ }
+ one = quote_path(it->string, -1, &onebuf, s->prefix);
+ printf("%s\n", one);
+ strbuf_release(&onebuf);
+ }
+}
+
+static void short_untracked(int null_termination, struct string_list_item *it,
+ struct wt_status *s)
+{
+ if (null_termination) {
+ fprintf(stdout, "?? %s%c", it->string, 0);
+ } else {
+ struct strbuf onebuf = STRBUF_INIT;
+ const char *one;
+ one = quote_path(it->string, -1, &onebuf, s->prefix);
+ printf("?? %s\n", one);
+ strbuf_release(&onebuf);
+ }
+}
+
int cmd_stat(int argc, const char **argv, const char *prefix)
{
struct wt_status s;
+ static int null_termination, shortstatus;
+ int i;
unsigned char sha1[20];
static struct option builtin_stat_options[] = {
+ OPT_BOOLEAN('s', "short", &shortstatus,
+ "show status concicely"),
+ OPT_BOOLEAN('z', "null", &null_termination,
+ "terminate entries with NUL"),
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
"mode",
"show untracked files, optional modes: all, normal, no. (Default: all)",
@@ -925,7 +1000,27 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
wt_status_collect(&s);
- wt_status_print_body(&s);
+ if (shortstatus) {
+ for (i = 0; i < s.change.nr; i++) {
+ struct wt_status_change_data *d;
+ struct string_list_item *it;
+
+ it = &(s.change.items[i]);
+ d = it->util;
+ if (d->stagemask)
+ short_unmerged(null_termination, it, &s);
+ else
+ short_status(null_termination, it, &s);
+ }
+ for (i = 0; i < s.untracked.nr; i++) {
+ struct string_list_item *it;
+
+ it = &(s.untracked.items[i]);
+ short_untracked(null_termination, it, &s);
+ }
+ } else {
+ wt_status_print_body(&s);
+ }
return 0;
}
--
1.6.4.173.g72959
^ permalink raw reply related
* [PATCH v3 6/8] git stat: the beginning
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
In-Reply-To: <1249894465-11018-6-git-send-email-gitster@pobox.com>
Tentatively add "git stat" as a new command. This does not munge the
index with paths parameters before showing the status like "git status"
does. In later rounds, we will take path parameters as pathspec to limit
the output.
---
Makefile | 1 +
builtin-commit.c | 60 +++++++++++++++++++++++++++++++++++++++++++++---------
builtin.h | 1 +
git.c | 1 +
wt-status.c | 24 +++++++++++++--------
wt-status.h | 1 +
6 files changed, 69 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index daf4296..39dd334 100644
--- a/Makefile
+++ b/Makefile
@@ -378,6 +378,7 @@ BUILT_INS += git-init$X
BUILT_INS += git-merge-subtree$X
BUILT_INS += git-peek-remote$X
BUILT_INS += git-repo-config$X
+BUILT_INS += git-stat$X
BUILT_INS += git-show$X
BUILT_INS += git-stage$X
BUILT_INS += git-status$X
diff --git a/builtin-commit.c b/builtin-commit.c
index 601118f..bc780a8 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -24,6 +24,7 @@
#include "string-list.h"
#include "rerere.h"
#include "unpack-trees.h"
+#include "quote.h"
static const char * const builtin_commit_usage[] = {
"git commit [options] [--] <filepattern>...",
@@ -35,6 +36,11 @@ static const char * const builtin_status_usage[] = {
NULL
};
+static const char * const builtin_stat_usage[] = {
+ "git stat [options]",
+ NULL
+};
+
static unsigned char head_sha1[20], merge_head_sha1[20];
static char *use_message_buffer;
static const char commit_editmsg[] = "COMMIT_EDITMSG";
@@ -691,6 +697,21 @@ static const char *find_author_by_nickname(const char *name)
die("No existing author found with '%s'", name);
}
+
+static void handle_untracked_files_arg(struct wt_status *s)
+{
+ if (!untracked_files_arg)
+ ; /* default already initialized */
+ else if (!strcmp(untracked_files_arg, "no"))
+ s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
+ else if (!strcmp(untracked_files_arg, "normal"))
+ s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
+ else if (!strcmp(untracked_files_arg, "all"))
+ s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
+ else
+ die("Invalid untracked files mode '%s'", untracked_files_arg);
+}
+
static int parse_and_validate_options(int argc, const char *argv[],
const char * const usage[],
const char *prefix,
@@ -794,16 +815,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
else
die("Invalid cleanup mode %s", cleanup_arg);
- if (!untracked_files_arg)
- ; /* default already initialized */
- else if (!strcmp(untracked_files_arg, "no"))
- s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
- else if (!strcmp(untracked_files_arg, "normal"))
- s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
- else if (!strcmp(untracked_files_arg, "all"))
- s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
- else
- die("Invalid untracked files mode '%s'", untracked_files_arg);
+ handle_untracked_files_arg(s);
if (all && argc > 0)
die("Paths with -a does not make sense.");
@@ -886,6 +898,34 @@ static int git_status_config(const char *k, const char *v, void *cb)
return git_diff_ui_config(k, v, NULL);
}
+int cmd_stat(int argc, const char **argv, const char *prefix)
+{
+ struct wt_status s;
+ unsigned char sha1[20];
+ static struct option builtin_stat_options[] = {
+ { OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
+ "mode",
+ "show untracked files, optional modes: all, normal, no. (Default: all)",
+ PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
+ OPT_END(),
+ };
+
+ wt_status_prepare(&s);
+ git_config(git_status_config, &s);
+ argc = parse_options(argc, argv, prefix,
+ builtin_stat_options,
+ builtin_stat_usage, 0);
+ handle_untracked_files_arg(&s);
+
+ read_cache();
+ refresh_cache(REFRESH_QUIET|REFRESH_UNMERGED);
+ s.is_initial = get_sha1(s.reference, sha1) ? 1 : 0;
+ wt_status_collect(&s);
+
+ wt_status_print_body(&s);
+ return 0;
+}
+
int cmd_status(int argc, const char **argv, const char *prefix)
{
struct wt_status s;
diff --git a/builtin.h b/builtin.h
index 20427d2..eeaf0b6 100644
--- a/builtin.h
+++ b/builtin.h
@@ -95,6 +95,7 @@ extern int cmd_send_pack(int argc, const char **argv, const char *prefix);
extern int cmd_shortlog(int argc, const char **argv, const char *prefix);
extern int cmd_show(int argc, const char **argv, const char *prefix);
extern int cmd_show_branch(int argc, const char **argv, const char *prefix);
+extern int cmd_stat(int argc, const char **argv, const char *prefix);
extern int cmd_status(int argc, const char **argv, const char *prefix);
extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
diff --git a/git.c b/git.c
index 807d875..de7fcf6 100644
--- a/git.c
+++ b/git.c
@@ -350,6 +350,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "shortlog", cmd_shortlog, USE_PAGER },
{ "show-branch", cmd_show_branch, RUN_SETUP },
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
+ { "stat", cmd_stat, RUN_SETUP | NEED_WORK_TREE },
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
{ "stripspace", cmd_stripspace },
{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
diff --git a/wt-status.c b/wt-status.c
index b6ae12c..a5dbdcc 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -531,6 +531,20 @@ static void wt_status_print_tracking(struct wt_status *s)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
}
+void wt_status_print_body(struct wt_status *s)
+{
+ wt_status_print_unmerged(s);
+ wt_status_print_updated(s);
+ wt_status_print_changed(s);
+ if (s->wt_status_submodule_summary)
+ wt_status_print_submodule_summary(s);
+ if (s->show_untracked_files)
+ wt_status_print_untracked(s);
+ else if (s->commitable)
+ fprintf(s->fp,
+ "# Untracked files not listed (use -u option to show untracked files)\n");
+}
+
void wt_status_print(struct wt_status *s)
{
unsigned char sha1[20];
@@ -561,15 +575,7 @@ void wt_status_print(struct wt_status *s)
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
}
- wt_status_print_unmerged(s);
- wt_status_print_updated(s);
- wt_status_print_changed(s);
- if (s->wt_status_submodule_summary)
- wt_status_print_submodule_summary(s);
- if (s->show_untracked_files)
- wt_status_print_untracked(s);
- else if (s->commitable)
- fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
+ wt_status_print_body(s);
if (s->verbose)
wt_status_print_verbose(s);
diff --git a/wt-status.h b/wt-status.h
index 33240b3..44c40ff 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -54,5 +54,6 @@ struct wt_status {
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
void wt_status_collect(struct wt_status *s);
+void wt_status_print_body(struct wt_status *s);
#endif /* STATUS_H */
--
1.6.4.173.g72959
^ permalink raw reply related
* [PATCH v3 5/8] wt-status: collect untracked files in a separate "collect" phase
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
In-Reply-To: <1249894465-11018-5-git-send-email-gitster@pobox.com>
In a way similar to updated and locally modified files are collected.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
wt-status.c | 58 ++++++++++++++++++++++++++++++++++++----------------------
wt-status.h | 3 ++-
2 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 68e4d9b..b6ae12c 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -41,6 +41,7 @@ void wt_status_prepare(struct wt_status *s)
s->fp = stdout;
s->index_file = get_index_file();
s->change.strdup_strings = 1;
+ s->untracked.strdup_strings = 1;
}
static void wt_status_print_unmerged_header(struct wt_status *s)
@@ -311,7 +312,30 @@ static void wt_status_collect_changes_initial(struct wt_status *s)
}
}
-void wt_status_collect_changes(struct wt_status *s)
+static void wt_status_collect_untracked(struct wt_status *s)
+{
+ int i;
+ struct dir_struct dir;
+
+ if (!s->show_untracked_files)
+ return;
+ memset(&dir, 0, sizeof(dir));
+ if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
+ dir.flags |=
+ DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
+ setup_standard_excludes(&dir);
+
+ fill_directory(&dir, NULL);
+ for(i = 0; i < dir.nr; i++) {
+ struct dir_entry *ent = dir.entries[i];
+ if (!cache_name_is_other(ent->name, ent->len))
+ continue;
+ s->workdir_untracked = 1;
+ string_list_insert(ent->name, &s->untracked);
+ }
+}
+
+void wt_status_collect(struct wt_status *s)
{
wt_status_collect_changes_worktree(s);
@@ -319,6 +343,7 @@ void wt_status_collect_changes(struct wt_status *s)
wt_status_collect_changes_initial(s);
else
wt_status_collect_changes_index(s);
+ wt_status_collect_untracked(s);
}
static void wt_status_print_unmerged(struct wt_status *s)
@@ -446,31 +471,20 @@ static void wt_status_print_submodule_summary(struct wt_status *s)
static void wt_status_print_untracked(struct wt_status *s)
{
- struct dir_struct dir;
int i;
- int shown_header = 0;
struct strbuf buf = STRBUF_INIT;
- memset(&dir, 0, sizeof(dir));
- if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
- dir.flags |=
- DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
- setup_standard_excludes(&dir);
+ if (!s->untracked.nr)
+ return;
- fill_directory(&dir, NULL);
- for(i = 0; i < dir.nr; i++) {
- struct dir_entry *ent = dir.entries[i];
- if (!cache_name_is_other(ent->name, ent->len))
- continue;
- if (!shown_header) {
- s->workdir_untracked = 1;
- wt_status_print_untracked_header(s);
- shown_header = 1;
- }
+ wt_status_print_untracked_header(s);
+ for (i = 0; i < s->untracked.nr; i++) {
+ struct string_list_item *it;
+ it = &(s->untracked.items[i]);
color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), "%s",
- quote_path(ent->name, ent->len,
- &buf, s->prefix));
+ quote_path(it->string, strlen(it->string),
+ &buf, s->prefix));
}
strbuf_release(&buf);
}
@@ -539,7 +553,7 @@ void wt_status_print(struct wt_status *s)
wt_status_print_tracking(s);
}
- wt_status_collect_changes(s);
+ wt_status_collect(s);
if (s->is_initial) {
color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
@@ -566,7 +580,7 @@ void wt_status_print(struct wt_status *s)
; /* nothing */
else if (s->workdir_dirty)
printf("no changes added to commit (use \"git add\" and/or \"git commit -a\")\n");
- else if (s->workdir_untracked)
+ else if (s->untracked.nr)
printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
else if (s->is_initial)
printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
diff --git a/wt-status.h b/wt-status.h
index 12dc95e..33240b3 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -48,10 +48,11 @@ struct wt_status {
FILE *fp;
const char *prefix;
struct string_list change;
+ struct string_list untracked;
};
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
-void wt_status_collect_changes(struct wt_status *s);
+void wt_status_collect(struct wt_status *s);
#endif /* STATUS_H */
--
1.6.4.173.g72959
^ permalink raw reply related
* [PATCH v3 4/8] Make git_status_config() file scope static to builtin-commit.c
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
In-Reply-To: <1249894465-11018-4-git-send-email-gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin-commit.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
wt-status.c | 60 ------------------------------------------------------
wt-status.h | 1 -
3 files changed, 60 insertions(+), 61 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index ca36ba2..601118f 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -826,6 +826,66 @@ static int dry_run_commit(int argc, const char **argv, const char *prefix,
return commitable ? 0 : 1;
}
+static int parse_status_slot(const char *var, int offset)
+{
+ if (!strcasecmp(var+offset, "header"))
+ return WT_STATUS_HEADER;
+ if (!strcasecmp(var+offset, "updated")
+ || !strcasecmp(var+offset, "added"))
+ return WT_STATUS_UPDATED;
+ if (!strcasecmp(var+offset, "changed"))
+ return WT_STATUS_CHANGED;
+ if (!strcasecmp(var+offset, "untracked"))
+ return WT_STATUS_UNTRACKED;
+ if (!strcasecmp(var+offset, "nobranch"))
+ return WT_STATUS_NOBRANCH;
+ if (!strcasecmp(var+offset, "unmerged"))
+ return WT_STATUS_UNMERGED;
+ die("bad config variable '%s'", var);
+}
+
+static int git_status_config(const char *k, const char *v, void *cb)
+{
+ struct wt_status *s = cb;
+
+ if (!strcmp(k, "status.submodulesummary")) {
+ int is_bool;
+ s->wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);
+ if (is_bool && s->wt_status_submodule_summary)
+ s->wt_status_submodule_summary = -1;
+ return 0;
+ }
+ if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
+ s->wt_status_use_color = git_config_colorbool(k, v, -1);
+ return 0;
+ }
+ if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
+ int slot = parse_status_slot(k, 13);
+ if (!v)
+ return config_error_nonbool(k);
+ color_parse(v, k, s->wt_status_colors[slot]);
+ return 0;
+ }
+ if (!strcmp(k, "status.relativepaths")) {
+ s->wt_status_relative_paths = git_config_bool(k, v);
+ return 0;
+ }
+ if (!strcmp(k, "status.showuntrackedfiles")) {
+ if (!v)
+ return config_error_nonbool(k);
+ else if (!strcmp(v, "no"))
+ s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
+ else if (!strcmp(v, "normal"))
+ s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
+ else if (!strcmp(v, "all"))
+ s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
+ else
+ return error("Invalid untracked files mode '%s'", v);
+ return 0;
+ }
+ return git_diff_ui_config(k, v, NULL);
+}
+
int cmd_status(int argc, const char **argv, const char *prefix)
{
struct wt_status s;
diff --git a/wt-status.c b/wt-status.c
index a2a7257..68e4d9b 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -19,24 +19,6 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_RED, /* WT_STATUS_UNMERGED */
};
-static int parse_status_slot(const char *var, int offset)
-{
- if (!strcasecmp(var+offset, "header"))
- return WT_STATUS_HEADER;
- if (!strcasecmp(var+offset, "updated")
- || !strcasecmp(var+offset, "added"))
- return WT_STATUS_UPDATED;
- if (!strcasecmp(var+offset, "changed"))
- return WT_STATUS_CHANGED;
- if (!strcasecmp(var+offset, "untracked"))
- return WT_STATUS_UNTRACKED;
- if (!strcasecmp(var+offset, "nobranch"))
- return WT_STATUS_NOBRANCH;
- if (!strcasecmp(var+offset, "unmerged"))
- return WT_STATUS_UNMERGED;
- die("bad config variable '%s'", var);
-}
-
static const char *color(int slot, struct wt_status *s)
{
return s->wt_status_use_color > 0 ? s->wt_status_colors[slot] : "";
@@ -594,45 +576,3 @@ void wt_status_print(struct wt_status *s)
printf("nothing to commit (working directory clean)\n");
}
}
-
-int git_status_config(const char *k, const char *v, void *cb)
-{
- struct wt_status *s = cb;
-
- if (!strcmp(k, "status.submodulesummary")) {
- int is_bool;
- s->wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);
- if (is_bool && s->wt_status_submodule_summary)
- s->wt_status_submodule_summary = -1;
- return 0;
- }
- if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
- s->wt_status_use_color = git_config_colorbool(k, v, -1);
- return 0;
- }
- if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
- int slot = parse_status_slot(k, 13);
- if (!v)
- return config_error_nonbool(k);
- color_parse(v, k, s->wt_status_colors[slot]);
- return 0;
- }
- if (!strcmp(k, "status.relativepaths")) {
- s->wt_status_relative_paths = git_config_bool(k, v);
- return 0;
- }
- if (!strcmp(k, "status.showuntrackedfiles")) {
- if (!v)
- return config_error_nonbool(k);
- else if (!strcmp(v, "no"))
- s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
- else if (!strcmp(v, "normal"))
- s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
- else if (!strcmp(v, "all"))
- s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
- else
- return error("Invalid untracked files mode '%s'", v);
- return 0;
- }
- return git_diff_ui_config(k, v, NULL);
-}
diff --git a/wt-status.h b/wt-status.h
index f22c3c1..12dc95e 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -50,7 +50,6 @@ struct wt_status {
struct string_list change;
};
-int git_status_config(const char *var, const char *value, void *cb);
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
void wt_status_collect_changes(struct wt_status *s);
--
1.6.4.173.g72959
^ permalink raw reply related
* [PATCH v3 3/8] wt-status: move wt_status_colors[] into wt_status structure
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
In-Reply-To: <1249894465-11018-3-git-send-email-gitster@pobox.com>
The benefit of this one alone is somewhat iffy, but for completeness this
moves the wt_status_colors[] color palette to the wt_status structure to
complete what the previous commit started.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
wt-status.c | 9 +++++----
wt-status.h | 2 ++
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index c84a18a..a2a7257 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1,6 +1,5 @@
#include "cache.h"
#include "wt-status.h"
-#include "color.h"
#include "object.h"
#include "dir.h"
#include "commit.h"
@@ -11,7 +10,7 @@
#include "run-command.h"
#include "remote.h"
-static char wt_status_colors[][COLOR_MAXLEN] = {
+static char default_wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
GIT_COLOR_GREEN, /* WT_STATUS_UPDATED */
GIT_COLOR_RED, /* WT_STATUS_CHANGED */
@@ -40,7 +39,7 @@ static int parse_status_slot(const char *var, int offset)
static const char *color(int slot, struct wt_status *s)
{
- return s->wt_status_use_color > 0 ? wt_status_colors[slot] : "";
+ return s->wt_status_use_color > 0 ? s->wt_status_colors[slot] : "";
}
void wt_status_prepare(struct wt_status *s)
@@ -49,6 +48,8 @@ void wt_status_prepare(struct wt_status *s)
const char *head;
memset(s, 0, sizeof(*s));
+ memcpy(s->wt_status_colors, default_wt_status_colors,
+ sizeof(default_wt_status_colors));
s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
s->wt_status_use_color = -1;
s->wt_status_relative_paths = 1;
@@ -613,7 +614,7 @@ int git_status_config(const char *k, const char *v, void *cb)
int slot = parse_status_slot(k, 13);
if (!v)
return config_error_nonbool(k);
- color_parse(v, k, wt_status_colors[slot]);
+ color_parse(v, k, s->wt_status_colors[slot]);
return 0;
}
if (!strcmp(k, "status.relativepaths")) {
diff --git a/wt-status.h b/wt-status.h
index 3d7fe30..f22c3c1 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -3,6 +3,7 @@
#include <stdio.h>
#include "string-list.h"
+#include "color.h"
enum color_wt_status {
WT_STATUS_HEADER,
@@ -37,6 +38,7 @@ struct wt_status {
int wt_status_relative_paths;
int wt_status_submodule_summary;
enum untracked_status_type show_untracked_files;
+ char wt_status_colors[6][COLOR_MAXLEN];
/* These are computed during processing of the individual sections */
int commitable;
--
1.6.4.173.g72959
^ permalink raw reply related
* [PATCH v3 2/8] wt-status: move many global settings to wt_status structure
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
In-Reply-To: <1249894465-11018-2-git-send-email-gitster@pobox.com>
Turn four global variables (wt_status_use_color, show_tracked_files,
wt_status_relative_paths, and wt_status_submodule_summary) into fields of
wt_status structure. Get rid of "untracked" field that was used only to
keep track of otherwise available information redundantly.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin-commit.c | 87 +++++++++++++++++++++++++++++------------------------
wt-status.c | 81 +++++++++++++++++++++++++-------------------------
wt-status.h | 9 +++--
3 files changed, 93 insertions(+), 84 deletions(-)
diff --git a/builtin-commit.c b/builtin-commit.c
index 3a7e35d..ca36ba2 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -343,27 +343,24 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, int
return false_lock.filename;
}
-static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn)
+static int run_status(FILE *fp, const char *index_file, const char *prefix, int nowarn,
+ struct wt_status *s)
{
- struct wt_status s;
-
- wt_status_prepare(&s);
- if (wt_status_relative_paths)
- s.prefix = prefix;
+ if (s->wt_status_relative_paths)
+ s->prefix = prefix;
if (amend) {
- s.amend = 1;
- s.reference = "HEAD^1";
+ s->amend = 1;
+ s->reference = "HEAD^1";
}
- s.verbose = verbose;
- s.untracked = (show_untracked_files == SHOW_ALL_UNTRACKED_FILES);
- s.index_file = index_file;
- s.fp = fp;
- s.nowarn = nowarn;
+ s->verbose = verbose;
+ s->index_file = index_file;
+ s->fp = fp;
+ s->nowarn = nowarn;
- wt_status_print(&s);
+ wt_status_print(s);
- return s.commitable;
+ return s->commitable;
}
static int is_a_merge(const unsigned char *sha1)
@@ -417,7 +414,8 @@ static void determine_author_info(void)
author_date = date;
}
-static int prepare_to_commit(const char *index_file, const char *prefix)
+static int prepare_to_commit(const char *index_file, const char *prefix,
+ struct wt_status *s)
{
struct stat statbuf;
int commitable, saved_color_setting;
@@ -559,10 +557,10 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
if (ident_shown)
fprintf(fp, "#\n");
- saved_color_setting = wt_status_use_color;
- wt_status_use_color = 0;
- commitable = run_status(fp, index_file, prefix, 1);
- wt_status_use_color = saved_color_setting;
+ saved_color_setting = s->wt_status_use_color;
+ s->wt_status_use_color = 0;
+ commitable = run_status(fp, index_file, prefix, 1, s);
+ s->wt_status_use_color = saved_color_setting;
} else {
unsigned char sha1[20];
const char *parent = "HEAD";
@@ -583,7 +581,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
if (!commitable && !in_merge && !allow_empty &&
!(amend && is_a_merge(head_sha1))) {
- run_status(stdout, index_file, prefix, 0);
+ run_status(stdout, index_file, prefix, 0, s);
return 0;
}
@@ -695,7 +693,8 @@ static const char *find_author_by_nickname(const char *name)
static int parse_and_validate_options(int argc, const char *argv[],
const char * const usage[],
- const char *prefix)
+ const char *prefix,
+ struct wt_status *s)
{
int f = 0;
@@ -798,11 +797,11 @@ static int parse_and_validate_options(int argc, const char *argv[],
if (!untracked_files_arg)
; /* default already initialized */
else if (!strcmp(untracked_files_arg, "no"))
- show_untracked_files = SHOW_NO_UNTRACKED_FILES;
+ s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
else if (!strcmp(untracked_files_arg, "normal"))
- show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
+ s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
else if (!strcmp(untracked_files_arg, "all"))
- show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
+ s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
else
die("Invalid untracked files mode '%s'", untracked_files_arg);
@@ -814,13 +813,14 @@ static int parse_and_validate_options(int argc, const char *argv[],
return argc;
}
-static int dry_run_commit(int argc, const char **argv, const char *prefix)
+static int dry_run_commit(int argc, const char **argv, const char *prefix,
+ struct wt_status *s)
{
int commitable;
const char *index_file;
index_file = prepare_index(argc, argv, prefix, 1);
- commitable = run_status(stdout, index_file, prefix, 0);
+ commitable = run_status(stdout, index_file, prefix, 0, s);
rollback_index_files();
return commitable ? 0 : 1;
@@ -828,14 +828,18 @@ static int dry_run_commit(int argc, const char **argv, const char *prefix)
int cmd_status(int argc, const char **argv, const char *prefix)
{
- git_config(git_status_config, NULL);
- if (wt_status_use_color == -1)
- wt_status_use_color = git_use_color_default;
+ struct wt_status s;
+
+ wt_status_prepare(&s);
+ git_config(git_status_config, &s);
+ if (s.wt_status_use_color == -1)
+ s.wt_status_use_color = git_use_color_default;
if (diff_use_color_default == -1)
diff_use_color_default = git_use_color_default;
- argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);
- return dry_run_commit(argc, argv, prefix);
+ argc = parse_and_validate_options(argc, argv, builtin_status_usage,
+ prefix, &s);
+ return dry_run_commit(argc, argv, prefix, &s);
}
static void print_summary(const char *prefix, const unsigned char *sha1)
@@ -887,10 +891,12 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
static int git_commit_config(const char *k, const char *v, void *cb)
{
+ struct wt_status *s = cb;
+
if (!strcmp(k, "commit.template"))
return git_config_string(&template_file, k, v);
- return git_status_config(k, v, cb);
+ return git_status_config(k, v, s);
}
int cmd_commit(int argc, const char **argv, const char *prefix)
@@ -903,21 +909,24 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
struct commit_list *parents = NULL, **pptr = &parents;
struct stat statbuf;
int allow_fast_forward = 1;
+ struct wt_status s;
- git_config(git_commit_config, NULL);
+ wt_status_prepare(&s);
+ git_config(git_commit_config, &s);
- if (wt_status_use_color == -1)
- wt_status_use_color = git_use_color_default;
+ if (s.wt_status_use_color == -1)
+ s.wt_status_use_color = git_use_color_default;
- argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);
+ argc = parse_and_validate_options(argc, argv, builtin_commit_usage,
+ prefix, &s);
if (dry_run)
- return dry_run_commit(argc, argv, prefix);
+ return dry_run_commit(argc, argv, prefix, &s);
index_file = prepare_index(argc, argv, prefix, 0);
/* Set up everything for writing the commit object. This includes
running hooks, writing the trees, and interacting with the user. */
- if (!prepare_to_commit(index_file, prefix)) {
+ if (!prepare_to_commit(index_file, prefix, &s)) {
rollback_index_files();
return 1;
}
diff --git a/wt-status.c b/wt-status.c
index 97fedfa..c84a18a 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -11,9 +11,6 @@
#include "run-command.h"
#include "remote.h"
-int wt_status_relative_paths = 1;
-int wt_status_use_color = -1;
-static int wt_status_submodule_summary;
static char wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_NORMAL, /* WT_STATUS_HEADER */
GIT_COLOR_GREEN, /* WT_STATUS_UPDATED */
@@ -23,8 +20,6 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
GIT_COLOR_RED, /* WT_STATUS_UNMERGED */
};
-enum untracked_status_type show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
-
static int parse_status_slot(const char *var, int offset)
{
if (!strcasecmp(var+offset, "header"))
@@ -43,9 +38,9 @@ static int parse_status_slot(const char *var, int offset)
die("bad config variable '%s'", var);
}
-static const char *color(int slot)
+static const char *color(int slot, struct wt_status *s)
{
- return wt_status_use_color > 0 ? wt_status_colors[slot] : "";
+ return s->wt_status_use_color > 0 ? wt_status_colors[slot] : "";
}
void wt_status_prepare(struct wt_status *s)
@@ -54,6 +49,9 @@ void wt_status_prepare(struct wt_status *s)
const char *head;
memset(s, 0, sizeof(*s));
+ s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
+ s->wt_status_use_color = -1;
+ s->wt_status_relative_paths = 1;
head = resolve_ref("HEAD", sha1, 0, NULL);
s->branch = head ? xstrdup(head) : NULL;
s->reference = "HEAD";
@@ -64,7 +62,7 @@ void wt_status_prepare(struct wt_status *s)
static void wt_status_print_unmerged_header(struct wt_status *s)
{
- const char *c = color(WT_STATUS_HEADER);
+ const char *c = color(WT_STATUS_HEADER, s);
color_fprintf_ln(s->fp, c, "# Unmerged paths:");
if (!s->is_initial)
color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
@@ -76,7 +74,7 @@ static void wt_status_print_unmerged_header(struct wt_status *s)
static void wt_status_print_cached_header(struct wt_status *s)
{
- const char *c = color(WT_STATUS_HEADER);
+ const char *c = color(WT_STATUS_HEADER, s);
color_fprintf_ln(s->fp, c, "# Changes to be committed:");
if (!s->is_initial) {
color_fprintf_ln(s->fp, c, "# (use \"git reset %s <file>...\" to unstage)", s->reference);
@@ -89,7 +87,7 @@ static void wt_status_print_cached_header(struct wt_status *s)
static void wt_status_print_dirty_header(struct wt_status *s,
int has_deleted)
{
- const char *c = color(WT_STATUS_HEADER);
+ const char *c = color(WT_STATUS_HEADER, s);
color_fprintf_ln(s->fp, c, "# Changed but not updated:");
if (!has_deleted)
color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to update what will be committed)");
@@ -101,7 +99,7 @@ static void wt_status_print_dirty_header(struct wt_status *s,
static void wt_status_print_untracked_header(struct wt_status *s)
{
- const char *c = color(WT_STATUS_HEADER);
+ const char *c = color(WT_STATUS_HEADER, s);
color_fprintf_ln(s->fp, c, "# Untracked files:");
color_fprintf_ln(s->fp, c, "# (use \"git add <file>...\" to include in what will be committed)");
color_fprintf_ln(s->fp, c, "#");
@@ -109,7 +107,7 @@ static void wt_status_print_untracked_header(struct wt_status *s)
static void wt_status_print_trailer(struct wt_status *s)
{
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
}
#define quote_path quote_path_relative
@@ -117,13 +115,13 @@ static void wt_status_print_trailer(struct wt_status *s)
static void wt_status_print_unmerged_data(struct wt_status *s,
struct string_list_item *it)
{
- const char *c = color(WT_STATUS_UNMERGED);
+ const char *c = color(WT_STATUS_UNMERGED, s);
struct wt_status_change_data *d = it->util;
struct strbuf onebuf = STRBUF_INIT;
const char *one, *how = "bug";
one = quote_path(it->string, -1, &onebuf, s->prefix);
- color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
+ color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
switch (d->stagemask) {
case 1: how = "both deleted:"; break;
case 2: how = "added by us:"; break;
@@ -142,7 +140,7 @@ static void wt_status_print_change_data(struct wt_status *s,
struct string_list_item *it)
{
struct wt_status_change_data *d = it->util;
- const char *c = color(change_type);
+ const char *c = color(change_type, s);
int status = status;
char *one_name;
char *two_name;
@@ -164,7 +162,7 @@ static void wt_status_print_change_data(struct wt_status *s,
one = quote_path(one_name, -1, &onebuf, s->prefix);
two = quote_path(two_name, -1, &twobuf, s->prefix);
- color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
+ color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
switch (status) {
case DIFF_STATUS_ADDED:
color_fprintf(s->fp, c, "new file: %s", one);
@@ -450,7 +448,7 @@ static void wt_status_print_submodule_summary(struct wt_status *s)
NULL
};
- sprintf(summary_limit, "%d", wt_status_submodule_summary);
+ sprintf(summary_limit, "%d", s->wt_status_submodule_summary);
snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", s->index_file);
memset(&sm_summary, 0, sizeof(sm_summary));
@@ -471,8 +469,7 @@ static void wt_status_print_untracked(struct wt_status *s)
struct strbuf buf = STRBUF_INIT;
memset(&dir, 0, sizeof(dir));
-
- if (!s->untracked)
+ if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES)
dir.flags |=
DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES;
setup_standard_excludes(&dir);
@@ -487,8 +484,8 @@ static void wt_status_print_untracked(struct wt_status *s)
wt_status_print_untracked_header(s);
shown_header = 1;
}
- color_fprintf(s->fp, color(WT_STATUS_HEADER), "#\t");
- color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED), "%s",
+ color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "#\t");
+ color_fprintf_ln(s->fp, color(WT_STATUS_UNTRACKED, s), "%s",
quote_path(ent->name, ent->len,
&buf, s->prefix));
}
@@ -532,15 +529,15 @@ static void wt_status_print_tracking(struct wt_status *s)
return;
for (cp = sb.buf; (ep = strchr(cp, '\n')) != NULL; cp = ep + 1)
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
"# %.*s", (int)(ep - cp), cp);
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
}
void wt_status_print(struct wt_status *s)
{
unsigned char sha1[20];
- const char *branch_color = color(WT_STATUS_HEADER);
+ const char *branch_color = color(WT_STATUS_HEADER, s);
s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
if (s->branch) {
@@ -550,10 +547,10 @@ void wt_status_print(struct wt_status *s)
branch_name += 11;
else if (!strcmp(branch_name, "HEAD")) {
branch_name = "";
- branch_color = color(WT_STATUS_NOBRANCH);
+ branch_color = color(WT_STATUS_NOBRANCH, s);
on_what = "Not currently on any branch.";
}
- color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
+ color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "# ");
color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
if (!s->is_initial)
wt_status_print_tracking(s);
@@ -562,17 +559,17 @@ void wt_status_print(struct wt_status *s)
wt_status_collect_changes(s);
if (s->is_initial) {
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "# Initial commit");
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER), "#");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "# Initial commit");
+ color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), "#");
}
wt_status_print_unmerged(s);
wt_status_print_updated(s);
wt_status_print_changed(s);
- if (wt_status_submodule_summary)
+ if (s->wt_status_submodule_summary)
wt_status_print_submodule_summary(s);
- if (show_untracked_files)
+ if (s->show_untracked_files)
wt_status_print_untracked(s);
else if (s->commitable)
fprintf(s->fp, "# Untracked files not listed (use -u option to show untracked files)\n");
@@ -590,7 +587,7 @@ void wt_status_print(struct wt_status *s)
printf("nothing added to commit but untracked files present (use \"git add\" to track)\n");
else if (s->is_initial)
printf("nothing to commit (create/copy files and use \"git add\" to track)\n");
- else if (!show_untracked_files)
+ else if (!s->show_untracked_files)
printf("nothing to commit (use -u to show untracked files)\n");
else
printf("nothing to commit (working directory clean)\n");
@@ -599,15 +596,17 @@ void wt_status_print(struct wt_status *s)
int git_status_config(const char *k, const char *v, void *cb)
{
+ struct wt_status *s = cb;
+
if (!strcmp(k, "status.submodulesummary")) {
int is_bool;
- wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);
- if (is_bool && wt_status_submodule_summary)
- wt_status_submodule_summary = -1;
+ s->wt_status_submodule_summary = git_config_bool_or_int(k, v, &is_bool);
+ if (is_bool && s->wt_status_submodule_summary)
+ s->wt_status_submodule_summary = -1;
return 0;
}
if (!strcmp(k, "status.color") || !strcmp(k, "color.status")) {
- wt_status_use_color = git_config_colorbool(k, v, -1);
+ s->wt_status_use_color = git_config_colorbool(k, v, -1);
return 0;
}
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
@@ -618,21 +617,21 @@ int git_status_config(const char *k, const char *v, void *cb)
return 0;
}
if (!strcmp(k, "status.relativepaths")) {
- wt_status_relative_paths = git_config_bool(k, v);
+ s->wt_status_relative_paths = git_config_bool(k, v);
return 0;
}
if (!strcmp(k, "status.showuntrackedfiles")) {
if (!v)
return config_error_nonbool(k);
else if (!strcmp(v, "no"))
- show_untracked_files = SHOW_NO_UNTRACKED_FILES;
+ s->show_untracked_files = SHOW_NO_UNTRACKED_FILES;
else if (!strcmp(v, "normal"))
- show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
+ s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES;
else if (!strcmp(v, "all"))
- show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
+ s->show_untracked_files = SHOW_ALL_UNTRACKED_FILES;
else
return error("Invalid untracked files mode '%s'", v);
return 0;
}
- return git_diff_ui_config(k, v, cb);
+ return git_diff_ui_config(k, v, NULL);
}
diff --git a/wt-status.h b/wt-status.h
index f80142f..3d7fe30 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -18,7 +18,6 @@ enum untracked_status_type {
SHOW_NORMAL_UNTRACKED_FILES,
SHOW_ALL_UNTRACKED_FILES
};
-extern enum untracked_status_type show_untracked_files;
struct wt_status_change_data {
int worktree_status;
@@ -33,8 +32,12 @@ struct wt_status {
const char *reference;
int verbose;
int amend;
- int untracked;
int nowarn;
+ int wt_status_use_color;
+ int wt_status_relative_paths;
+ int wt_status_submodule_summary;
+ enum untracked_status_type show_untracked_files;
+
/* These are computed during processing of the individual sections */
int commitable;
int workdir_dirty;
@@ -46,8 +49,6 @@ struct wt_status {
};
int git_status_config(const char *var, const char *value, void *cb);
-extern int wt_status_use_color;
-extern int wt_status_relative_paths;
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
void wt_status_collect_changes(struct wt_status *s);
--
1.6.4.173.g72959
^ permalink raw reply related
* [PATCH v3 1/8] commit: --dry-run
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
In-Reply-To: <1249894465-11018-1-git-send-email-gitster@pobox.com>
This teaches --dry-run option to "git commit".
It is the same as "git status", but in the longer term we would want to
change the semantics of "git status" not to be the preview of commit, and
this is the first step for doing so.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/git-commit.txt | 7 ++++++-
builtin-commit.c | 29 ++++++++++++++++-------------
2 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index b5d81be..d01ff5a 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -8,7 +8,7 @@ git-commit - Record changes to the repository
SYNOPSIS
--------
[verse]
-'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend]
+'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
[(-c | -C) <commit>] [-F <file> | -m <msg>]
[--allow-empty] [--no-verify] [-e] [--author=<author>]
[--cleanup=<mode>] [--] [[-i | -o ]<file>...]
@@ -198,6 +198,11 @@ specified.
--quiet::
Suppress commit summary message.
+--dry-run::
+ Do not create a commit, but show a list of paths that are
+ to be committed, paths with local changes that will be left
+ uncommitted and paths that are untracked.
+
\--::
Do not interpret any more arguments as options.
diff --git a/builtin-commit.c b/builtin-commit.c
index 6d12c2e..3a7e35d 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -51,7 +51,7 @@ static const char *template_file;
static char *edit_message, *use_message;
static char *author_name, *author_email, *author_date;
static int all, edit_flag, also, interactive, only, amend, signoff;
-static int quiet, verbose, no_verify, allow_empty;
+static int quiet, verbose, no_verify, allow_empty, dry_run;
static char *untracked_files_arg;
/*
* The default commit message cleanup mode will remove the lines
@@ -103,6 +103,7 @@ static struct option builtin_commit_options[] = {
OPT_BOOLEAN(0, "interactive", &interactive, "interactively add files"),
OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
+ OPT_BOOLEAN(0, "dry-run", &dry_run, "show what would be committed"),
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
OPT_BOOLEAN(0, "allow-empty", &allow_empty, "ok to record an empty change"),
@@ -813,28 +814,28 @@ static int parse_and_validate_options(int argc, const char *argv[],
return argc;
}
-int cmd_status(int argc, const char **argv, const char *prefix)
+static int dry_run_commit(int argc, const char **argv, const char *prefix)
{
- const char *index_file;
int commitable;
+ const char *index_file;
- git_config(git_status_config, NULL);
+ index_file = prepare_index(argc, argv, prefix, 1);
+ commitable = run_status(stdout, index_file, prefix, 0);
+ rollback_index_files();
+ return commitable ? 0 : 1;
+}
+
+int cmd_status(int argc, const char **argv, const char *prefix)
+{
+ git_config(git_status_config, NULL);
if (wt_status_use_color == -1)
wt_status_use_color = git_use_color_default;
-
if (diff_use_color_default == -1)
diff_use_color_default = git_use_color_default;
argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);
-
- index_file = prepare_index(argc, argv, prefix, 1);
-
- commitable = run_status(stdout, index_file, prefix, 0);
-
- rollback_index_files();
-
- return commitable ? 0 : 1;
+ return dry_run_commit(argc, argv, prefix);
}
static void print_summary(const char *prefix, const unsigned char *sha1)
@@ -909,6 +910,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
wt_status_use_color = git_use_color_default;
argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);
+ if (dry_run)
+ return dry_run_commit(argc, argv, prefix);
index_file = prepare_index(argc, argv, prefix, 0);
--
1.6.4.173.g72959
^ permalink raw reply related
* [PATCH v3 0/8] shortstatus updates
From: Junio C Hamano @ 2009-08-10 8:54 UTC (permalink / raw)
To: git
Another round of "git status won't be a preview of git commit someday".
This builds on the part that are already in 'pu', and is queued in 'pu'.
Junio C Hamano (8):
commit: --dry-run
wt-status: move many global settings to wt_status structure
wt-status: move wt_status_colors[] into wt_status structure
Make git_status_config() file scope static to builtin-commit.c
wt-status: collect untracked files in a separate "collect" phase
git stat: the beginning
git stat: pathspec limits, unlike traditional "git status"
git stat -s: short status output
Documentation/git-commit.txt | 7 +-
Makefile | 1 +
builtin-commit.c | 312 +++++++++++++++++++++++++++++++++++-------
builtin.h | 1 +
git.c | 1 +
wt-status.c | 206 ++++++++++++----------------
wt-status.h | 17 ++-
7 files changed, 367 insertions(+), 178 deletions(-)
^ permalink raw reply
* Re: [PATCH v2] push: point to 'git pull' and 'git push --force' in case of non-fast forward
From: Junio C Hamano @ 2009-08-10 8:49 UTC (permalink / raw)
To: Matthieu Moy; +Cc: Teemu Likonen, git
In-Reply-To: <vpq8whsawjs.fsf@bauges.imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> If you read "Integrate them with your changes" and understand that it is
>> talking about "git pull" or "git pull --rebase", then you do not have to
>> read the doc. It should "click".
>
> But what's the point is being so vague, while you could just add "(see
> git pull)"? See what you've just wrote: one should "understand that it
> is about ...". So, why write Y thinking that the user should
> understand that it is about X while you could write X directly?
In order to cover both "pull" and "pull --rebase"?
^ permalink raw reply
* Re: [PATCH 5/8] Add a config option for remotes to specify a foreign vcs
From: Junio C Hamano @ 2009-08-10 8:47 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: git, Brian Gernhardt, Johan Herland, Johannes Schindelin
In-Reply-To: <alpine.LNX.2.00.0908092153520.27553@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
> I think that users should never need to know the names of the helpers. I
> mean, the native protocol uses helpers that most users are completely
> unaware of. The users do need to know what the
... heck ;-)?
But seriously, why not?
> The problem is not that foreign systems don't have "urls" in particular.
> The problem is that there are foreign systems, like perforce, where the
> lines between different repositories in the git sense are drawn in very
> different ways. In perforce, for example, there is a single namespace for
> all branches of all projects hosted on the same server. It's like...
> ...
> (and hundreds more, mixing all the branches of all of the repositories
> for all of the projects, without any conventions beyond what the
> community on the particular server made up)
That looks similar to a subversion server with multiple projects with
multiple branches, and they seem to be able to use
"svn://<whatever svn uses as its own convention>"
just fine.
Why p4 cannot do what svn can? Doesn't p4 ever "name" a repository/branch
inside that "single namespace" with a simple string that is easy to
remember for users? And if there is one, I do not see what prevents you
from using "p4://<whatever information p4 users use>"?
> You really need a different sort of configuration option to specify what
> we think of as "the git.git repository", which includes certain branches
> and doesn't include other projects hosted on kernel.org. And in order to
> find the server, it uses an arbitrary shell command line that acts like
> rsh (and often consists of "ssh" as the command and a bunch of complicated
> options to connect to the right port of the right host to get the right
> restricted shell with the right preset environment). So there's nothing
> you can put in the <whatever string the helper understands> part, because
> the helper really has to figure out what it's doing from a bunch of
> options.
>
> Furthermore, I don't want to just use "p4:" as what people should use in
> remote.*.url in order to select the right helper, because then people are
> going to have different remotes with the same url option value in order to
> access entirely different data.
Maybe it is the _primary_ itch you would want to scratch, but this does
sound like a very special case that wants to have multiple pieces of
pre-parsed information to identify a "repository".
Perhaps in such a case it would be equally valid if you said "p4:hello"
and "p4:goodbye" to identify two "repositories", with p4-helper specific
configuration option that is keyed off of of p4.hello.* and p4.goodbye.*
namespace, e.g. (without knowing p4 at all)
[remote "origin"]
url = p4:hello
[p4 "hello"]
find-server-command = ssh bunch of complicated options
random-p4-option = ...
random-other-p4-option = ...
Of course it does not have to be called "url", and you could do the same
thing with:
[remote "origin"]
vcs = p4
[p4 "origin"]
find-server-command = ssh bunch of complicated options
random-p4-option = ...
random-other-p4-option = ...
And probably there aren't much difference either way between these two
appraoches. The former gives an extra name ("hello") that may simply be
redundant, or perhaps adds value by descriptive, depending on your
viewpoint.
^ permalink raw reply
* Re: [PATCH v2] push: point to 'git pull' and 'git push --force' in case of non-fast forward
From: Matthieu Moy @ 2009-08-10 8:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Teemu Likonen, git
In-Reply-To: <7vljls7n4v.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> If you read "Integrate them with your changes" and understand that it is
> talking about "git pull" or "git pull --rebase", then you do not have to
> read the doc. It should "click".
But what's the point is being so vague, while you could just add "(see
git pull)"? See what you've just wrote: one should "understand that it
is about ...". So, why write Y thinking that the user should
understand that it is about X while you could write X directly?
--
Matthieu
^ permalink raw reply
* Re: [PATCH] svn: allow git-svn to update remotes outside of refs/remotes
From: Eric Wong @ 2009-08-10 8:38 UTC (permalink / raw)
To: Adam Brewster; +Cc: git
In-Reply-To: <1249350039-7338-4-git-send-email-adambrewster@gmail.com>
Adam Brewster <adambrewster@gmail.com> wrote:
> It may be convenient for some users to store svn remote tracking
> branches outside of the refs/remotes/ heirarchy. [1] and [2] indicate
> that there is interest in making this possible.
>
> [1] http://www.gitready.com/advanced/2009/02/16/convert-git-svn-tag-branches-to-real-tags.html
> [2] http://kerneltrap.org/mailarchive/git/2007/8/30/256359
I definitely agree with the direction of this...
We'll need a mechanism for migrating existing repos from
.git/svn/foo/* => .git/svn/refs/remotes/foo/* to avoid breaking
things for people with existing repos. I guess that's why
you've been looking at (and helping fix) the migrate test :)
--
Eric Wong
^ permalink raw reply
* backups with git
From: Roald de Vries @ 2009-08-10 8:27 UTC (permalink / raw)
To: git
Dear all,
I'm thinking of using git as a backup solution for my whole system,
setting my $GIT_DIR to something like "/backupdisc/backup". Does that
seem sensible? In his Google tech talk, Linus said that git was not
good at huge projects; I guess that would apply to backups. On the
other hand, maybe a backup doesn't need to be as fast as he wants git
to be for projects. Has anybody used git like this? And was it a good
experience?
Kind regards,
Roald
^ permalink raw reply
* Re: [PATCH] svn: Add && to t9107-git-svn-migrarte.sh
From: Eric Wong @ 2009-08-10 8:32 UTC (permalink / raw)
To: Adam Brewster; +Cc: git
In-Reply-To: <20090806212841.GA13437@dcvr.yhbt.net>
Eric Wong <normalperson@yhbt.net> wrote:
> Adam Brewster <adambrewster@gmail.com> wrote:
> > It was probably intended for the test to fail unless all of the
> > commands succeed.
>
> I think you've uncovered some major breakage in this test that never got
> noticed until now. I'll try to take a harder look tonight or this
> weekend.
>
> Fortunately, this functionality is rarely needed these days :)
> Thanks for the heads up!
Actually, the test should look like this, I'll push it out
along with the other one in a few.
>From 4ebe6e92c3b62d5192b6cc8158fde701bf2c0dcb Mon Sep 17 00:00:00 2001
From: Adam Brewster <adambrewster@gmail.com>
Date: Mon, 3 Aug 2009 21:40:37 -0400
Subject: [PATCH] svn: Add && to t9107-git-svn-migrate.sh
It was probably intended for the test to fail unless all of the
commands succeed.
[ew: fixed tests to actually work]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
t/t9107-git-svn-migrate.sh | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh
index 3a9e077..c0098d9 100755
--- a/t/t9107-git-svn-migrate.sh
+++ b/t/t9107-git-svn-migrate.sh
@@ -56,7 +56,15 @@ test_expect_success 'initialize a multi-repository repo' '
git config --add svn-remote.svn.fetch "branches/b:refs/remotes/b" &&
for i in tags/0.1 tags/0.2 tags/0.3; do
git config --add svn-remote.svn.fetch \
- $i:refs/remotes/$i || exit 1; done
+ $i:refs/remotes/$i || exit 1; done &&
+ git config --get-all svn-remote.svn.fetch > fetch.out &&
+ grep "^trunk:refs/remotes/trunk$" fetch.out &&
+ grep "^branches/a:refs/remotes/a$" fetch.out &&
+ grep "^branches/b:refs/remotes/b$" fetch.out &&
+ grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
+ grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
+ grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
+ grep "^:refs/${remotes_git_svn}" fetch.out
'
# refs should all be different, but the trees should all be the same:
@@ -86,14 +94,14 @@ test_expect_success 'migrate --minimize on old inited layout' '
echo "$svnrepo"$path > "$GIT_DIR"/svn/$ref/info/url ) || exit 1;
done &&
git svn migrate --minimize &&
- test -z "`git config -l |grep -v "^svn-remote\.git-svn\."`" &&
+ test -z "`git config -l | grep "^svn-remote\.git-svn\."`" &&
git config --get-all svn-remote.svn.fetch > fetch.out &&
grep "^trunk:refs/remotes/trunk$" fetch.out &&
grep "^branches/a:refs/remotes/a$" fetch.out &&
grep "^branches/b:refs/remotes/b$" fetch.out &&
grep "^tags/0\.1:refs/remotes/tags/0\.1$" fetch.out &&
grep "^tags/0\.2:refs/remotes/tags/0\.2$" fetch.out &&
- grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out
+ grep "^tags/0\.3:refs/remotes/tags/0\.3$" fetch.out &&
grep "^:refs/${remotes_git_svn}" fetch.out
'
--
Eric Wong
^ permalink raw reply related
* Re: [PATCH 5/8] Add a config option for remotes to specify a foreign vcs
From: Johan Herland @ 2009-08-10 8:32 UTC (permalink / raw)
To: git; +Cc: Daniel Barkalow, Junio C Hamano, Brian Gernhardt,
Johannes Schindelin
In-Reply-To: <alpine.LNX.2.00.0908092153520.27553@iabervon.org>
On Monday 10 August 2009, Daniel Barkalow wrote:
> On Sun, 9 Aug 2009, Junio C Hamano wrote:
> > Daniel Barkalow <barkalow@iabervon.org> writes:
> > > If this is set, the url is not required, and the transport always
> > > uses a helper named "git-remote-<value>".
> > >
> > > It is a separate configuration option in order to allow a sensible
> > > configuration for foreign systems which either have no meaningful
> > > urls for repositories or which require urls that do not specify the
> > > system used by the repository at that location. However, this only
> > > affects how the name of the helper is determined, not anything about
> > > the interaction with the helper, and the contruction is such that, if
> > > the foreign scm does happen to use a co-named url method, a url with
> > > that method may be used directly.
> >
> > Personally, I do not like this.
> >
> > Why isn't it enough to define the canonical remote name git takes as
> > "<name of the helper>:<whatever string the helper understands>"?
>
> [...]
>
> The only way I've been able to come up with to support this at all
> usefully is to have a bunch of helper-specific options that specify what
> the helper needs to know about the locations you consider to be part of
> the project and an option that tells git that this remote uses the p4
> helper. I'm not sure what makes sense for other helpers, but the case I
> actually use needs something like what's in this patch.
I'm somewhat agnostic on this issue. At the moment, I follow the P4 cues,
and use a config like this:
[remote "foo"]
vcs = cvs
cvsRoot = ":pserver:user@cvs.server.example.com/var/cvs/cvsroot"
cvsModule = "bar"
...
But I could just as well use a config like this instead:
[remote "foo"]
url = "cvs::pserver:user@cvs.server.example.com/var/cvs/cvsroot#bar"
...
Either is fine with me, although I suspect users might find the
current/first alternative easier to parse.
> I think it makes sense for svn access to support just having a url
> option like "svn://something (svn native protocol)", or
> "svn+ssh://something (svn protocol over ssh)" or "svn+https://something
> (https access to a svn repo)", or some other similar syntax, but this is
> a poor fit for p4.
>
> In order to support this, there just needs to be a call to check whether
> "remote-<something>" is an available git command (without running it or
> giving an error), and the helper code should be used if it is. This is
> actually required so that people with workstations whose domain is
> .kernel.org and who have cloned "master:/home/linus/something.git" don't
> start getting "remote-master isn't a git command" errors (that is,
> misinterpreting ssh-format location hostnames as helper names. Johan,
> perhaps you could write that for your CVS helper?
Sorry, not following you here. Write exactly what?
- The code in the transport layer for checking if "remote-<something>"
is an available git command?
- The code in my CVS helper for handling the ssh-format misinterpretation,
i.e. the case where someone has a git/ssh server called "cvs"? If so,
how should this be handled?
> I think that, ideally, helpers for foreign systems would be portable
> across multiple native systems. The svn helper could be a program
> "svn-remote-access-helper", and anything that speaks fast-import (e.g.,
> bzr or hg) would be able to use it. When installing it for git, you'd
> symlink it to git-remote-svn; if you decided to install
> "svn-remote-access-helper-ng", you'd change the symlink.
In that case, helpers must keep their metadata in a repo-independent
format. Currently that is outside the scope of my CVS helper, since I'm
leveraging git-notes for most of the CVS helper's metadata.
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
^ permalink raw reply
* gitweb stops working sometimes
From: Erez Zilber @ 2009-08-10 8:01 UTC (permalink / raw)
To: git
Hi,
I'm running gitweb on a centos 5.3 server and it works well 99% of the
time. Sometimes, I see the following behavior:
1. I'm able to load the page that shows all git trees.
2. When I click on one of the links that should show a specific tree,
it opens a page with the following text: "<div
class="title"> </div>
"
If I restart httpd, it doesn't help. The only solution that I found so
far is to reboot the server and then everything works. However,
rebooting the server is a bad solution.
Any idea?
Thanks,
Erez
^ permalink raw reply
* Re: [PATCH] fix potential infinite loop given large unsigned integer
From: Christian Couder @ 2009-08-10 5:24 UTC (permalink / raw)
To: Erik Faye-Lund; +Cc: Junio C Hamano, Ryan Flynn, git
In-Reply-To: <40aa078e0908090525h7b4d6efeh658e2edcfbe16c7e@mail.gmail.com>
On Sunday 09 August 2009, Erik Faye-Lund wrote:
> On Sun, Aug 9, 2009 at 9:38 AM, Junio C Hamano<gitster@pobox.com> wrote:
> > + static char num_buf[64];
> > rev.total = total + start_number - 1;
> > + sprintf(num_buf, "%d", rev.total);
> > + rev.num_width = strlen(num_buf);
>
> how about
> rev.num_width = (int)log10((double)rev.total) + 1;
>
> hm?
>
> log10() appears to be C99, but can be emulated on earlier C-versions by
> doing #define log10(x) (log(x) / log(10.0))
That would mean linking with -lm?
Regards,
Christian.
^ permalink raw reply
* [PATCH] git-instaweb: detect difference between mod_cgi and mod_cgid for apache2
From: Mark A Rada @ 2009-08-10 5:19 UTC (permalink / raw)
To: git
I'm not sure if this should have been two patches or just one.
First I changed the check of whether mod_cgi is built in or not from
matching against
'mod_cgi.c' to 'mod_cgi' because I made the assumption that mod_cgid
would be called
'mod_cgid.c' (I haven't actually checked this, but it sounds
reasonable). Then, the
second change handles the two cases when no cgi module is built in,
which I did try
(for mod_cgid that is).
Also, should the socket needed for mod_cgid be put in $GIT_DIR or
somewhere else?
tl;dr I only actually tried 1/4 cases, everything else looks reasonable
--
Mark A Rada (ferrous26)
marada@uwaterloo.ca
--->8---
Some people have mod_cgid in place of mod_cgi, this will check which one
the user has available to them first, and then act accordingly.
Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
git-instaweb.sh | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/git-instaweb.sh b/git-instaweb.sh
index 5f5cac7..fdac0d0 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -297,8 +297,14 @@ EOF
# plain-old CGI
resolve_full_httpd
list_mods=$(echo "$full_httpd" | sed "s/-f$/-l/")
- $list_mods | grep 'mod_cgi\.c' >/dev/null 2>&1 || \
- echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
+ $list_mods | grep 'mod_cgi' >/dev/null 2>&1 || \
+ if test -f "$module_path/mod_cgi.so"
+ then
+ echo "LoadModule cgi_module $module_path/mod_cgi.so" >> "$conf"
+ else
+ echo "LoadModule cgi_module $module_path/mod_cgid.so" >> "$conf"
+ echo "ScriptSock $GIT_DIR/gitweb.sock" >> "$conf"
+ fi
cat >> "$conf" <<EOF
AddHandler cgi-script .cgi
<Location /gitweb.cgi>
--
1.6.4
^ permalink raw reply related
* Re: Implementing $Date$ substitution - problem with git status
From: Peter Krefting @ 2009-08-10 4:41 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Git List
In-Reply-To: <200908092252.58363.j6t@kdbg.org>
Johannes Sixt:
> The clean filter is applied before 'git diff' generates the diff. Since you
> have unstaged changes (I take [...] to mean this), you see a new date on
> every invocation.
Sorry for being unclear; no, the $Date$ line is the only change that shows
up. I removed the surrounding context because I didn't want to publish them.
On another machine, there is another file that exhibits the same problem.
> After 'git add .htaccess' subsequent 'git diff' should not show any changes.
But then I need to check it in again, and I'd like to avoid that, if possible.
Is it possible to have a filter run on "commit" instead of "add"? (Or is
"commit" just moving changes from the index to the repository, making that
impossible?)
>> Doing "git reset --hard" or "git checkout master filename" does not
>> help, the file is still believed to be modified by git.
>
> Now, that's an entirely different problem, and I think that there is a
> bug. I have observed this as well with my own clean filter sometimes, but
> not always. I haven't found a recipe that reliably exhibits the problem.
It seems to be triggered by using my date script and doing
git add file
git commit file
git reset --hard file
the last command gives me a local copy with the keyword expanded, but marked
dirty.
Is it possible to have "git add" expand the keyword (both the Git-internal
"ident", i.e "$Id$", and my "$Date$")? Would duplicating the "clean" filter
as a "smudge" one accomplish that?
--
\\// Peter - http://www.softwolves.pp.se/
^ permalink raw reply
* [JGIT PATCH 1/1] Generate javadoc when making jgit. Also, package docs into a zip for distribution.
From: Nicholas Campbell @ 2009-08-10 4:32 UTC (permalink / raw)
To: git; +Cc: Shawn O. Pearce, Robin Rosenberg
Runs through defined "PLUGINS" and creates Javadoc. Assumes src is a subdir.
Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
---
make_jgit.sh | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/make_jgit.sh b/make_jgit.sh
index baaa3af..25ac15c 100755
--- a/make_jgit.sh
+++ b/make_jgit.sh
@@ -3,6 +3,7 @@
O_CLI=jgit
O_JAR=jgit.jar
O_SRC=jgit_src.zip
+O_DOC=jgit_docs.zip
PLUGINS="
org.spearce.jgit
@@ -119,3 +120,12 @@ mv $O_CLI+ $O_CLI &&
echo "Created $O_CLI." || die "Build failed."
cleanup_bin
+
+echo "Build Docs"
+for p in $PLUGINS; do
+ javadoc -sourcepath "$p/src/" -d "docs/$p/" `find "$p/src" -name "*.java"`
+done
+
+jar cf "$O_DOC" docs/
+echo "Created $O_DOC."
+
--
1.6.0.4
^ permalink raw reply related
* Re: [PATCH 5/8] Add a config option for remotes to specify a foreign vcs
From: Daniel Barkalow @ 2009-08-10 4:30 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Brian Gernhardt, Johan Herland, Johannes Schindelin
In-Reply-To: <7v1vnk79lt.fsf@alter.siamese.dyndns.org>
On Sun, 9 Aug 2009, Junio C Hamano wrote:
> Daniel Barkalow <barkalow@iabervon.org> writes:
>
> > If this is set, the url is not required, and the transport always uses
> > a helper named "git-remote-<value>".
> >
> > It is a separate configuration option in order to allow a sensible
> > configuration for foreign systems which either have no meaningful urls
> > for repositories or which require urls that do not specify the system
> > used by the repository at that location. However, this only affects
> > how the name of the helper is determined, not anything about the
> > interaction with the helper, and the contruction is such that, if the
> > foreign scm does happen to use a co-named url method, a url with that
> > method may be used directly.
>
> Personally, I do not like this.
>
> Why isn't it enough to define the canonical remote name git takes as
> "<name of the helper>:<whatever string the helper understands>"?
I think that users should never need to know the names of the helpers. I
mean, the native protocol uses helpers that most users are completely
unaware of. The users do need to know what the
> Then <whatever string the helper understands> part does not have to
> resemble URL at all, if the foreign system does not have such a concept
> (i.e. "have no meaning urls for repositories").
The problem is not that foreign systems don't have "urls" in particular.
The problem is that there are foreign systems, like perforce, where the
lines between different repositories in the git sense are drawn in very
different ways. In perforce, for example, there is a single namespace for
all branches of all projects hosted on the same server. It's like if
kernel.org had branches:
- git-master
- linux-master
- git-next
- linux-next
- linux-rt
- git-pu
- linux-stable
- sparse-master
(and hundreds more, mixing all the branches of all of the repositories
for all of the projects, without any conventions beyond what the
community on the particular server made up)
You really need a different sort of configuration option to specify what
we think of as "the git.git repository", which includes certain branches
and doesn't include other projects hosted on kernel.org. And in order to
find the server, it uses an arbitrary shell command line that acts like
rsh (and often consists of "ssh" as the command and a bunch of complicated
options to connect to the right port of the right host to get the right
restricted shell with the right preset environment). So there's nothing
you can put in the <whatever string the helper understands> part, because
the helper really has to figure out what it's doing from a bunch of
options.
Furthermore, I don't want to just use "p4:" as what people should use in
remote.*.url in order to select the right helper, because then people are
going to have different remotes with the same url option value in order to
access entirely different data.
The only way I've been able to come up with to support this at all
usefully is to have a bunch of helper-specific options that specify what
the helper needs to know about the locations you consider to be part of
the project and an option that tells git that this remote uses the p4
helper. I'm not sure what makes sense for other helpers, but the case I
actually use needs something like what's in this patch.
I think it makes sense for svn access to support just having a url
option like "svn://something (svn native protocol)", or
"svn+ssh://something (svn protocol over ssh)" or "svn+https://something
(https access to a svn repo)", or some other similar syntax, but this is a
poor fit for p4.
In order to support this, there just needs to be a call to check whether
"remote-<something>" is an available git command (without running it or
giving an error), and the helper code should be used if it is. This is
actually required so that people with workstations whose domain is
.kernel.org and who have cloned "master:/home/linus/something.git" don't
start getting "remote-master isn't a git command" errors (that is,
misinterpreting ssh-format location hostnames as helper names. Johan,
perhaps you could write that for your CVS helper?
> Your "let's eject curl based transport out of core" helper (already in
> 'next') will become something like these in the canonical form:
>
> curl:http://git.kernel.org/pub/scm/git/git.git
> curl:ftp://git.kernel.org/pub/scm/git/git.git
> curl:https://git.kernel.org/pub/scm/git/git.git
>
> that are handled by a single helper binary git-remote-curl, but nobody has
> to use these canonical forms for well-known transports, because we can
> have an obvious set of backward-compatible synonyms that are understood by
> the transport layer to choose that helper program, so that usual
>
> http://git.kernel.org/pub/scm/git/git.git
>
> will be understood to choose git-remote-curl backend. We do not need to
> have three git-remote-{http,https,ftp} helpers at all.
>
> That way, a Subversion repository people may want to interact with would
> be spelled, if the helper is "git-remote-svn", like this:
>
> svn:https://scummvm.svn.sourceforge.net/svnroot/scummvm/
>
> and it would be crystal clear that it is not a git native repository that
> is accessed over curl based walkers, and also the folks who still have not
> migrated to git can simply drop the leading "svn:" and learn the name of
> the repository they could access natively with Subversion. Nobody on the
> Subversion side would think svn:https://... is the URL to use with
> Subversion (after all they will see that on the communication in the git
> circle).
>
> And from the git side, we can tell users: "if you want to interact with
> Subversion repositories, you can use traditional git-svn, or you can use
> the unified remote mechanism. To use the latter, just prefix 'svn:' in
> front of the URL used to refer to the repository in the Subversion world".
>
> If you spell the "URL" as https://scummvm.svn.sourceforge.net/svnroot/scummvm/
> then you wouldn't be able to give that directly to git from the command
> line, without using this new configuration. I do not quite understand why
> this indirection is desired. I think it only confuses users.
As I said above, I think that just picking the start off of the URL is a
good solution for systems where the remote repository has a location, but
that's not every system, and not the one that's my personal itch.
> I recall somebody earlier mentioned a possibility to have more than one
> helper that deals with one type of foreign system. In such a case, a pair
> of URL and vcs configuration can be used to identify what helper to use on
> what foreign "repository":
>
> (https://scummvm.svn.sourceforge.net/svnroot/scummvm/, svn)
> (https://scummvm.svn.sourceforge.net/svnroot/scummvm/, svn-ng)
>
> and it might become easier to switch the helper without changing the URL
> part. But I do not particularly think that would be a practical
> advantage, unless we can assume that the next-generation version of the
> helper can somehow reuse the metadata the old version of the helper left
> in the repository and incrementally operate on the repository. Even in
> that case, I think spelling everything out in a single configuration
> (i.e.. remote.$name.url) would make it clearer to see what is going on.
I think that, ideally, helpers for foreign systems would be portable
across multiple native systems. The svn helper could be a program
"svn-remote-access-helper", and anything that speaks fast-import (e.g.,
bzr or hg) would be able to use it. When installing it for git, you'd
symlink it to git-remote-svn; if you decided to install
"svn-remote-access-helper-ng", you'd change the symlink.
Of course, there's a long way to go before helpers can be portable in this
direction, but I think it's mostly tractable and good for making the code
clean.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox