* [PATCH 4/8] Teach git var about GIT_PAGER
From: Jonathan Nieder @ 2009-10-31 1:41 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031012050.GA5160@progeny.tock>
Expose the command found by setup_pager() for scripts to use.
Scripts can use this to avoid repeating the logic to look for a
proper pager in each command.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
No changes from the last version sent.
Documentation/git-var.txt | 6 ++++++
cache.h | 1 +
| 18 +++++++++++++++---
var.c | 10 ++++++++++
4 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt
index 89e4b4f..ef6aa81 100644
--- a/Documentation/git-var.txt
+++ b/Documentation/git-var.txt
@@ -44,6 +44,12 @@ GIT_EDITOR::
environment variable, then `core.editor` configuration, then
`$VISUAL`, then `$EDITOR`, and then finally 'vi'.
+GIT_PAGER::
+ Text viewer for use by git commands (e.g., 'less'). The value
+ is meant to be interpreted by the shell. The order of preference
+ is the `$GIT_PAGER` environment variable, then `core.pager`
+ configuration, then `$PAGER`, and then finally 'less'.
+
Diagnostics
-----------
You don't exist. Go away!::
diff --git a/cache.h b/cache.h
index 311cfe1..5aaa4ba 100644
--- a/cache.h
+++ b/cache.h
@@ -751,6 +751,7 @@ extern const char *git_committer_info(int);
extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
extern const char *fmt_name(const char *name, const char *email);
extern const char *git_editor(void);
+extern const char *git_pager(void);
struct checkout {
const char *base_dir;
--git a/pager.c b/pager.c
index 86facec..0b63d99 100644
--- a/pager.c
+++ b/pager.c
@@ -44,12 +44,14 @@ static void wait_for_pager_signal(int signo)
raise(signo);
}
-void setup_pager(void)
+const char *git_pager(void)
{
- const char *pager = getenv("GIT_PAGER");
+ const char *pager;
if (!isatty(1))
- return;
+ return NULL;
+
+ pager = getenv("GIT_PAGER");
if (!pager) {
if (!pager_program)
git_config(git_default_config, NULL);
@@ -60,6 +62,16 @@ void setup_pager(void)
if (!pager)
pager = "less";
else if (!*pager || !strcmp(pager, "cat"))
+ pager = NULL;
+
+ return pager;
+}
+
+void setup_pager(void)
+{
+ const char *pager = git_pager();
+
+ if (!pager)
return;
spawned_pager = 1; /* means we are emitting to terminal */
diff --git a/var.c b/var.c
index 399f409..facec11 100644
--- a/var.c
+++ b/var.c
@@ -23,6 +23,15 @@ static const char *editor(int flag)
return pgm;
}
+static const char *pager(int flag)
+{
+ const char *pgm = git_pager();
+
+ if (!pgm)
+ pgm = "cat";
+ return pgm;
+}
+
struct git_var {
const char *name;
const char *(*read)(int);
@@ -31,6 +40,7 @@ static struct git_var git_vars[] = {
{ "GIT_COMMITTER_IDENT", git_committer_info },
{ "GIT_AUTHOR_IDENT", git_author_info },
{ "GIT_EDITOR", editor },
+ { "GIT_PAGER", pager },
{ "", NULL },
};
--
1.6.5.2
^ permalink raw reply related
* [PATCH 5/8] add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR"
From: Jonathan Nieder @ 2009-10-31 1:42 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031012050.GA5160@progeny.tock>
Use the new "git var GIT_EDITOR" feature to decide what editor to
use, instead of duplicating its logic elsewhere. This should make
the behavior of commands in edge cases (e.g., editor names with
spaces) a little more consistent.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Documentation/config.txt | 4 +---
Documentation/git-commit.txt | 2 +-
Documentation/git-send-email.txt | 4 ++--
contrib/fast-import/git-p4 | 5 +----
git-add--interactive.perl | 3 +--
git-send-email.perl | 3 ++-
git-sh-setup.sh | 19 ++++++-------------
git-svn.perl | 5 ++---
8 files changed, 16 insertions(+), 29 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index d1e2120..5181b77 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -387,9 +387,7 @@ core.editor::
Commands such as `commit` and `tag` that lets you edit
messages by launching an editor uses the value of this
variable when it is set, and the environment variable
- `GIT_EDITOR` is not set. The order of preference is
- `GIT_EDITOR` environment, `core.editor`, `VISUAL` and
- `EDITOR` environment variables and then finally `vi`.
+ `GIT_EDITOR` is not set. See linkgit:git-var[1].
core.pager::
The command that git will use to paginate output. Can
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 0578a40..3ea80c8 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -323,7 +323,7 @@ ENVIRONMENT AND CONFIGURATION VARIABLES
The editor used to edit the commit log message will be chosen from the
GIT_EDITOR environment variable, the core.editor configuration variable, the
VISUAL environment variable, or the EDITOR environment variable (in that
-order).
+order). See linkgit:git-var[1] for details.
HOOKS
-----
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 767cf4d..c85d7f4 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -60,8 +60,8 @@ The --bcc option must be repeated for each user you want on the bcc list.
The --cc option must be repeated for each user you want on the cc list.
--compose::
- Use $GIT_EDITOR, core.editor, $VISUAL, or $EDITOR to edit an
- introductory message for the patch series.
+ Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
+ to edit an introductory message for the patch series.
+
When '--compose' is used, git send-email will use the From, Subject, and
In-Reply-To headers specified in the message. If the body of the message
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index e710219..48059d0 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -729,13 +729,10 @@ class P4Submit(Command):
tmpFile.write(submitTemplate + separatorLine + diff + newdiff)
tmpFile.close()
mtime = os.stat(fileName).st_mtime
- defaultEditor = "vi"
- if platform.system() == "Windows":
- defaultEditor = "notepad"
if os.environ.has_key("P4EDITOR"):
editor = os.environ.get("P4EDITOR")
else:
- editor = os.environ.get("EDITOR", defaultEditor);
+ editor = read_pipe("git var GIT_EDITOR")
system(editor + " " + fileName)
response = "y"
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 69aeaf0..0c74e5c 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -987,8 +987,7 @@ sub edit_hunk_manually {
EOF
close $fh;
- my $editor = $ENV{GIT_EDITOR} || $repo->config("core.editor")
- || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+ chomp(my $editor = run_cmd_pipe(qw(git var GIT_EDITOR)));
system('sh', '-c', $editor.' "$@"', $editor, $hunkfile);
if ($? != 0) {
diff --git a/git-send-email.perl b/git-send-email.perl
index a0279de..4f5da4e 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -162,7 +162,8 @@ my $compose_filename;
# Handle interactive edition of files.
my $multiedit;
-my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi";
+my $editor = Git::command_oneline('var', 'GIT_EDITOR');
+
sub do_edit {
if (defined($multiedit) && !$multiedit) {
map {
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index c41c2f7..99cceeb 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -99,19 +99,12 @@ set_reflog_action() {
}
git_editor() {
- : "${GIT_EDITOR:=$(git config core.editor)}"
- : "${GIT_EDITOR:=${VISUAL:-${EDITOR}}}"
- case "$GIT_EDITOR,$TERM" in
- ,dumb)
- echo >&2 "No editor specified in GIT_EDITOR, core.editor, VISUAL,"
- echo >&2 "or EDITOR. Tried to fall back to vi but terminal is dumb."
- echo >&2 "Please set one of these variables to an appropriate"
- echo >&2 "editor or run $0 with options that will not cause an"
- echo >&2 "editor to be invoked (e.g., -m or -F for git-commit)."
- exit 1
- ;;
- esac
- eval "${GIT_EDITOR:=vi}" '"$@"'
+ if test -z "${GIT_EDITOR:+set}"
+ then
+ GIT_EDITOR="$(git var GIT_EDITOR)" || return $?
+ fi
+
+ eval "$GIT_EDITOR" '"$@"'
}
is_bare_repository () {
diff --git a/git-svn.perl b/git-svn.perl
index 6a3b501..42c9a72 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1321,9 +1321,8 @@ sub get_commit_entry {
close $log_fh or croak $!;
if ($_edit || ($type eq 'tree')) {
- my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
- # TODO: strip out spaces, comments, like git-commit.sh
- system($editor, $commit_editmsg);
+ chomp(my $editor = command_oneline(qw(var GIT_EDITOR)));
+ system('sh', '-c', $editor.' "$@"', $editor, $commit_editmsg);
}
rename $commit_editmsg, $commit_msg or croak $!;
{
--
1.6.5.2
^ permalink raw reply related
* [PATCH 6/8] am -i, git-svn: use "git var GIT_PAGER"
From: Jonathan Nieder @ 2009-10-31 1:43 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031012050.GA5160@progeny.tock>
Use the new "git var GIT_PAGER" command to ask what pager to use.
Without this change, the core.pager configuration is ignored by
these commands.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
git-am.sh | 5 ++++-
git-svn.perl | 6 ++----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/git-am.sh b/git-am.sh
index c132f50..2649487 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -649,7 +649,10 @@ do
[eE]*) git_editor "$dotest/final-commit"
action=again ;;
[vV]*) action=again
- LESS=-S ${PAGER:-less} "$dotest/patch" ;;
+ : ${GIT_PAGER=$(git var GIT_PAGER)}
+ : ${LESS=-FRSX}
+ export LESS
+ $GIT_PAGER "$dotest/patch" ;;
*) action=again ;;
esac
done
diff --git a/git-svn.perl b/git-svn.perl
index 42c9a72..c4ca548 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -5171,10 +5171,8 @@ sub git_svn_log_cmd {
# adapted from pager.c
sub config_pager {
- $pager ||= $ENV{GIT_PAGER} || $ENV{PAGER};
- if (!defined $pager) {
- $pager = 'less';
- } elsif (length $pager == 0 || $pager eq 'cat') {
+ chomp(my $pager = command_oneline(qw(var GIT_PAGER)));
+ if ($pager eq 'cat') {
$pager = undef;
}
$ENV{GIT_PAGER_IN_USE} = defined($pager);
--
1.6.5.2
^ permalink raw reply related
* [PATCH 7/8] Provide a build time default-editor setting
From: Jonathan Nieder @ 2009-10-31 1:44 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031012050.GA5160@progeny.tock>
Provide a DEFAULT_EDITOR knob to allow setting the fallback
editor to use instead of vi (when VISUAL, EDITOR, and GIT_EDITOR
are unset). The value can be set at build time according to a
system’s policy. For example, on Debian systems, the default
editor should be the 'editor' command.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Makefile | 17 +++++++++++++++++
editor.c | 6 +++++-
t/t7005-editor.sh | 31 ++++++++++++++++++++++++-------
3 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 268aede..625866c 100644
--- a/Makefile
+++ b/Makefile
@@ -200,6 +200,14 @@ all::
# memory allocators with the nedmalloc allocator written by Niall Douglas.
#
# Define NO_REGEX if you have no or inferior regex support in your C library.
+#
+# Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
+# want to use something different. The value will be interpreted by the shell
+# if necessary when it is used. Examples:
+#
+# DEFAULT_EDITOR='~/bin/vi',
+# DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
+# DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1363,6 +1371,15 @@ BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
$(COMPAT_CFLAGS)
LIB_OBJS += $(COMPAT_OBJS)
+# Quote for C
+
+ifdef DEFAULT_EDITOR
+DEFAULT_EDITOR_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_EDITOR)))"
+DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
+
+BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
+endif
+
ALL_CFLAGS += $(BASIC_CFLAGS)
ALL_LDFLAGS += $(BASIC_LDFLAGS)
diff --git a/editor.c b/editor.c
index 4f98b72..2aac807 100644
--- a/editor.c
+++ b/editor.c
@@ -2,6 +2,10 @@
#include "strbuf.h"
#include "run-command.h"
+#ifndef DEFAULT_EDITOR
+#define DEFAULT_EDITOR "vi"
+#endif
+
const char *git_editor(void)
{
const char *editor = getenv("GIT_EDITOR");
@@ -19,7 +23,7 @@ const char *git_editor(void)
return NULL;
if (!editor)
- editor = "vi";
+ editor = DEFAULT_EDITOR;
return editor;
}
diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh
index b647957..73ba44c 100755
--- a/t/t7005-editor.sh
+++ b/t/t7005-editor.sh
@@ -4,7 +4,26 @@ test_description='GIT_EDITOR, core.editor, and stuff'
. ./test-lib.sh
-for i in GIT_EDITOR core_editor EDITOR VISUAL vi
+unset EDITOR VISUAL GIT_EDITOR
+
+test_expect_success 'does editor have a simple name (no slashes, etc)?' '
+
+ editor=$(TERM=vt100 git var GIT_EDITOR) &&
+ test -n "$editor" &&
+ simple=t &&
+ case "$editor" in
+ */* | core_editor | [A-Z]*)
+ unset simple;;
+ esac
+
+'
+if test -z "${simple+set}"
+then
+ say 'skipping editor tests, default editor is not sought on PATH'
+ test_done
+fi
+
+for i in GIT_EDITOR core_editor EDITOR VISUAL "$editor"
do
cat >e-$i.sh <<-EOF
#!$SHELL_PATH
@@ -12,15 +31,13 @@ do
EOF
chmod +x e-$i.sh
done
-unset vi
-mv e-vi.sh vi
-unset EDITOR VISUAL GIT_EDITOR
+mv "e-$editor.sh" "$editor"
test_expect_success setup '
msg="Hand edited" &&
echo "$msg" >expect &&
- git add vi &&
+ git add "$editor" &&
test_tick &&
git commit -m "$msg" &&
git show -s --pretty=oneline |
@@ -44,7 +61,7 @@ test_expect_success 'dumb should error out when falling back on vi' '
TERM=vt100
export TERM
-for i in vi EDITOR VISUAL core_editor GIT_EDITOR
+for i in "$editor" EDITOR VISUAL core_editor GIT_EDITOR
do
echo "Edited by $i" >expect
unset EDITOR VISUAL GIT_EDITOR
@@ -68,7 +85,7 @@ done
unset EDITOR VISUAL GIT_EDITOR
git config --unset-all core.editor
-for i in vi EDITOR VISUAL core_editor GIT_EDITOR
+for i in "$editor" EDITOR VISUAL core_editor GIT_EDITOR
do
echo "Edited by $i" >expect
case "$i" in
--
1.6.5.2
^ permalink raw reply related
* [PATCH 8/8] Provide a build time default-pager setting
From: Jonathan Nieder @ 2009-10-31 1:45 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031012050.GA5160@progeny.tock>
From: Junio C Hamano <gitster@pobox.com>
Provide a DEFAULT_PAGER knob so packagers can set the fallback
pager to something appropriate during the build.
Examples:
On (old) solaris systems, /usr/bin/less (typically the first less
found) doesn't understand the default arguments (FXRS), which
forces users to alter their environment (PATH, GIT_PAGER, LESS,
etc) or have a local or global gitconfig before paging works as
expected.
On Debian systems, by policy packages must fall back to the
'pager' command, so that changing the target of the
/usr/bin/pager symlink changes the default pager for all packages
at once.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Makefile | 11 +++++++++++
| 6 +++++-
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 625866c..18fc50a 100644
--- a/Makefile
+++ b/Makefile
@@ -201,6 +201,10 @@ all::
#
# Define NO_REGEX if you have no or inferior regex support in your C library.
#
+# Define DEFAULT_PAGER to a sensible pager command (defaults to "less") if
+# you want to use something different. The value will be interpreted by the
+# shell at runtime when it is used.
+#
# Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
# want to use something different. The value will be interpreted by the shell
# if necessary when it is used. Examples:
@@ -1380,6 +1384,13 @@ DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
endif
+ifdef DEFAULT_PAGER
+DEFAULT_PAGER_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_PAGER)))"
+DEFAULT_PAGER_CQ_SQ = $(subst ','\'',$(DEFAULT_PAGER_CQ))
+
+BASIC_CFLAGS += -DDEFAULT_PAGER='$(DEFAULT_PAGER_CQ_SQ)'
+endif
+
ALL_CFLAGS += $(BASIC_CFLAGS)
ALL_LDFLAGS += $(BASIC_LDFLAGS)
--git a/pager.c b/pager.c
index 0b63d99..92c03f6 100644
--- a/pager.c
+++ b/pager.c
@@ -2,6 +2,10 @@
#include "run-command.h"
#include "sigchain.h"
+#ifndef DEFAULT_PAGER
+#define DEFAULT_PAGER "less"
+#endif
+
/*
* This is split up from the rest of git so that we can do
* something different on Windows.
@@ -60,7 +64,7 @@ const char *git_pager(void)
if (!pager)
pager = getenv("PAGER");
if (!pager)
- pager = "less";
+ pager = DEFAULT_PAGER;
else if (!*pager || !strcmp(pager, "cat"))
pager = NULL;
--
1.6.5.2
^ permalink raw reply related
* Re: [PATCH] Changed timestamp behavior of options -c/-C/--amend
From: Erick Mattos @ 2009-10-31 1:42 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vocnoe83m.fsf@alter.siamese.dyndns.org>
You are completely right.
All your concern is relevant and the whole problem must be re-engineered.
The good news is that I have almost finished it and I will be starting
a new thread with the new solution in a few minutes.
Regards
2009/10/30 Junio C Hamano <gitster@pobox.com>:
> Erick Mattos <erick.mattos@gmail.com> writes:
>
>> I don't see a use for comparing the author and committer because I can
>> use as template my own commits or others'.
>
> You _can_ use whichever irrelevant commit as a template, but "you _can_"
> is different from what it means, and what is and what is not _sensible_.
>
> You may be rewriting somebody else's patch (e.g. fixing up a typo in the
> message, or changing the implementation, or both). If you are going to
> keep the authorship, you are saying that "it is still _his_ code, not
> mine". In such a case, it never makes sense to change the timestamp, if
> that author is somebody other than you. After all that other guy may not
> even be aware of what you are doing when you make this commit; he may be
> in bed sound asleep in a different timezone.
>
> In another scenario, if your fix-up is very significant, even if you
> started from somebody else's patch, you may want to say "now this is my
> patch, the original author may have given me some inspiration, but the
> changes in this commit, including all the bugs, are mine". The same
> applies if you looked at the problem description of somebody' patch, and
> did your own solution without using anything from his commit.
>
> At that point, you would want the resulting commit to say it was written
> by you at this moment. You do not want to see -c/-C/--amend to retain any
> part of the authorship (not just timestamp) from the original commit.
>
> Side note. You may be fixing your own patch, in which case you may or
> may not consider your change significant, but at the time of either
> old timestamp or current time, you were working on this change, so
> using the current timestamp instead of using the old one is not a big
> deal, and that is why I think committer==author may be a good
> heuristic when deciding to touch or not touch the timestamp.
>
> But in general I do not like such dwim that depends on who you are (it
> makes it harder to explain, even if the end result may be useful in
> practice), so I'd rather not to see such a code for this topic if we
> can avoid it.
>
> In short, I do not think it makes sense to change only the timestamp while
> keeping the author. The issue is not "timestamp behaviour" with "use new
> timestamp" option, but rather is an ability to declare "Now this is a
> commit made _by me_ and _now_; iow, I take authorship for this change",
> even when you reuse the commit log message from somewhere else.
>
> So what is needed is an option to tell -c/-C/--amend to reuse _only_ the
> message but no authorship information from the original commit, I think.
>
^ permalink raw reply
* Re: [PATCH v2 3/8] Teach git var about GIT_EDITOR
From: Junio C Hamano @ 2009-10-31 2:01 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Junio C Hamano, Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031013934.GD5160@progeny.tock>
Jonathan Nieder <jrnieder@gmail.com> writes:
> From: Johannes Sixt <j6t@kdbg.org>
>
> Expose the command used by launch_editor() for scripts to use.
> This should allow one to avoid searching for a proper editor
> separately in each command.
>
> If no satisfactory GIT_EDITOR could be chosen, let "git var -l"
> output a warning. This warning goes to stderr so as not to
> confuse scripts. Example:
>
> core.logallrefupdates=true
>
> *** Please tell me who you are.
>
> Run
>
> git config --global user.email "you@example.com"
> git config --global user.name "Your Name"
>
> to set your account's default identity.
> Omit --global to set the identity only in this repository.
>
> GIT_COMMITTER_IDENT=user <user@domain> 1256952739 -0500
> GIT_AUTHOR_IDENT=user <user@domain> 1256952739 -0500
> warning: GIT_EDITOR: terminal is dumb, but EDITOR unset
Sorry, I cannot grok this example. Is it supposed to be a transcript
of a user session? What did the user type?
^ permalink raw reply
* Re: [PATCH] Update packfile transfer protocol documentation
From: Shawn O. Pearce @ 2009-10-31 2:06 UTC (permalink / raw)
To: Scott Chacon; +Cc: git list
In-Reply-To: <d411cc4a0910291035m45ba0a8egd8a991acfbf6d5a7@mail.gmail.com>
Scott Chacon <schacon@gmail.com> wrote:
> The protocol-common.txt is taken from Shawns
> http-protocol.txt that was in common with packfile protocol. Shawn,
> is that the best way to share that info?
Yup, I think that's the easiest way to do it.
> diff --git a/Documentation/technical/pack-protocol.txt
> +
> +Transports
> +----------
> +The file:// transport simply runs the 'upload-pack' or 'receive-pack'
> +process locally.
You may want to mention that a pipe is used to communicate with
the local process.
> +Git Protocol
> +------------
> + git-proto-request = request-command SP pathname NUL [ host-parameter NUL ]
> + request-command = 'git-upload-pack' / 'git-receive-pack' /
> + 'git-upload-archive' ; case sensitive
> + pathname = *( %x01-ff ) ; exclude NUL
> + host-parameter = 'host' "=" hostname [ ":" port ]
Use double quotes for the request-command items and for the host
literal in host-parameter.
> +Currently only 'host' is allowed in the extra information. It's
No. We should make this a MUST. As in:
Only host-parameter is allowed in the git-proto-request.
Clients MUST NOT attempt to send additional parameters.
Sending another header can cause older git-daemons to lock up.
> + $ echo -e -n \
> + "0039git-upload-pack /schacon/gitbook.git\0host=github.com\0" |
> + nc -v github.com 9418
I guess a decent example, but lets use example.com in the
documentation.
> +SSH Protocol
> +------------
> +
> + $ ssh git.example.com 'git-upload-pack /project.git'
/project.git may be wrapped in single quotes if it contains shell
unsafe characters, like spaces. So really the invocation is
more like:
$ ssh git.example.com "git-upload-pack '/my project.git'"
> +In an ssh:// format URI, it's absolute in the URI, so the '/' after
Unless its ssh://user@example.com/~alice/project.git, in which case
we execute
ssh user@example.com 'git-upload-pack ~alice/project.git'.
> +Reference Discovery
> +-------------------
> +
> +When the client initially connects the server will immediately respond
> +with a listing of each reference it has (all branches and tags) along
> +with the commit SHA that each reference currently points to.
> +
> + $ echo -e -n \
> + "0039git-upload-pack /schacon/gitbook.git\0host=github.com\0" |
> + nc -v github.com 9418
Same remark about example.com in docs.
> +HEAD is not included if its detached - that is, if HEAD is not a
> +symbolic reference, a pointer to another branch, it is not included
> +in the initial server response.
Really? I thought it was.
> +Packfile Negotiation
> +--------------------
> +After reference and capabilities discovery, the client can decide
> +to terminate the connection (as happens with the ls-remote command)
In this case the client SHOULD send flush-pkt before closing so
the server can gracefully terminate, rather than ungracefully exit
while waiting on input.
I don't know why this is, the server should be more robust here,
but its historical precendent and there are older servers still,
so we should document it.
> +----
> + upload-request = want-list
> + have-list
> + compute-end
The shallow stuff goes between want-list and have-list, and actually
has a full round trip between the client and the server. I didn't
get to documenting that yet. We'll need to do that soon.
> +Once all the "want"s (and optional 'deepen') [...]
> +
> +TODO: shallow/unshallow response
Also document the deepen command above in the ABNF.
> +Now the client will send a list of the obj-ids it has. In multi-ack
> +mode, the canonical implementation will send up to 32 of these at a
Also, in multi_ack mode the canonical implementation will skip
ahead and send the next 32 immediately, so that there is always
a block of 32 "in-flight on the wire" at a time.
This means some pipe buffering is required, at least 1604 bytes
on the client side. IIRC POSIX pipes (and some pure-software ones
e.g. the Java default in-memory pipe) only promise 512 bytes.
But for some reason I recall I had computed this out at just over
2100 bytes, but right now I can't recall why that is.
> +If the server reads 'have' lines, it then will respond by ACKing any
> +of the obj-ids the client said it had that the server also has. Or,
> +once the server has found an acceptable common base commit and is
> +ready to make a packfile, it will blindly ACK all 'have' obj-ids back
> +to the client. Then it will send a 'NACK' and then wait for
> +another response from the client - either a 'done' or another list of
> +'have' lines.
If this is a description of non-multi_ack mode, its wrong.
Without multi_ack:
* upload-pack sends "ACK %s\n" on the first common object it finds.
After that it says nothing until the client gives it a "done".
* upload-pack sends "NAK\n" on a flush-pkt if no common object
has been found yet. If one has been found, and thus an ACK
was already sent, its silent on the flush-pkt.
> +In multi-ack mode, the server will respond with 'ACK obj-id continue'
> +for common commits, otherwise it will just respond with 'ACK obj-id'
> +lines. In multi-ack-detailed mode, it will differentiate the ACKs
Its multi_ack and mulit_ack_detailed. For historical reasons we
use _ in these not -.
Also, in multi_ack mode we never use "ACK %s\n", only the newer
"ACK %s continue\n" gets used. This is also true in multi_ack_detailed,
where we only use common/ready and none of the other forms.
> +After the client has gotten 'ACK obj-id' responses for all it's
> +references, or has sent more than 256 references and decides to give
> +up, it will send a 'done' command, which signals to the server that it
> +is ready to receive it's packfile data.
This isn't really correct. The client won't get an "ACK obj-id"
for its refs. Really the client's termination condition is that
it has received enough "ACK obj-id"'s that it can color everything
left in the --date-order queue as common with the server, or the
--date-order queue is empty.
The 256 thing isn't 256 references. Its the client SHOULD abort if
it has 256 have lines without receiving a single ACK, of any kind,
from the server. In such a case the client has just walked down
some long path where there is nothing in common, and maybe that
really is the case, so it should just give up.
Unfortunately this rule is dicey because if a client is really far
ahead of the remote peer its fetching from it could go down that
256 commit chain and give up too soon, and download the entire
project all over again.
Fortunately, the 256 limit *only* turns on in the canonical client
implementation if we have received at least one "ACK %s continue"
during a prior round. This helps to ensure that at least one common
ancestor is found before we give up entirely.
> +Once the 'done' line is read from the client, the server will either
> +send a final 'ACK obj-id' line if it is in multi-ack mode and has found
> +a common base, or it will send a 'NAK' if it has still not found a common
> +base; then the server will start sending it's packfile data.
This needs to be more clear.
It always sends NAK after done if there is no common base found.
It only sends ACK after done if there is at least one common base
and multi_ack or multi_ack_detailed is enabled.
> +----
> + server-response = *acks
> + nack
NAK is optional if ACKs were sent, so really I think this entire block is:
server-response = *ack_multi ack / nak
ack_multi = PKT-LINE("ACK" SP obj-id ack_status LF)
ack_status = "continue" / "common" / "ready"
ack = PKT-LINE("ACK SP obj-id LF)
nak = PKT-LINE("NAK" LF)
> + acks = *ack
Some sort of tab/space error on leading indent, but I'd drop this rule.
> + nack = PKT-LINE("NACK" LF)
This is actually spelled "NAK" (no C). See my rewrite above.
> +Packfile Data
> +-------------
> +
> +If 'side-band' or 'side-band-64k' capabilities have been specified by
> +the client, the server will send the packfile data multiplexed - it
> +will be sent in packets of either 1000 bytes or 64k, depending on which
Its 999 data bytes, 1 control code, for a total of 1000 bytes in
a pkt-line, or 65519 data bytes, 1 control code, for a total of
65520 bytes in a pkt-line. You imply 65536 bytes of data here by
saying 64k. Don't round up.
> +sideband type was specified, with each packet starting with the packet-line
> +format of the amount of data that follows, followed by a single byte
Not format, length.
> +If no 'side-band' capability was specified, the server will simply
> +stream the entire packfile.
Without multiplexing.
> +Reference Discovery
> +-------------------
> +
> +instead of following a null byte, the capabilities follow a space.
No, the follow a NUL.
> + capability-list = capability *(SP capability)
> + capability = 1*(ALPHA / DIGIT / "-" / "_")
Tab/space error on indent.
> +Reference Update Request and Packfile Transfer
> +----------------------------------------------
> +
> +This list is followed by a flush packet and then the packfile that should
> +contain all the objects that the server will need to complete the new
> +references.
The pack-file MUST NOT be sent if the only command used is 'delete'.
A pack-file MUST be sent if either create or update command is used.
An empty pack-file MUST be sent if a create or update command is
used, and the server already obviously has the object (e.g. the
SHA-1 is already pointed to by another ref that was listed in the
advertisement).
> +----
> + update-request = command-list pack-file
Add [] around pack-file to make it optional.
> +An example client/server communication might look like this:
> +
> +----
> + S: 007c74730d410fcb6603ace96f1dc55ea6196122532d HEAD report-status
> delete-refs ofs-delta\n
There's a NUL before the capabilities. Also, HEAD usually is not
sent in the advertisement, its weird to update HEAD via push.
> + S: 000aunpack ok\n
> + S: 000aok refs/heads/debug\n
> + S: 000ang refs/heads/master non-fast-forward\n
Your pkt-len is all wrong here, there's no way each of those is 10
bytes long. :-)
Please double check all of the pkt-lens used in the document, its
annoying, but if we are trying to really document the protocol its
a good idea that all examples presented are accurate.
> diff --git a/Documentation/technical/protocol-capabilities.txt
> +
> +multi-ack
> +---------
> +
> +The 'multi-ack' capability allows the server to return "ACK $SHA1
Its spelled 'multi_ack'.
Otherwise, nice writeup of this capability.
> +side-band, side-band-64k
> +------------------------
You need to explain how the packet length is actually 1 byte larger
than the data payload, with a stream code in that first byte of:
1 - pack data
2 - progress messages
3 - fatal error message just before stream aborts
Further, with side-band and its 1000 byte messages, its actually
999 bytes of payload and 1 byte for the stream code.
With side-band-64k, same deal, you have 65519 bytes of data and 1
byte for the stream code.
> +shallow
> +-------
This capability also adds "shallow" and "unshallow" commands to
the fetch-pack/upload-pack protocol. I haven't had time to study
what impact this has, as we haven't implemented shallow support
yet in JGit.
> +no-progress
> +-----------
> +
> +The client was started with "git clone -q" or something, and doesn't
> +want that side brand 2. Basically the client just says "I do not
s/brand/band/
> +include-tag
> +-----------
> +
> +The 'include-tag' capability is about sending tags if we are sending
> +objects they point to. If we pack an object to the client, and a tag
> +points exactly at that object, we pack the tag too. In general this
> +allows a client to get all new tags when it fetches a branch, in a
> +single network connection.
Elaborate to say "annotated tag" at least once here.
> +Servers SHOULD support all capabilities defined in this document.
This should be at the top of this document, not inside of the
include-tag section.
We should also document the following from receive-pack:
* report-status
* delete-refs
> diff --git a/Documentation/technical/protocol-common.txt
...
> + data-pkt = pkt-len pkt-payload
> + pkt-len = 4*(HEXDIG)
> + pkt-payload = (pkt-len - 4)*(OCTET)
Some sort of odd tab/space error here on the pkt-len line.
--
Shawn.
^ permalink raw reply
* Re: [PATCH 7/8] Provide a build time default-editor setting
From: Junio C Hamano @ 2009-10-31 2:09 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031014441.GH5160@progeny.tock>
Jonathan Nieder <jrnieder@gmail.com> writes:
> +test_expect_success 'does editor have a simple name (no slashes, etc)?' '
> +
> + editor=$(TERM=vt100 git var GIT_EDITOR) &&
> + test -n "$editor" &&
> + simple=t &&
> + case "$editor" in
> + */* | core_editor | [A-Z]*)
Hmm, what are the latter two cases designed to catch?
^ permalink raw reply
* Re: [PATCH v2 3/8] Teach git var about GIT_EDITOR
From: Jonathan Nieder @ 2009-10-31 2:23 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <7vk4yccodl.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
>> core.logallrefupdates=true
>>
>> *** Please tell me who you are.
>>
>> Run
>>
>> git config --global user.email "you@example.com"
>> git config --global user.name "Your Name"
>>
>> to set your account's default identity.
>> Omit --global to set the identity only in this repository.
>>
>> GIT_COMMITTER_IDENT=user <user@domain> 1256952739 -0500
>> GIT_AUTHOR_IDENT=user <user@domain> 1256952739 -0500
>> warning: GIT_EDITOR: terminal is dumb, but EDITOR unset
>
> Sorry, I cannot grok this example. Is it supposed to be a transcript
> of a user session? What did the user type?
Oh, sorry about that. The user typed 'git var -l', and that is all
output from that. More realistic examples:
$ # what scripts see
$ git var -l 2>/dev/null
gc.auto=0
rerere.enabled
merge.log
merge.conflictstyle=diff3
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git://repo.or.cz/git
branch.master.remote=origin
branch.master.merge=refs/heads/master
GIT_COMMITTER_IDENT=user <user@domain> 1256952739 -0500
GIT_AUTHOR_IDENT=user <user@domain> 1256952739 -0500
$
$ # what scripts pass on to the user
$ git var -l >/dev/null
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
warning: GIT_EDITOR: terminal is dumb, but EDITOR unset
$
At least, that is what I was imagining (that’s one way to use git var,
anyway).
Would a more friendly message be helpful here? I am not sure how 'git
var -l' gets used. I never liked using it directly myself, mostly
because the long list of configuration items can be overwhelming.
Jonathan
^ permalink raw reply
* Re: [PATCH v2 3/8] Teach git var about GIT_EDITOR
From: Junio C Hamano @ 2009-10-31 2:34 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031022347.GA5569@progeny.tock>
Jonathan Nieder <jrnieder@gmail.com> writes:
> Junio C Hamano wrote:
>
>>> core.logallrefupdates=true
>>>
>>> *** Please tell me who you are.
>>>
>>> Run
>>>
>>> git config --global user.email "you@example.com"
>>> git config --global user.name "Your Name"
>>>
>>> to set your account's default identity.
>>> Omit --global to set the identity only in this repository.
>>>
>>> GIT_COMMITTER_IDENT=user <user@domain> 1256952739 -0500
>>> GIT_AUTHOR_IDENT=user <user@domain> 1256952739 -0500
>>> warning: GIT_EDITOR: terminal is dumb, but EDITOR unset
>>
>> Sorry, I cannot grok this example. Is it supposed to be a transcript
>> of a user session? What did the user type?
>
> Oh, sorry about that. The user typed 'git var -l', and that is all
> output from that. More realistic examples:
>
> $ # what scripts see
> $ git var -l 2>/dev/null
> gc.auto=0
> rerere.enabled
> merge.log
> merge.conflictstyle=diff3
> core.repositoryformatversion=0
> core.filemode=true
> core.bare=false
> core.logallrefupdates=true
> remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
> remote.origin.url=git://repo.or.cz/git
> branch.master.remote=origin
> branch.master.merge=refs/heads/master
> GIT_COMMITTER_IDENT=user <user@domain> 1256952739 -0500
> GIT_AUTHOR_IDENT=user <user@domain> 1256952739 -0500
> $
> $ # what scripts pass on to the user
> $ git var -l >/dev/null
>
> *** Please tell me who you are.
>
> Run
>
> git config --global user.email "you@example.com"
> git config --global user.name "Your Name"
>
> to set your account's default identity.
> Omit --global to set the identity only in this repository.
>
> warning: GIT_EDITOR: terminal is dumb, but EDITOR unset
> $
This is more readable.
But the user did not even ask for GIT_EDITOR. Should it even mention
"unusable"? or should it just say something like
GIT_EDITOR=
without complaining?
For that matter, I also wonder if we can squelch the user.email one when
we are only listing the variables (I know it is not part of this topic,
but I can still wonder).
> Would a more friendly message be helpful here? I am not sure how 'git
> var -l' gets used. I never liked using it directly myself, mostly
> because the long list of configuration items can be overwhelming.
I think people run "git var -l", store the results in variables (think
Perl or Python script) and read from there, instead of making separate
invocations of "git var" for individual variables.
^ permalink raw reply
* [PATCH] commit -c/-C/--amend: take over authorship and restamp time with --claim
From: Erick Mattos @ 2009-10-31 3:08 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Erick Mattos
When we use one of the options above we are normally trying to do mainly
two things: one is using the source as a template and second is to
recreate a commit with corrections.
When they are used, the authorship and timestamp recorded in the newly
created commit is always taken from the original commit. And they
should not when we are using it as a template.
The new --claim option is meant to solve this need by regenerating the
timestamp and setting as new author the committer or the one specified
on --author option.
Signed-off-by: Erick Mattos <erick.mattos@gmail.com>
---
Documentation/git-commit.txt | 10 +++++++---
builtin-commit.c | 7 ++++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 0578a40..96248ab 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -9,7 +9,7 @@ SYNOPSIS
--------
[verse]
'git commit' [-a | --interactive] [-s] [-v] [-u<mode>] [--amend] [--dry-run]
- [(-c | -C) <commit>] [-F <file> | -m <msg>]
+ [(-c | -C) <commit>] [-F <file> | -m <msg>] [--claim]
[--allow-empty] [--no-verify] [-e] [--author=<author>]
[--cleanup=<mode>] [--] [[-i | -o ]<file>...]
@@ -61,14 +61,18 @@ OPTIONS
-C <commit>::
--reuse-message=<commit>::
Take an existing commit object, and reuse the log message
- and the authorship information (including the timestamp)
- when creating the commit.
+ and the authorship information when creating the commit.
-c <commit>::
--reedit-message=<commit>::
Like '-C', but with '-c' the editor is invoked, so that
the user can further edit the commit message.
+--claim::
+ When used with -C/-c/--amend options the committer takes over
+ the cloned commit authorship and renew the timestamp thus using
+ only the commit message from the source.
+
-F <file>::
--file=<file>::
Take the commit message from the given file. Use '-' to
diff --git a/builtin-commit.c b/builtin-commit.c
index c395cbf..33922df 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, dry_run;
+static int quiet, verbose, no_verify, allow_empty, dry_run, claim;
static char *untracked_files_arg;
/*
* The default commit message cleanup mode will remove the lines
@@ -91,8 +91,9 @@ static struct option builtin_commit_options[] = {
OPT_FILENAME('F', "file", &logfile, "read log from file"),
OPT_STRING(0, "author", &force_author, "AUTHOR", "override author for commit"),
OPT_CALLBACK('m', "message", &message, "MESSAGE", "specify commit message", opt_parse_m),
- OPT_STRING('c', "reedit-message", &edit_message, "COMMIT", "reuse and edit message from specified commit "),
+ OPT_STRING('c', "reedit-message", &edit_message, "COMMIT", "reuse and edit message from specified commit"),
OPT_STRING('C', "reuse-message", &use_message, "COMMIT", "reuse message from specified commit"),
+ OPT_BOOLEAN(0, "claim", &claim, "take over cloned commit authorship and renew timestamp"),
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
OPT_FILENAME('t', "template", &template_file, "use specified template file"),
OPT_BOOLEAN('e', "edit", &edit_flag, "force edit of commit"),
@@ -381,7 +382,7 @@ static void determine_author_info(void)
email = getenv("GIT_AUTHOR_EMAIL");
date = getenv("GIT_AUTHOR_DATE");
- if (use_message) {
+ if (use_message && !claim) {
const char *a, *lb, *rb, *eol;
a = strstr(use_message_buffer, "\nauthor ");
--
1.6.5.2.102.g0a733
^ permalink raw reply related
* Re: [PATCH 7/8] Provide a build time default-editor setting
From: Jonathan Nieder @ 2009-10-31 3:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <7vfx90co1e.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
>> +test_expect_success 'does editor have a simple name (no slashes, etc)?' '
>> +
>> + editor=$(TERM=vt100 git var GIT_EDITOR) &&
>> + test -n "$editor" &&
>> + simple=t &&
>> + case "$editor" in
>> + */* | core_editor | [A-Z]*)
>
> Hmm, what are the latter two cases designed to catch?
Both are meant to allow the test to work without too many changes.
The core_editor case is a little pedantic, since it is unlikely to
actually come up in practice. With a default editor of core_editor,
the initial loop will overwrite e-core_editor.sh (to be used through
the core.editor configuration) with e-core_editor.sh (to be used as a
fallback editor) before renaming it to core_editor.
I missed some other cases: If editor is .git, e-GIT_EDITOR.sh, etc,
the mv will still misbehave.
The [A-Z]* test is to avoid changing the loop around line 86:
| unset EDITOR VISUAL GIT_EDITOR
| git config --unset-all core.editor
| for i in "$editor" EDITOR VISUAL core_editor GIT_EDITOR
| do
| echo "Edited by $i" >expect
| case "$i" in
| core_editor)
| git config core.editor ./e-core_editor.sh
| ;;
| [A-Z]*)
| eval "$i=./e-$i.sh"
| export $i
| ;;
| esac
| test_expect_success "Using $i (override)" '
| git --exec-path=. commit --amend &&
| git show -s --pretty=oneline |
| sed -e "s/^[0-9a-f]* //" >actual &&
| diff actual expect
| '
| done
which I do not think is worth making more complicated.
Maybe it would be better to just check for an editor consisting only
of alphabetical characters. Perhaps something like the following:
-- %< --
From: Jonathan Nieder <jrnieder@gmail.com>
Subject: [PATCH] Provide a build time default-editor setting
Provide a DEFAULT_EDITOR knob to allow setting the fallback
editor to use instead of vi (when VISUAL, EDITOR, and GIT_EDITOR
are unset). The value can be set at build time according to a
system’s policy. For example, on Debian systems, the default
editor should be the 'editor' command.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Makefile | 17 +++++++++++++++++
editor.c | 6 +++++-
t/t7005-editor.sh | 27 ++++++++++++++++++++-------
3 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 268aede..625866c 100644
--- a/Makefile
+++ b/Makefile
@@ -200,6 +200,14 @@ all::
# memory allocators with the nedmalloc allocator written by Niall Douglas.
#
# Define NO_REGEX if you have no or inferior regex support in your C library.
+#
+# Define DEFAULT_EDITOR to a sensible editor command (defaults to "vi") if you
+# want to use something different. The value will be interpreted by the shell
+# if necessary when it is used. Examples:
+#
+# DEFAULT_EDITOR='~/bin/vi',
+# DEFAULT_EDITOR='$GIT_FALLBACK_EDITOR',
+# DEFAULT_EDITOR='"C:\Program Files\Vim\gvim.exe" --nofork'
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1363,6 +1371,15 @@ BASIC_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' \
$(COMPAT_CFLAGS)
LIB_OBJS += $(COMPAT_OBJS)
+# Quote for C
+
+ifdef DEFAULT_EDITOR
+DEFAULT_EDITOR_CQ = "$(subst ",\",$(subst \,\\,$(DEFAULT_EDITOR)))"
+DEFAULT_EDITOR_CQ_SQ = $(subst ','\'',$(DEFAULT_EDITOR_CQ))
+
+BASIC_CFLAGS += -DDEFAULT_EDITOR='$(DEFAULT_EDITOR_CQ_SQ)'
+endif
+
ALL_CFLAGS += $(BASIC_CFLAGS)
ALL_LDFLAGS += $(BASIC_LDFLAGS)
diff --git a/editor.c b/editor.c
index 4f98b72..2aac807 100644
--- a/editor.c
+++ b/editor.c
@@ -2,6 +2,10 @@
#include "strbuf.h"
#include "run-command.h"
+#ifndef DEFAULT_EDITOR
+#define DEFAULT_EDITOR "vi"
+#endif
+
const char *git_editor(void)
{
const char *editor = getenv("GIT_EDITOR");
@@ -19,7 +23,7 @@ const char *git_editor(void)
return NULL;
if (!editor)
- editor = "vi";
+ editor = DEFAULT_EDITOR;
return editor;
}
diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh
index b647957..13c37de 100755
--- a/t/t7005-editor.sh
+++ b/t/t7005-editor.sh
@@ -4,7 +4,22 @@ test_description='GIT_EDITOR, core.editor, and stuff'
. ./test-lib.sh
-for i in GIT_EDITOR core_editor EDITOR VISUAL vi
+unset EDITOR VISUAL GIT_EDITOR
+
+test_expect_success 'determine default editor' '
+
+ editor=$(TERM=vt100 git var GIT_EDITOR) &&
+ test -n "$editor"
+
+'
+
+if ! test -z "$(printf '%s\n' "$editor" | sed '/^[a-z]*$/d')"
+then
+ say 'skipping editor tests, default editor name too complicated'
+ test_done
+fi
+
+for i in GIT_EDITOR core_editor EDITOR VISUAL "$editor"
do
cat >e-$i.sh <<-EOF
#!$SHELL_PATH
@@ -12,15 +27,13 @@ do
EOF
chmod +x e-$i.sh
done
-unset vi
-mv e-vi.sh vi
-unset EDITOR VISUAL GIT_EDITOR
+mv "e-$editor.sh" "$editor"
test_expect_success setup '
msg="Hand edited" &&
echo "$msg" >expect &&
- git add vi &&
+ git add "$editor" &&
test_tick &&
git commit -m "$msg" &&
git show -s --pretty=oneline |
@@ -44,7 +57,7 @@ test_expect_success 'dumb should error out when falling back on vi' '
TERM=vt100
export TERM
-for i in vi EDITOR VISUAL core_editor GIT_EDITOR
+for i in "$editor" EDITOR VISUAL core_editor GIT_EDITOR
do
echo "Edited by $i" >expect
unset EDITOR VISUAL GIT_EDITOR
@@ -68,7 +81,7 @@ done
unset EDITOR VISUAL GIT_EDITOR
git config --unset-all core.editor
-for i in vi EDITOR VISUAL core_editor GIT_EDITOR
+for i in "$editor" EDITOR VISUAL core_editor GIT_EDITOR
do
echo "Edited by $i" >expect
case "$i" in
--
1.6.5.2
^ permalink raw reply related
* Re: [PATCH v2 3/8] Teach git var about GIT_EDITOR
From: Jonathan Nieder @ 2009-10-31 4:00 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <7vws2cb8bp.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> But the user did not even ask for GIT_EDITOR. Should it even mention
> "unusable"? or should it just say something like
>
> GIT_EDITOR=
>
> without complaining?
>
> For that matter, I also wonder if we can squelch the user.email one when
> we are only listing the variables (I know it is not part of this topic,
> but I can still wonder).
[...]
> I think people run "git var -l", store the results in variables (think
> Perl or Python script) and read from there, instead of making separate
> invocations of "git var" for individual variables.
In that case, most variable-specific warnings should be suppressed as
irrelevant. So squelching the warnings makes sense.
How about this patch? With the "git var GIT_EDITOR" patch applied on
top, "git var -l" silently omits the GIT_EDITOR variable when a suitable
editor cannot be found.
-- %< --
Subject: Suppress warnings from "git var -l"
For scripts using "git var -l" to read all logical variables at
once, not all per-variable warnings will be relevant. Suppress
them.
The git source tree does not include any scripts using "git var
-l", so this change should not affect other git commands.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
ident.c | 2 +-
var.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/ident.c b/ident.c
index 99f1c85..26409b2 100644
--- a/ident.c
+++ b/ident.c
@@ -205,7 +205,7 @@ const char *fmt_ident(const char *name, const char *email,
if ((warn_on_no_name || error_on_no_name) &&
name == git_default_name && env_hint) {
fprintf(stderr, env_hint, au_env, co_env);
- env_hint = NULL; /* warn only once, for "git var -l" */
+ env_hint = NULL; /* warn only once */
}
if (error_on_no_name)
die("empty ident %s <%s> not allowed", name, email);
diff --git a/var.c b/var.c
index 125c0d1..dacbaab 100644
--- a/var.c
+++ b/var.c
@@ -22,7 +22,7 @@ static void list_vars(void)
{
struct git_var *ptr;
for (ptr = git_vars; ptr->read; ptr++)
- printf("%s=%s\n", ptr->name, ptr->read(IDENT_WARN_ON_NO_NAME));
+ printf("%s=%s\n", ptr->name, ptr->read(0));
}
static const char *read_var(const char *var)
--
1.6.5.2
^ permalink raw reply related
* [PATCH v3] Teach git var about GIT_EDITOR
From: Jonathan Nieder @ 2009-10-31 4:04 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031040003.GA6022@progeny.tock>
From: Johannes Sixt <j6t@kdbg.org>
Expose the command used by launch_editor() for scripts to use.
This should allow one to avoid searching for a proper editor
separately in each command.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Jonathan Nieder wrote:
> How about this patch? With the "git var GIT_EDITOR" patch applied on
> top, "git var -l" silently omits the GIT_EDITOR variable when a suitable
> editor cannot be found.
>
> -- %< --
> Subject: Suppress warnings from "git var -l"
>
> For scripts using "git var -l" to read all logical variables at
> once, not all per-variable warnings will be relevant. Suppress
> them.
Here’s the "git var GIT_EDITOR" patch again, rebased on top of the
aforementioned patch. The rest of the series should apply without
changes.
Documentation/git-var.txt | 8 ++++++++
cache.h | 1 +
editor.c | 14 ++++++++++++--
var.c | 16 +++++++++++++++-
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt
index e2f4c09..89e4b4f 100644
--- a/Documentation/git-var.txt
+++ b/Documentation/git-var.txt
@@ -36,6 +36,14 @@ GIT_AUTHOR_IDENT::
GIT_COMMITTER_IDENT::
The person who put a piece of code into git.
+GIT_EDITOR::
+ Text editor for use by git commands. The value is meant to be
+ interpreted by the shell when it is used. Examples: `~/bin/vi`,
+ `$SOME_ENVIRONMENT_VARIABLE`, `"C:\Program Files\Vim\gvim.exe"
+ --nofork`. The order of preference is the `$GIT_EDITOR`
+ environment variable, then `core.editor` configuration, then
+ `$VISUAL`, then `$EDITOR`, and then finally 'vi'.
+
Diagnostics
-----------
You don't exist. Go away!::
diff --git a/cache.h b/cache.h
index 96840c7..311cfe1 100644
--- a/cache.h
+++ b/cache.h
@@ -750,6 +750,7 @@ extern const char *git_author_info(int);
extern const char *git_committer_info(int);
extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
extern const char *fmt_name(const char *name, const char *email);
+extern const char *git_editor(void);
struct checkout {
const char *base_dir;
diff --git a/editor.c b/editor.c
index 3f13751..4f98b72 100644
--- a/editor.c
+++ b/editor.c
@@ -2,7 +2,7 @@
#include "strbuf.h"
#include "run-command.h"
-int launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
+const char *git_editor(void)
{
const char *editor = getenv("GIT_EDITOR");
const char *terminal = getenv("TERM");
@@ -16,11 +16,21 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
editor = getenv("EDITOR");
if (!editor && terminal_is_dumb)
- return error("terminal is dumb, but EDITOR unset");
+ return NULL;
if (!editor)
editor = "vi";
+ return editor;
+}
+
+int launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
+{
+ const char *editor = git_editor();
+
+ if (!editor)
+ return error("terminal is dumb, but EDITOR unset");
+
if (strcmp(editor, ":")) {
size_t len = strlen(editor);
int i = 0;
diff --git a/var.c b/var.c
index dacbaab..12a8512 100644
--- a/var.c
+++ b/var.c
@@ -8,6 +8,16 @@
static const char var_usage[] = "git var [-l | <variable>]";
+static const char *editor(int flag)
+{
+ const char *pgm = git_editor();
+
+ if (!pgm && flag & IDENT_ERROR_ON_NO_NAME)
+ die("terminal is dumb, but VISUAL and EDITOR unset");
+
+ return pgm;
+}
+
struct git_var {
const char *name;
const char *(*read)(int);
@@ -15,14 +25,18 @@ struct git_var {
static struct git_var git_vars[] = {
{ "GIT_COMMITTER_IDENT", git_committer_info },
{ "GIT_AUTHOR_IDENT", git_author_info },
+ { "GIT_EDITOR", editor },
{ "", NULL },
};
static void list_vars(void)
{
struct git_var *ptr;
+ const char *val;
+
for (ptr = git_vars; ptr->read; ptr++)
- printf("%s=%s\n", ptr->name, ptr->read(0));
+ if ((val = ptr->read(0))
+ printf("%s=%s\n", ptr->name, val);
}
static const char *read_var(const char *var)
--
1.6.5.2
^ permalink raw reply related
* What's cooking in git.git (Oct 2009, #06; Fri, 30)
From: Junio C Hamano @ 2009-10-31 4:04 UTC (permalink / raw)
To: git
Here are the topics that have been cooking. Commits prefixed with '-' are
only in 'pu' while commits prefixed with '+' are in 'next'. The ones
marked with '.' do not appear in any of the integration branches, but I am
still holding onto them.
In 1.7.0, we plan to correct handful of warts in the interfaces everybody
agrees that they were mistakes. The resulting system may not be strictly
backward compatible. Currently planeed changes are:
* refuse push to update the checked out branch in a non-bare repo by
default
Make "git push" into a repository to update the branch that is checked
out fail by default. You can countermand this default by setting a
configuration variable in the receiving repository.
http://thread.gmane.org/gmane.comp.version-control.git/107758/focus=108007
* refuse push to delete the current branch by default
Make "git push $there :$killed" to delete the branch that is pointed at
by its HEAD fail by default. You can countermand this default by
setting a configuration variable in the receiving repository.
http://thread.gmane.org/gmane.comp.version-control.git/108862/focus=108936
* git-send-email won't make deep threads by default
Many people said that by default when sending more than 2 patches the
threading git-send-email makes by default is hard to read, and they
prefer the default be one cover letter and each patch as a direct
follow-up to the cover letter. You can countermand this by setting a
configuration variable.
http://article.gmane.org/gmane.comp.version-control.git/109790
* git-status won't be "git-commit --dry-run" anymore
http://thread.gmane.org/gmane.comp.version-control.git/125989/focus=125993
* "git-diff -w --exit-code" will exit success if only differences it
found are whitespace changes that are stripped away from the output.
http://thread.gmane.org/gmane.comp.version-control.git/119731/focus=119751
The tests do not pass with three series at the tip of tonight's 'pu' branch.
--------------------------------------------------
[Graduated to "master"]
* cb/doc-fetch-pull-merge (2009-10-21) 1 commit.
(merged to 'next' on 2009-10-21 at 1d9190d)
+ modernize fetch/merge/pull examples
* ja/fetch-doc (2009-10-22) 3 commits.
(merged to 'next' on 2009-10-22 at 8868407)
+ Documentation/merge-options.txt: order options in alphabetical groups
+ Documentation/git-pull.txt: Add subtitles above included option files
(merged to 'next' on 2009-10-21 at bf09f62)
+ Documentation/fetch-options.txt: order options alphabetically
* tr/maint-roff-quote (2009-10-22) 1 commit.
(merged to 'next' on 2009-10-22 at 14c5631)
+ Quote ' as \(aq in manpages
* ak/bisect-reset-to-switch (2009-10-13) 1 commit.
(merged to 'next' on 2009-10-22 at 592fff3)
+ bisect reset: Allow resetting to any commit, not just a branch
* jc/maint-1.6.3-graft-trailing-space (2009-10-14) 1 commit.
(merged to 'next' on 2009-10-22 at 90ccac6)
+ info/grafts: allow trailing whitespaces at the end of line
* jn/show-normalized-refs (2009-10-12) 3 commits.
(merged to 'next' on 2009-10-23 at 332aad3)
+ check-ref-format: simplify --print implementation
+ git check-ref-format --print
+ Add tests for git check-ref-format
* jc/checkout-auto-track (2009-10-18) 3 commits
(merged to 'next' on 2009-10-23 at ff7e8f3)
+ git checkout --no-guess
+ DWIM "git checkout frotz" to "git checkout -b frotz origin/frotz"
+ check_filename(): make verify_filename() callable without dying
The final shape of this series ended up to be more or less exactly what
Dscho hinted he wanted to have in one of the discussion.
* tr/stash-format (2009-10-19) 5 commits
(merged to 'next' on 2009-10-23 at 6c551c3)
+ stash list: drop the default limit of 10 stashes
+ stash list: use new %g formats instead of sed
+ Introduce new pretty formats %g[sdD] for reflog information
+ reflog-walk: refactor the branch@{num} formatting
+ Refactor pretty_print_commit arguments into a struct
* js/diff-verbose-submodule (2009-10-23) 2 commits.
(merged to 'next' on 2009-10-23 at e479773)
+ add tests for git diff --submodule
+ Add the --submodule option to the diff option family
--------------------------------------------------
[New Topics]
* bg/merge-ff-only (2009-10-29) 1 commit
- Teach 'git merge' and 'git pull' the option --ff-only
Soon in 'next'.
* jk/maint-1.6.3-ls-files-i (2009-10-30) 1 commit.
- ls-files: unbreak "ls-files -i"
Soon in 'next'.
* jn/editor-pager (2009-10-30) 8 commits
- Provide a build time default-pager setting
- Provide a build time default-editor setting
- am -i, git-svn: use "git var GIT_PAGER"
- add -i, send-email, svn, p4, etc: use "git var GIT_EDITOR"
- Teach git var about GIT_PAGER
- Teach git var about GIT_EDITOR
- Do not use VISUAL editor on dumb terminals
- Handle more shell metacharacters in editor names
Does not seem to pass t3404 by itself.
* js/maint-diff-color-words (2009-10-30) 3 commits.
- (pu) cleanup with diff_words_flush()
- diff --color-words -U0: fix the location of hunk headers
- t4034-diff-words: add a test for word diff without context
Replaces mh/maint-diff-color-words. The tip one is my "at least it would
be a bit more readable this way" patch without proper commit log message.
* sc/difftool-p4merge (2009-10-28) 1 commit
- mergetool--lib: add p4merge as a pre-configured mergetool option
Soon in 'next'.
* sc/protocol-doc (2009-10-29) 1 commit
- Update packfile transfer protocol documentation
Expecting replacement.
* sr/vcs-helper (2009-10-29) 19 commits
- .gitignore: add git-remote-cvs
- Refactor git_remote_cvs to a more generic git_remote_helpers
- More fixes to the git-remote-cvs installation procedure
- Fix the Makefile-generated path to the git_remote_cvs package in git-remote-cvs
- Add simple selftests of git-remote-cvs functionality
- git-remote-cvs: Remote helper program for CVS repositories
- 2/2: Add Python support library for CVS remote helper
- 1/2: Add Python support library for CVS remote helper
- Basic build infrastructure for Python scripts
- Allow helpers to request marks for fast-import
- Introduce <vcs>::<url> syntax for remote url
- Fix memory leak in helper method for disconnect
- Allow helpers to report in "list" command that the ref is unchanged
- Factor ref updating out of fetch_with_import
- Add support for "import" helper command
- Add a config option for remotes to specify a foreign vcs
- Allow programs to not depend on remotes having urls
- Allow fetch to modify refs
- Use a function to determine whether a remote is valid
Supposed to replace db/vcs-helper-rest and jh/cvs-helper but expecting
replacement. Does not pass selftest yet (e.g. t9801).
* tr/describe-advice (2009-10-28) 1 commit
- describe: when failing, tell the user about options that work
Soon in 'next'.
--------------------------------------------------
[Stalled]
* tr/filter-branch (2009-10-28) 2 commits.
- filter-branch: nearest-ancestor rewriting outside subdir filter
- filter-branch: stop special-casing $filter_subdir argument
J6t has some comments on this.
* ne/rev-cache (2009-10-19) 7 commits.
- support for commit grafts, slight change to general mechanism
- support for path name caching in rev-cache
- full integration of rev-cache into git, completed test suite
- administrative functions for rev-cache, start of integration into git
- support for non-commit object caching in rev-cache
- basic revision cache system, no integration or features
- man page and technical discussion for rev-cache
The author indicated that there is another round coming. Does not seem to
pass the tests when merged to 'pu'.
* jl/submodule-add-noname (2009-09-22) 1 commit.
- git submodule add: make the <path> parameter optional
Dscho started an interesting discussion regarding the larger workflow in
which the "submodule add" is used. I think the patch itself makes sense
but at the same time it probably makes sense to also take the <path> and
infer the <repository> as Dscho suggested, probably in "git submodule
add", not in "git add" proper, at least initially.
* sr/gfi-options (2009-09-06) 6 commits.
- fast-import: test the new option command
- fast-import: add option command
- fast-import: test the new feature command
- fast-import: add feature command
- fast-import: put marks reading in it's own function
- fast-import: put option parsing code in separate functions
Seems to be moving again soon.
* je/send-email-no-subject (2009-08-05) 1 commit.
(merged to 'next' on 2009-10-11 at 1b99c56)
+ send-email: confirm on empty mail subjects
The existing tests cover the positive case (i.e. as long as the user says
"yes" to the "do you really want to send this message that lacks subject",
the message is sent) of this feature, but the feature itself needs its own
test to verify the negative case (i.e. does it correctly stop if the user
says "no"?)
--------------------------------------------------
[Cooking]
* mr/gitweb-snapshot (2009-10-29) 3 commits.
- gitweb: Smarter snapshot names
- t/gitweb-lib.sh: Split gitweb output into headers and body
(merged to 'next' on 2009-10-11 at 22ba047)
+ gitweb: check given hash before trying to create snapshot
Replaced the tip with Jakub's updates.
* jp/dirty-describe (2009-10-21) 1 commit.
(merged to 'next' on 2009-10-30 at 19c7fc7)
+ Teach "git describe" --dirty option
* jp/fetch-cull-many-refs (2009-10-25) 2 commits
- fetch: Speed up fetch of large numbers of refs
- remote: Make ref_remove_duplicates faster for large numbers of refs
* bg/format-patch-p-noop (2009-10-25) 3 commits.
(merged to 'next' on 2009-10-30 at e34a3db)
+ format-patch documentation: Fix formatting
+ format-patch documentation: Remove diff options that are not useful
+ format-patch: Make implementation and documentation agree
* jk/gitignore-anchored (2009-10-26) 1 commit
(merged to 'next' on 2009-10-30 at 9391a93)
+ gitignore: root most patterns at the top-level directory
* jk/maint-add-p-empty (2009-10-27) 1 commit.
(merged to 'next' on 2009-10-30 at 2bd302f)
+ add-interactive: handle deletion of empty files
* jk/maint-push-config (2009-10-25) 1 commit.
(merged to 'next' on 2009-10-30 at 934e3c5)
+ push: always load default config
* lt/revision-bisect (2009-10-27) 1 commit.
(merged to 'next' on 2009-10-30 at 81ee52b)
+ Add '--bisect' revision machinery argument
* jc/pretty-lf (2009-10-04) 1 commit.
- Pretty-format: %[+-]x to tweak inter-item newlines
* rs/pretty-wrap (2009-10-17) 1 commit
(merged to 'next' on 2009-10-30 at 403bbfe)
+ Implement wrap format %w() as if it is a mode switch
(this branch uses js/log-rewrap.)
* js/log-rewrap (2009-10-18) 3 commits
(merged to 'next' on 2009-10-30 at 403bbfe)
+ Teach --wrap to only indent without wrapping
+ Add strbuf_add_wrapped_text() to utf8.[ch]
+ print_wrapped_text(): allow hard newlines
(this branch is used by rs/pretty-wrap.)
* sr/blame-incomplete (2009-10-19) 1 commit.
(merged to 'next' on 2009-10-22 at 133e0ce)
+ blame: make sure that the last line ends in an LF
I think this is _good enough_ as-is; although it would be better if we
added some hint to the output for Porcelain implementations, that can be
done as a follow-up fix.
* fc/doc-fast-forward (2009-10-24) 1 commit.
- Use 'fast-forward' all over the place
* ks/precompute-completion (2009-10-26) 3 commits.
(merged to 'next' on 2009-10-28 at cd5177f)
+ completion: ignore custom merge strategies when pre-generating
(merged to 'next' on 2009-10-22 at f46a28a)
+ bug: precomputed completion includes scripts sources
(merged to 'next' on 2009-10-14 at adf722a)
+ Speedup bash completion loading
* sp/smart-http (2009-10-30) 28 commits
- test smart http fetch and push
- http tests: use /dumb/ URL prefix
- set httpd port before sourcing lib-httpd
- t5540-http-push: remove redundant fetches
- Smart HTTP fetch: gzip requests
- Smart fetch over HTTP: client side
- Smart push over HTTP: client side
- Discover refs via smart HTTP server when available
- http-backend: more explict LocationMatch
- http-backend: add example for gitweb on same URL
- http-backend: use mod_alias instead of mod_rewrite
- http-backend: reword some documentation
- http-backend: add GIT_PROJECT_ROOT environment var
- Smart fetch and push over HTTP: server side
- Add stateless RPC options to upload-pack, receive-pack
- Git-aware CGI to provide dumb HTTP transport
- remote-helpers: return successfully if everything up-to-date
- Move WebDAV HTTP push under remote-curl
- remote-helpers: Support custom transport options
- remote-helpers: Fetch more than one ref in a batch
- fetch: Allow transport -v -v -v to set verbosity to 3
- remote-curl: Refactor walker initialization
- Add multi_ack_detailed capability to fetch-pack/upload-pack
- Move "get_ack()" back to fetch-pack
- fetch-pack: Use a strbuf to compose the want list
- pkt-line: Make packet_read_line easier to debug
- pkt-line: Add strbuf based functions
- http-push: fix check condition on http.c::finish_http_pack_request()
v5
* ef/msys-imap (2009-10-22) 9 commits.
- Windows: use BLK_SHA1 again
- MSVC: Enable OpenSSL, and translate -lcrypto
- mingw: enable OpenSSL
- mingw: wrap SSL_set_(w|r)fd to call _get_osfhandle
- imap-send: build imap-send on Windows
- imap-send: fix compilation-error on Windows
- imap-send: use run-command API for tunneling
- imap-send: use separate read and write fds
- imap-send: remove useless uid code
This is pulled from J6t; I'll merge it to 'next' if Dscho is Ok with it.
* jc/fix-tree-walk (2009-10-22) 11 commits.
(merged to 'next' on 2009-10-22 at 10c0c8f)
+ Revert failed attempt since 353c5ee
+ read-tree --debug-unpack
(merged to 'next' on 2009-10-11 at 0b058e2)
+ unpack-trees.c: look ahead in the index
+ unpack-trees.c: prepare for looking ahead in the index
+ Aggressive three-way merge: fix D/F case
+ traverse_trees(): handle D/F conflict case sanely
+ more D/F conflict tests
+ tests: move convenience regexp to match object names to test-lib.sh
+ unpack_callback(): use unpack_failed() consistently
+ unpack-trees: typofix
+ diff-lib.c: fix misleading comments on oneway_diff()
This has some stupid bugs and temporarily reverted from 'next' until I can
fix it.
* jh/notes (2009-10-09) 22 commits.
- fast-import: Proper notes tree manipulation using the notes API
- Refactor notes concatenation into a flexible interface for combining notes
- Notes API: Allow multiple concurrent notes trees with new struct notes_tree
- Notes API: for_each_note(): Traverse the entire notes tree with a callback
- Notes API: get_note(): Return the note annotating the given object
- Notes API: add_note(): Add note objects to the internal notes tree structure
- Notes API: init_notes(): Initialize the notes tree from the given notes ref
- Notes API: get_commit_notes() -> format_note() + remove the commit restriction
- Add selftests verifying concatenation of multiple notes for the same commit
- Refactor notes code to concatenate multiple notes annotating the same object
- Add selftests verifying that we can parse notes trees with various fanouts
- Teach the notes lookup code to parse notes trees with various fanout schemes
- Teach notes code to free its internal data structures on request
- Add '%N'-format for pretty-printing commit notes
- Add flags to get_commit_notes() to control the format of the note string
- t3302-notes-index-expensive: Speed up create_repo()
- fast-import: Add support for importing commit notes
- Teach "-m <msg>" and "-F <file>" to "git notes edit"
- Add an expensive test for git-notes
- Speed up git notes lookup
- Add a script to edit/inspect notes
- Introduce commit notes
I think Johan indicated that early parts of it is ready for 'next', so I
may do so up to "Add selftests" one.
* jn/gitweb-blame (2009-09-01) 5 commits.
- gitweb: Minify gitweb.js if JSMIN is defined
- gitweb: Create links leading to 'blame_incremental' using JavaScript
(merged to 'next' on 2009-10-11 at 73c4a83)
+ gitweb: Colorize 'blame_incremental' view during processing
+ gitweb: Incremental blame (using JavaScript)
+ gitweb: Add optional "time to generate page" info in footer
Ajax-y blame.
* nd/sparse (2009-08-20) 19 commits.
- sparse checkout: inhibit empty worktree
- Add tests for sparse checkout
- read-tree: add --no-sparse-checkout to disable sparse checkout support
- unpack-trees(): ignore worktree check outside checkout area
- unpack_trees(): apply $GIT_DIR/info/sparse-checkout to the final index
- unpack-trees(): "enable" sparse checkout and load $GIT_DIR/info/sparse-checkout
- unpack-trees.c: generalize verify_* functions
- unpack-trees(): add CE_WT_REMOVE to remove on worktree alone
- Introduce "sparse checkout"
- dir.c: export excluded_1() and add_excludes_from_file_1()
- excluded_1(): support exclude files in index
- unpack-trees(): carry skip-worktree bit over in merged_entry()
- Read .gitignore from index if it is skip-worktree
- Avoid writing to buffer in add_excludes_from_file_1()
- Teach Git to respect skip-worktree bit (writing part)
- Teach Git to respect skip-worktree bit (reading part)
- Introduce "skip-worktree" bit in index, teach Git to get/set this bit
- Add test-index-version
- update-index: refactor mark_valid() in preparation for new options
--------------------------------------------------
[For 1.7.0]
* jc/1.7.0-no-commit-no-ff-2 (2009-10-22) 1 commit.
- git-merge: forbid fast-forward and up-to-date when --no-commit is given
This makes "git merge --no-commit" fail when it results in fast-forward or
up-to-date. I haven't described this at the beginning of this message
yet, as it is not clear if this change is even necessary. Opinions?
* jk/1.7.0-status (2009-09-05) 5 commits.
- docs: note that status configuration affects only long format
(merged to 'next' on 2009-10-11 at 65c8513)
+ commit: support alternate status formats
+ status: add --porcelain output format
+ status: refactor format option parsing
+ status: refactor short-mode printing to its own function
(this branch uses jc/1.7.0-status.)
Gives the --short output format to post 1.7.0 "git commit --dry-run" that
is similar to that of post 1.7.0 "git status".
The tip one is not in 'next' as I have been hoping that somebody may want
to change the code to make it unnecessary, but it does not seem to be
happening, so probably it should also go to 'next'.
* jc/1.7.0-status (2009-09-05) 4 commits.
(merged to 'next' on 2009-10-11 at 9558627)
+ status: typo fix in usage
+ git status: not "commit --dry-run" anymore
+ git stat -s: short status output
+ git stat: the beginning of "status that is not a dry-run of commit"
(this branch is used by jk/1.7.0-status.)
With this, "git status" is no longer "git commit --dry-run".
* jc/1.7.0-send-email-no-thread-default (2009-08-22) 1 commit.
(merged to 'next' on 2009-10-11 at 043acdf)
+ send-email: make --no-chain-reply-to the default
* jc/1.7.0-diff-whitespace-only-status (2009-08-30) 4 commits.
(merged to 'next' on 2009-10-11 at 546c74d)
+ diff.c: fix typoes in comments
+ Make test case number unique
+ diff: Rename QUIET internal option to QUICK
+ diff: change semantics of "ignore whitespace" options
This changes exit code from "git diff --ignore-whitespace" and friends
when there is no actual output. It is a backward incompatible change, but
we could argue that it is a bugfix.
* jc/1.7.0-push-safety (2009-02-09) 2 commits.
(merged to 'next' on 2009-10-11 at 81b8128)
+ Refuse deleting the current branch via push
+ Refuse updating the current branch in a non-bare repository via push
--------------------------------------------------
[I have been too busy to purge these]
* jc/log-tz (2009-03-03) 1 commit.
- Allow --date=local --date=other-format to work as expected
Maybe some people care about this. I dunno.
* jc/mailinfo-remove-brackets (2009-07-15) 1 commit.
- mailinfo: -b option keeps [bracketed] strings that is not a [PATCH] marker
Maybe some people care about this. I dunno.
* jg/log-format-body-indent (2009-09-19) 1 commit.
. git-log --format: Add %B tag with %B(x) option
* mh/maint-diff-color-words (2009-10-28) 3 commits
. diff: fix the location of hunk headers for "git diff --color-words -U0"
. diff: move the handling of the hunk header after the changed lines
. t4034-diff-words: add a test for word diff without context
Ejected; js/maint-diff-color-words replaces this.
* db/vcs-helper-rest (2009-10-27) 7 commits.
. Fix memory leak in helper method for disconnect
. Allow helpers to report in "list" command that the ref is unchanged
. Add support for "import" helper command
. Add a config option for remotes to specify a foreign vcs
. Allow programs to not depend on remotes having urls
. Allow fetch to modify refs
. Use a function to determine whether a remote is valid
(this branch is used by jh/cvs-helper.)
* jh/cvs-helper (2009-08-18) 8 commits.
. More fixes to the git-remote-cvs installation procedure
. Fix the Makefile-generated path to the git_remote_cvs package in git-remote-cvs
. Add simple selftests of git-remote-cvs functionality
. git-remote-cvs: Remote helper program for CVS repositories
. 2/2: Add Python support library for CVS remote helper
. 1/2: Add Python support library for CVS remote helper
. Basic build infrastructure for Python scripts
. Allow helpers to request marks for fast-import
(this branch uses db/vcs-helper-rest.)
Ejected; sr/vcs-helper is supposed to replace these two.
^ permalink raw reply
* Re: [PATCH v3] Teach git var about GIT_EDITOR
From: Jonathan Nieder @ 2009-10-31 4:53 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031040436.GB6022@progeny.tock>
A typo fix --- sorry for the noise.
Jonathan Nieder wrote:
> --- a/var.c
> +++ b/var.c
> @@ -8,6 +8,16 @@
>
> static const char var_usage[] = "git var [-l | <variable>]";
>
> +static const char *editor(int flag)
> +{
> + const char *pgm = git_editor();
> +
> + if (!pgm && flag & IDENT_ERROR_ON_NO_NAME)
> + die("terminal is dumb, but VISUAL and EDITOR unset");
Agh... s/VISUAL and //.
All right, time to sleep. Apologies for all the mistakes, and thanks
for the help catching them.
Kind regards,
Jonathan
^ permalink raw reply
* Gitolite update
From: Sitaram Chamarty @ 2009-10-31 6:02 UTC (permalink / raw)
To: Git Mailing List
This is an update on gitolite, an ssh-based access control tool for
using git in a typical corporate environment. The latest version is
always at git://github.com/sitaramc/gitolite.git
While still remaining upward compatible with the "inspiration" project
(gitosis), the extra features now form the largest section in
http://github.com/sitaramc/gitolite/blob/pu/doc/3-faq-tips-etc.mkd.
This was mostly the result of users asking for features they wanted, so
please take a look to see if something there strikes your fancy.
[However, the 2 programs that do the actual access control *still*
total only about 90 lines; I firmly intend to keep those less than
100 to make them easy to audit for security.]
Significant additions since the last update
-------------------------------------------
Installs/upgrades
* The easy install script is also good for upgrades. The new "-q"
option is particularly useful, and makes an upgrade really quick and
"one command".
Remote admin mode (where you make config changes in a clone of the
gitolite-admin repo, and push them to the server) is now the
*default*. I think I managed to put enough ssh intelligence into
the ssh aspect to make this finally work without pain, and people on
#git have said it does work (i.e., it's not just me claiming it ;-)
Config file maintenance
* Large config files (when you have many, many, repos) can be split up
and delegated to different people. The main config file can give a
specific user the authority to manage a specific group of repos, and
that user can then maintain the access control for those repos
independently.
* Config files are also checked for mismatches in pubkeys and
usernames, which is good for catching typos early.
Documentation etc
* The documentation, help text, and messages that come out have had
numerous changes based on user feedback on #git. Like in the easy
install script, a lot of effort has gone into the ssh aspect.
Other (minor) updates
---------------------
* Supports git installed outside the normal $PATH (on the server).
Without this, *all* your users would have to specify the upload-pack
and receive-pack program paths, either by setting config variables
or using "-u", "--exec" etc. in the clone/push commands.
* Trying a plain ssh to your gitolite account now tells you what repos
you have access to, instead of a (largely useless) error message
about needing SSH_ORIGINAL_COMMAND. This sounds like a gimmick...
until you actually need it :)
* I've finally started tagging releases, and now an install or an
upgrade done from a clone will record the version number. When you
upgrade, it tells you you're upgrading from version foo to version
bar.
* When specifying repos in subdirectories (foo/bar/baz.git) you no
longer have to manually create foo/bar on the server first.
Recap of older features (for completeness)
------------------------------------------
* per-branch permissions, including fine-grained control over "rewind"
* install without root access on any Unix
* simpler but much more powerful config file syntax
* more comprehensive logging
* "personal" namespace prefix for each user
* "deny" rights in the config file (in the "rebel" branch)
Questions and support
---------------------
I'm often on #git, subject to my living in UTC+0530 time, and email is
also welcome (sitaramc@gmail.com is preferred, but
sitaram.chamarty@tcs.com may get my attention quicker). If you log an
issue on github, please also send an email; I am checking github more
often now (having missed two issues for many days) but it's not as
frequent as I would have liked.
--
Sitaram
sitaramc@gmail.com / sitaram.chamarty@tcs.com
^ permalink raw reply
* [PATCH v4] imap-send.c: fix compiler warnings for OpenSSL 1.0
From: Vietor Liu @ 2009-10-31 6:36 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Fedora 12 has upgraded OpenSSL to 1.0.0-beta3 version.
When compiling git on Fedora 12, the following warning is displayed:
imap-send.c: In function ‘ssl_socket_connect’:
imap-send.c:284: warning: assignment discards qualifiers from pointer target type
imap-send.c:286: warning: assignment discards qualifiers from pointer target type
==============================================
The relevant change in OpenSSL 1.0:
*) Let the TLSv1_method() etc. functions return a 'const' SSL_METHOD
pointer and make the SSL_METHOD parameter in SSL_CTX_new,
SSL_CTX_set_ssl_version and SSL_set_ssl_method 'const'.
Signed-off-by: Vietor Liu <vietor@vxwo.org>
---
imap-send.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/imap-send.c b/imap-send.c
index 3847fd1..f805c6e 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -273,7 +273,11 @@ static int ssl_socket_connect(struct imap_socket *sock, int use_tls_only, int ve
fprintf(stderr, "SSL requested but SSL support not compiled in\n");
return -1;
#else
+#if (OPENSSL_VERSION_NUMBER >= 0x10000000L)
+ const SSL_METHOD *meth;
+#else
SSL_METHOD *meth;
+#endif
SSL_CTX *ctx;
int ret;
--
1.6.5.2
^ permalink raw reply related
* [PATCH v2 2/8] Do not use VISUAL editor on dumb terminals
From: Jonathan Nieder @ 2009-10-31 7:46 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031013039.GC5160@progeny.tock>
Jonathan Nieder wrote:
> Refuse to use $VISUAL and fall back to $EDITOR if TERM is unset
> or set to "dumb". Traditionally, VISUAL is set to a screen
> editor and EDITOR to a line-based editor, which should be more
> useful in that situation.
I was too lazy to wait for tests to finish on this one, and lo and
behold, they did not pass.
These additional changes seem to help, and they also add a test to
explain the change in editor behavior. The patch with these changes
squashed is also included in this message, below the scissors mark.
In the controlled environment used for tests, TERM is set to dumb
and ever since commit 02b3566 (test-lib.sh: Add a test_set_editor
function to safely set $VISUAL, 2008-05-04), most tests set VISUAL
when they want to set an editor for git to use. With this patch, they
should be using EDITOR instead.
--- a/t/t7005-editor.sh
+++ b/t/t7005-editor.sh
@@ -42,6 +42,16 @@ test_expect_success 'dumb should error out when falling back on vi' '
fi
'
+test_expect_success 'dumb should prefer EDITOR to VISUAL' '
+
+ EDITOR=./e-EDITOR.sh &&
+ VISUAL=./e-VISUAL.sh &&
+ export EDITOR VISUAL &&
+ git commit --amend &&
+ test "$(git show -s --format=%s)" = "Edited by EDITOR"
+
+'
+
TERM=vt100
export TERM
for i in vi EDITOR VISUAL core_editor GIT_EDITOR
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -86,7 +86,7 @@ chmod 755 editor
test_expect_success \
"amend commit" \
- "VISUAL=./editor git commit --amend"
+ "EDITOR=./editor git commit --amend"
test_expect_success \
"passing -m and -F" \
@@ -107,7 +107,7 @@ chmod 755 editor
test_expect_success \
"editing message from other commit" \
"echo 'hula hula' >file && \
- VISUAL=./editor git commit -c HEAD^ -a"
+ EDITOR=./editor git commit -c HEAD^ -a"
test_expect_success \
"message from stdin" \
@@ -141,10 +141,10 @@ EOF
test_expect_success \
'editor not invoked if -F is given' '
echo "moo" >file &&
- VISUAL=./editor git commit -a -F msg &&
+ EDITOR=./editor git commit -a -F msg &&
git show -s --pretty=format:"%s" | grep -q good &&
echo "quack" >file &&
- echo "Another good message." | VISUAL=./editor git commit -a -F - &&
+ echo "Another good message." | EDITOR=./editor git commit -a -F - &&
git show -s --pretty=format:"%s" | grep -q good
'
# We could just check the head sha1, but checking each commit makes it
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -30,7 +30,7 @@ TZ=UTC
TERM=dumb
export LANG LC_ALL PAGER TERM TZ
EDITOR=:
-VISUAL=:
+unset VISUAL
unset GIT_EDITOR
unset AUTHOR_DATE
unset AUTHOR_EMAIL
@@ -58,7 +58,7 @@ GIT_MERGE_VERBOSITY=5
export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
-export EDITOR VISUAL
+export EDITOR
GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
# Protect ourselves from common misconfiguration to export
@@ -207,8 +207,8 @@ trap 'die' EXIT
test_set_editor () {
FAKE_EDITOR="$1"
export FAKE_EDITOR
- VISUAL='"$FAKE_EDITOR"'
- export VISUAL
+ EDITOR='"$FAKE_EDITOR"'
+ export EDITOR
}
test_tick () {
-- %< --
Subject: [PATCH] Do not use VISUAL editor on dumb terminals
Refuse to use $VISUAL and fall back to $EDITOR if TERM is unset
or set to "dumb". Traditionally, VISUAL is set to a screen
editor and EDITOR to a line-based editor, which should be more
useful in that situation.
vim, for example, is happy to assume a terminal supports ANSI
sequences even if TERM is dumb (e.g., when running from a text
editor like Acme). git already refuses to fall back to vi on a
dumb terminal if GIT_EDITOR, core.editor, VISUAL, and EDITOR are
unset, but without this patch, that check is suppressed by
VISUAL=vi.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jonathan Nieder <jrn@progeny.tock>
---
editor.c | 12 ++++++------
t/t7005-editor.sh | 10 ++++++++++
t/t7501-commit.sh | 8 ++++----
t/test-lib.sh | 8 ++++----
4 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/editor.c b/editor.c
index 941c0b2..3f13751 100644
--- a/editor.c
+++ b/editor.c
@@ -4,19 +4,19 @@
int launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
{
- const char *editor, *terminal;
+ const char *editor = getenv("GIT_EDITOR");
+ const char *terminal = getenv("TERM");
+ int terminal_is_dumb = !terminal || !strcmp(terminal, "dumb");
- editor = getenv("GIT_EDITOR");
if (!editor && editor_program)
editor = editor_program;
- if (!editor)
+ if (!editor && !terminal_is_dumb)
editor = getenv("VISUAL");
if (!editor)
editor = getenv("EDITOR");
- terminal = getenv("TERM");
- if (!editor && (!terminal || !strcmp(terminal, "dumb")))
- return error("Terminal is dumb but no VISUAL nor EDITOR defined.");
+ if (!editor && terminal_is_dumb)
+ return error("terminal is dumb, but EDITOR unset");
if (!editor)
editor = "vi";
diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh
index b647957..a95fe19 100755
--- a/t/t7005-editor.sh
+++ b/t/t7005-editor.sh
@@ -42,6 +42,16 @@ test_expect_success 'dumb should error out when falling back on vi' '
fi
'
+test_expect_success 'dumb should prefer EDITOR to VISUAL' '
+
+ EDITOR=./e-EDITOR.sh &&
+ VISUAL=./e-VISUAL.sh &&
+ export EDITOR VISUAL &&
+ git commit --amend &&
+ test "$(git show -s --format=%s)" = "Edited by EDITOR"
+
+'
+
TERM=vt100
export TERM
for i in vi EDITOR VISUAL core_editor GIT_EDITOR
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index d2de576..a603f6d 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -86,7 +86,7 @@ chmod 755 editor
test_expect_success \
"amend commit" \
- "VISUAL=./editor git commit --amend"
+ "EDITOR=./editor git commit --amend"
test_expect_success \
"passing -m and -F" \
@@ -107,7 +107,7 @@ chmod 755 editor
test_expect_success \
"editing message from other commit" \
"echo 'hula hula' >file && \
- VISUAL=./editor git commit -c HEAD^ -a"
+ EDITOR=./editor git commit -c HEAD^ -a"
test_expect_success \
"message from stdin" \
@@ -141,10 +141,10 @@ EOF
test_expect_success \
'editor not invoked if -F is given' '
echo "moo" >file &&
- VISUAL=./editor git commit -a -F msg &&
+ EDITOR=./editor git commit -a -F msg &&
git show -s --pretty=format:"%s" | grep -q good &&
echo "quack" >file &&
- echo "Another good message." | VISUAL=./editor git commit -a -F - &&
+ echo "Another good message." | EDITOR=./editor git commit -a -F - &&
git show -s --pretty=format:"%s" | grep -q good
'
# We could just check the head sha1, but checking each commit makes it
diff --git a/t/test-lib.sh b/t/test-lib.sh
index f2ca536..ec3336a 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -30,7 +30,7 @@ TZ=UTC
TERM=dumb
export LANG LC_ALL PAGER TERM TZ
EDITOR=:
-VISUAL=:
+unset VISUAL
unset GIT_EDITOR
unset AUTHOR_DATE
unset AUTHOR_EMAIL
@@ -58,7 +58,7 @@ GIT_MERGE_VERBOSITY=5
export GIT_MERGE_VERBOSITY
export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
-export EDITOR VISUAL
+export EDITOR
GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
# Protect ourselves from common misconfiguration to export
@@ -207,8 +207,8 @@ trap 'die' EXIT
test_set_editor () {
FAKE_EDITOR="$1"
export FAKE_EDITOR
- VISUAL='"$FAKE_EDITOR"'
- export VISUAL
+ EDITOR='"$FAKE_EDITOR"'
+ export EDITOR
}
test_tick () {
--
1.6.5.2
>
> vim, for example, is happy to assume a terminal supports ANSI
> sequences even if TERM is dumb (e.g., when running from a text
> editor like Acme). git already refuses to fall back to vi on a
> dumb terminal if GIT_EDITOR, core.editor, VISUAL, and EDITOR are
> unset, but without this patch, that check is suppressed by
> VISUAL=vi.
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> This patch eases my discomfort about the error message a little. It
> is not actually needed to support any ways of working I engage in.
>
> If stdout is redirected, this is probably still making the wrong
> choice; isatty(STDOUT_FILENO) might be a more useful datum to use.
> But it does not seem worth complicating the logic further.
>
> editor.c | 12 ++++++------
> 1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/editor.c b/editor.c
> index 941c0b2..3f13751 100644
> --- a/editor.c
> +++ b/editor.c
> @@ -4,19 +4,19 @@
>
> int launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
> {
> - const char *editor, *terminal;
> + const char *editor = getenv("GIT_EDITOR");
> + const char *terminal = getenv("TERM");
> + int terminal_is_dumb = !terminal || !strcmp(terminal, "dumb");
>
> - editor = getenv("GIT_EDITOR");
> if (!editor && editor_program)
> editor = editor_program;
> - if (!editor)
> + if (!editor && !terminal_is_dumb)
> editor = getenv("VISUAL");
> if (!editor)
> editor = getenv("EDITOR");
>
> - terminal = getenv("TERM");
> - if (!editor && (!terminal || !strcmp(terminal, "dumb")))
> - return error("Terminal is dumb but no VISUAL nor EDITOR defined.");
> + if (!editor && terminal_is_dumb)
> + return error("terminal is dumb, but EDITOR unset");
>
> if (!editor)
> editor = "vi";
> --
> 1.6.5.2
>
^ permalink raw reply related
* [PATCH v4] Teach git var about GIT_EDITOR
From: Jonathan Nieder @ 2009-10-31 7:56 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Ben Walton, Johannes Sixt, David Roundy, GIT List
In-Reply-To: <20091031045358.GA9565@progeny.tock>
Expose the command used by launch_editor() for scripts to use.
This should allow one to avoid searching for a proper editor
separately in each command.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
There was another typo in the patch I sent. The paper-bag fix:
diff -u b/var.c b/var.c
--- b/var.c
+++ b/var.c
@@ -35,7 +35,7 @@
const char *val;
for (ptr = git_vars; ptr->read; ptr++)
- if ((val = ptr->read(0))
+ if ((val = ptr->read(0)))
printf("%s=%s\n", ptr->name, val);
}
Here’s an updated patch. This one shouldn’t have any bugs (yeah, right).
Good night again,
Jonathan
Documentation/git-var.txt | 8 ++++++++
cache.h | 1 +
editor.c | 14 ++++++++++++--
var.c | 16 +++++++++++++++-
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-var.txt b/Documentation/git-var.txt
index e2f4c09..89e4b4f 100644
--- a/Documentation/git-var.txt
+++ b/Documentation/git-var.txt
@@ -36,6 +36,14 @@ GIT_AUTHOR_IDENT::
GIT_COMMITTER_IDENT::
The person who put a piece of code into git.
+GIT_EDITOR::
+ Text editor for use by git commands. The value is meant to be
+ interpreted by the shell when it is used. Examples: `~/bin/vi`,
+ `$SOME_ENVIRONMENT_VARIABLE`, `"C:\Program Files\Vim\gvim.exe"
+ --nofork`. The order of preference is the `$GIT_EDITOR`
+ environment variable, then `core.editor` configuration, then
+ `$VISUAL`, then `$EDITOR`, and then finally 'vi'.
+
Diagnostics
-----------
You don't exist. Go away!::
diff --git a/cache.h b/cache.h
index 96840c7..311cfe1 100644
--- a/cache.h
+++ b/cache.h
@@ -750,6 +750,7 @@ extern const char *git_author_info(int);
extern const char *git_committer_info(int);
extern const char *fmt_ident(const char *name, const char *email, const char *date_str, int);
extern const char *fmt_name(const char *name, const char *email);
+extern const char *git_editor(void);
struct checkout {
const char *base_dir;
diff --git a/editor.c b/editor.c
index 3f13751..4f98b72 100644
--- a/editor.c
+++ b/editor.c
@@ -2,7 +2,7 @@
#include "strbuf.h"
#include "run-command.h"
-int launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
+const char *git_editor(void)
{
const char *editor = getenv("GIT_EDITOR");
const char *terminal = getenv("TERM");
@@ -16,11 +16,21 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
editor = getenv("EDITOR");
if (!editor && terminal_is_dumb)
- return error("terminal is dumb, but EDITOR unset");
+ return NULL;
if (!editor)
editor = "vi";
+ return editor;
+}
+
+int launch_editor(const char *path, struct strbuf *buffer, const char *const *env)
+{
+ const char *editor = git_editor();
+
+ if (!editor)
+ return error("terminal is dumb, but EDITOR unset");
+
if (strcmp(editor, ":")) {
size_t len = strlen(editor);
int i = 0;
diff --git a/var.c b/var.c
index dacbaab..a303757 100644
--- a/var.c
+++ b/var.c
@@ -8,6 +8,16 @@
static const char var_usage[] = "git var [-l | <variable>]";
+static const char *editor(int flag)
+{
+ const char *pgm = git_editor();
+
+ if (!pgm && flag & IDENT_ERROR_ON_NO_NAME)
+ die("terminal is dumb, but EDITOR unset");
+
+ return pgm;
+}
+
struct git_var {
const char *name;
const char *(*read)(int);
@@ -15,14 +25,18 @@ struct git_var {
static struct git_var git_vars[] = {
{ "GIT_COMMITTER_IDENT", git_committer_info },
{ "GIT_AUTHOR_IDENT", git_author_info },
+ { "GIT_EDITOR", editor },
{ "", NULL },
};
static void list_vars(void)
{
struct git_var *ptr;
+ const char *val;
+
for (ptr = git_vars; ptr->read; ptr++)
- printf("%s=%s\n", ptr->name, ptr->read(0));
+ if ((val = ptr->read(0)))
+ printf("%s=%s\n", ptr->name, val);
}
static const char *read_var(const char *var)
--
1.6.5.2
^ permalink raw reply related
* Re: [PATCH] Don't create the $GIT_DIR/branches directory on init
From: Thomas Rast @ 2009-10-31 9:11 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: Junio C Hamano, git, spearce, sasa.zivkov
In-Reply-To: <1256923228-18949-1-git-send-email-robin.rosenberg@dewire.com>
Robin Rosenberg wrote:
> Git itself does not even look at this directory.
This contradicts the git-fetch manpage though: from urls-remotes.txt,
it includes
The name of one of the following can be used instead
of a URL as `<repository>` argument:
* a remote in the git configuration file: `$GIT_DIR/config`,
* a file in the `$GIT_DIR/remotes` directory, or
* a file in the `$GIT_DIR/branches` directory.
(and a longer explanation of what they need to look like).
So which one is wrong?
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: [PATCH] clone: detect extra arguments
From: Johan Herland @ 2009-10-31 11:32 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jeff King, Jonathan Nieder
In-Reply-To: <20091030145108.GA881@coredump.intra.peff.net>
On Friday 30 October 2009, Jeff King wrote:
> On Fri, Oct 30, 2009 at 10:45:25AM -0400, Jeff King wrote:
> > But looking at the usage message, there is some potential for cleanup.
>
> Also, we should probably do this (I did it as a patch on master, though,
> as it is an independent fix):
>
> -- >8 --
> Subject: [PATCH] clone: fix --recursive usage message
>
> Looks like a mistaken cut-and-paste in e7fed18a.
Yes. Please fix my screwup.
> Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Johan Herland <johan@herland.net>
> ---
> builtin-clone.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/builtin-clone.c b/builtin-clone.c
> index 5762a6f..436e8da 100644
> --- a/builtin-clone.c
> +++ b/builtin-clone.c
> @@ -61,7 +61,7 @@ static struct option builtin_clone_options[] = {
> OPT_BOOLEAN('s', "shared", &option_shared,
> "setup as shared repository"),
> OPT_BOOLEAN(0, "recursive", &option_recursive,
> - "setup as shared repository"),
> + "initialize submodules in the clone"),
> OPT_STRING(0, "template", &option_template, "path",
> "path the template repository"),
> OPT_STRING(0, "reference", &option_reference, "repo",
>
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
^ permalink raw reply
* Re: [PATCH] diff --color-words -U0: fix the location of hunk headers
From: Johannes Schindelin @ 2009-10-31 11:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: markus.heidelberg, git
In-Reply-To: <7vr5sklo7c.fsf@alter.siamese.dyndns.org>
Hi,
On Fri, 30 Oct 2009, Junio C Hamano wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
> > The reason I did not do that was to avoid a full subroutine call, as I
> > expected this code path to be very expensive.
>
> This is only done for the "word diff" mode, and my gut feeling is that it
> is not such a big issue.
Yeah, sorry, I should have stated explicitely that I no longer think that
there is a performance issue.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH 10/19] Allow helpers to request marks for fast-import
From: Johan Herland @ 2009-10-31 12:04 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: git, Johannes Schindelin, Daniel Barkalow
In-Reply-To: <fabb9a1e0910300526v5cbcf685l69f60c58b7e3732@mail.gmail.com>
On Friday 30 October 2009, Sverre Rabbelier wrote:
> Heya,
>
> On Fri, Oct 30, 2009 at 01:21, Johan Herland <johan@herland.net> wrote:
> > Please drop this patch from the series. The functionality is not
> > needed, since we'll use the fast-import "option" command from the
> > sr/gfi-options series instead.
>
> In that case I will rebase the series on top of sr/gfi-options then as
> soon as I reroll that one.
Good.
> Also, do you need to change anything else in git-remote-cvs to do that?
Yes, the sr/gfi-options series does cause some changes, both in git-remote-
cvs, and in the support libraries (adding a couple of methods to the
GitFastImport class in git.py).
This conglomeration of patch series is becoming fairly complicated, and it's
becoming hard to stay in sync. I suggest that you drop the CVS-specific
parts from this series, and work on stabilizing the common infrastructure.
Once that has settled, you can send a git-remote-hg series, and I can send a
rebased and updated git-remote-cvs series.
Feel free to reorganize the patches so that the git_remote_helpers
infrastructure is created in the correct location (instead of reorganizing
git_remote_cvs).
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
^ 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