Git development
 help / color / mirror / Atom feed
* Re: [PATCH] Color support for "git-add -i"
From: Wincent Colaiuta @ 2007-12-05 13:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Dan Zwell, Jeff King, git
In-Reply-To: <7vbq95tnk7.fsf@gitster.siamese.dyndns.org>

El 5/12/2007, a las 11:59, Junio C Hamano escribió:

> This is mostly lifted from earlier series by Dan Zwell, but updated to
> use "git config --get-color" to make it simpler and more consistent  
> with
> commands written in C.

Tested here and seems to work well. This is a nice little bit of  
usability polish.

Cheers,
Wincent

^ permalink raw reply

* Re: [PATCH] Color support for "git-add -i"
From: Wincent Colaiuta @ 2007-12-05 13:52 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Junio C Hamano, Dan Zwell, Jeff King, git
In-Reply-To: <475697BC.2090701@viscovery.net>

El 5/12/2007, a las 13:21, Johannes Sixt escribió:

> Junio C Hamano schrieb:
>> +color.interactive::
>> +	When true (or `always`), always use colors in `git add
>> +	--interactive`.  When false (or `never`), never.  When set to
>> +	`auto`, use colors only when the output is to the
>> +	terminal. Defaults to false.
>
> Any particular reason why color.interactive = true should be  
> different from
> color.diff = true? See 57f2b842 ("color.diff = true" is not "always"  
> anymore)

I wonder when you'd ever run an interactive command and not be in a  
terminal? ie. it doesn't make much sense to ever do "git add -i >  
foo", except perhaps from the test suite.

Notwithstanding, consistency for the sake of consistency is probably a  
good thing.

Cheers,
Wincent

^ permalink raw reply

* [PATCH] Add option --path to allow to run tests with real systems
From: Nguyễn Thái Ngọc Duy @ 2007-12-05 13:45 UTC (permalink / raw)
  To: git


Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 As we have decided to move git-* to gitexecdir, we should
 make sure it works.

 I'm running tests with --path now and saw some errors. Some
 of them could be from bugs of this patch. I haven't looked into
 them yet.

 t/lib-git-svn.sh          |    2 +-
 t/t0000-basic.sh          |    6 +++---
 t/t0040-parse-options.sh  |   16 ++++++++--------
 t/t4200-rerere.sh         |    8 ++++----
 t/t5301-sliding-window.sh |    2 +-
 t/t5302-pack-index.sh     |    4 ++--
 t/test-lib.sh             |   18 ++++++++++++++----
 7 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 8d4a447..fd60ebc 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -46,7 +46,7 @@ rawsvnrepo="$svnrepo"
 svnrepo="file://$svnrepo"
 
 poke() {
-	test-chmtime +1 "$1"
+	$GIT_TEST_PATH/test-chmtime +1 "$1"
 }
 
 SVN_HTTPD_MODULE_PATH=${SVN_HTTPD_MODULE_PATH-'/usr/lib/apache2/modules'}
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 4e49d59..f809163 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -289,12 +289,12 @@ test_expect_success 'absolute path works as expected' '
 	mkdir third &&
 	dir="$(cd .git; pwd -P)" &&
 	dir2=third/../second/other/.git &&
-	test "$dir" = "$(test-absolute-path $dir2)" &&
+	test "$dir" = "$($GIT_TEST_PATH/test-absolute-path $dir2)" &&
 	file="$dir"/index &&
-	test "$file" = "$(test-absolute-path $dir2/index)" &&
+	test "$file" = "$($GIT_TEST_PATH/test-absolute-path $dir2/index)" &&
 	ln -s ../first/file .git/syml &&
 	sym="$(cd first; pwd -P)"/file &&
-	test "$sym" = "$(test-absolute-path $dir2/syml)"
+	test "$sym" = "$($GIT_TEST_PATH/test-absolute-path $dir2/syml)"
 '
 
 test_done
diff --git a/t/t0040-parse-options.sh b/t/t0040-parse-options.sh
index 462fdf2..ca1cc9f 100755
--- a/t/t0040-parse-options.sh
+++ b/t/t0040-parse-options.sh
@@ -23,7 +23,7 @@ string options
 EOF
 
 test_expect_success 'test help' '
-	! test-parse-options -h > output 2> output.err &&
+	! $GIT_TEST_PATH/test-parse-options -h > output 2> output.err &&
 	test ! -s output &&
 	git diff expect.err output.err
 '
@@ -35,7 +35,7 @@ string: 123
 EOF
 
 test_expect_success 'short options' '
-	test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
 	git diff expect output &&
 	test ! -s output.err
 '
@@ -46,7 +46,7 @@ string: 321
 EOF
 
 test_expect_success 'long options' '
-	test-parse-options --boolean --integer 1729 --boolean --string2=321 \
+	$GIT_TEST_PATH/test-parse-options --boolean --integer 1729 --boolean --string2=321 \
 		> output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
@@ -62,7 +62,7 @@ arg 02: --boolean
 EOF
 
 test_expect_success 'intermingled arguments' '
-	test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
+	$GIT_TEST_PATH/test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
 		> output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
@@ -75,19 +75,19 @@ string: (not set)
 EOF
 
 test_expect_success 'unambiguously abbreviated option' '
-	test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
 
 test_expect_success 'unambiguously abbreviated option with "="' '
-	test-parse-options --int=2 > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --int=2 > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
 
 test_expect_failure 'ambiguously abbreviated option' '
-	test-parse-options --strin 123;
+	$GIT_TEST_PATH/test-parse-options --strin 123;
         test $? != 129
 '
 
@@ -98,7 +98,7 @@ string: 123
 EOF
 
 test_expect_success 'non ambiguous option (after two options it abbreviates)' '
-	test-parse-options --st 123 > output 2> output.err &&
+	$GIT_TEST_PATH/test-parse-options --st 123 > output 2> output.err &&
 	test ! -s output.err &&
 	git diff expect output
 '
diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index cfcdb69..ddbae1d 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -149,16 +149,16 @@ just_over_15_days_ago=$((-1-15*86400))
 almost_60_days_ago=$((60-60*86400))
 just_over_60_days_ago=$((-1-60*86400))
 
-test-chmtime =$almost_60_days_ago $rr/preimage
-test-chmtime =$almost_15_days_ago $rr2/preimage
+$GIT_TEST_PATH/test-chmtime =$almost_60_days_ago $rr/preimage
+$GIT_TEST_PATH/test-chmtime =$almost_15_days_ago $rr2/preimage
 
 test_expect_success 'garbage collection (part1)' 'git rerere gc'
 
 test_expect_success 'young records still live' \
 	"test -f $rr/preimage && test -f $rr2/preimage"
 
-test-chmtime =$just_over_60_days_ago $rr/preimage
-test-chmtime =$just_over_15_days_ago $rr2/preimage
+$GIT_TEST_PATH/test-chmtime =$just_over_60_days_ago $rr/preimage
+$GIT_TEST_PATH/test-chmtime =$just_over_15_days_ago $rr2/preimage
 
 test_expect_success 'garbage collection (part2)' 'git rerere gc'
 
diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh
index 073ac0c..8327051 100755
--- a/t/t5301-sliding-window.sh
+++ b/t/t5301-sliding-window.sh
@@ -12,7 +12,7 @@ test_expect_success \
      for i in a b c
      do
          echo $i >$i &&
-         test-genrandom "$i" 32768 >>$i &&
+         $GIT_TEST_PATH/test-genrandom "$i" 32768 >>$i &&
          git update-index --add $i || return 1
      done &&
      echo d >d && cat c >>d && git update-index --add d &&
diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh
index 2a2878b..0ae9cd8 100755
--- a/t/t5302-pack-index.sh
+++ b/t/t5302-pack-index.sh
@@ -15,11 +15,11 @@ test_expect_success \
      do
 		 i=`printf '%03i' $i`
          echo $i >file_$i &&
-         test-genrandom "$i" 8192 >>file_$i &&
+         $GIT_TEST_PATH/test-genrandom "$i" 8192 >>file_$i &&
          git update-index --add file_$i &&
 		 i=`expr $i + 1` || return 1
      done &&
-     { echo 101 && test-genrandom 100 8192; } >file_101 &&
+     { echo 101 && $GIT_TEST_PATH/test-genrandom 100 8192; } >file_101 &&
      git update-index --add file_101 &&
      tree=`git write-tree` &&
      commit=`git commit-tree $tree </dev/null` && {
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 90b6844..50a3551 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -84,6 +84,8 @@ do
 	--no-python)
 		# noop now...
 		shift ;;
+	--path=*)
+		path="${1#*=}"; shift ;;
 	*)
 		break ;;
 	esac
@@ -296,11 +298,19 @@ test_done () {
 
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in trash subdirectory.
-PATH=$(pwd)/..:$PATH
-GIT_EXEC_PATH=$(pwd)/..
+if [ -n "$path" ]; then
+	[ -x "$path/git" ] || error "git not found in $path"
+	PATH="$path":$PATH
+	export PATH
+	GIT_EXEC_PATH="$(git --exec-path)"
+else
+	PATH=$(pwd)/..:$PATH
+	GIT_EXEC_PATH=$(pwd)/..
+fi
+GIT_TEST_PATH=$(pwd)/..
 GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
 GIT_CONFIG=.git/config
-export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR GIT_CONFIG GIT_TEST_PATH
 
 GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
 export GITPERLLIB
@@ -308,7 +318,7 @@ test -d ../templates/blt || {
 	error "You haven't built things yet, have you?"
 }
 
-if ! test -x ../test-chmtime; then
+if ! test -x $GIT_TEST_PATH/test-chmtime; then
 	echo >&2 'You need to build test-chmtime:'
 	echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
 	exit 1
-- 
1.5.3.6.2040.gcdff-dirty

^ permalink raw reply related

* Put part of working tree on another file-system.
From: Sergei Organov @ 2007-12-05 13:44 UTC (permalink / raw)
  To: git

Hello,

I've a desire to put a sub-tree of my working tree into another
file-system. With CVS I've used symlink to achieve this. It works fine
with CVS as it doesn't care about directories and symlinks at all. I had
little hope it will work with GIT, but I've performed a test anyway. To
my surprise it almost worked, so I have a hope that maybe it's not that
difficult to support this. What do you think? Or maybe there is a
different way to achieve the goal with GIT?

The test has been performed in a clone of the git tree (my comments are
prefixed by "osv>"):

$ git status
# On branch master
nothing to commit (working directory clean)
$ mv gitweb ../ && ln -s ../gitweb .
$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       gitweb
nothing added to commit but untracked files present (use "git add" to track)

osv> here GIT is slightly confused by the change of a directory to a
osv> symlink to a directory.

$ echo hehe >> gitweb/INSTALL
$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   gitweb/INSTALL
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       gitweb
no changes added to commit (use "git add" and/or "git commit -a")

osv> here confusion is more obvious as GIT reports modified file in an
osv> untracked directory.

$ git commit -a

Created commit 7470207: The commit
 1 files changed, 1 insertions(+), 0 deletions(-)
$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       gitweb
nothing added to commit but untracked files present (use "git add" to track)

osv> surprisingly nothing very bad happened, -- GIT has commited the
osv> modified file just fine, and left the symlink unchanged.
 
$ git reset --hard HEAD^
HEAD is now at 7a4a2e1... Set OLD_ICONV on Cygwin.
[osv@fulcrum git]$ git status
# On branch master
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#
#       deleted:    gitweb/README
#       deleted:    gitweb/git-favicon.png
#       deleted:    gitweb/git-logo.png
#       deleted:    gitweb/gitweb.css
#       deleted:    gitweb/gitweb.perl
#       deleted:    gitweb/test/Märchen
#       deleted:    gitweb/test/file with spaces
#       deleted:    gitweb/test/file+plus+sign
#
no changes added to commit (use "git add" and/or "git commit -a")

osv> Ooops, -- now things begin to be more seriously broken. The result
osv> is that GIT removed the symlink, created gitweb directory, and put
osv> only INSTALL file into it. The directory the symlink was pointing
osv> to has the rest of files but INSTALL.

$ git reset --hard HEAD
HEAD is now at 7a4a2e1... Set OLD_ICONV on Cygwin.
$ git status
# On branch master
nothing to commit (working directory clean)

osv> This is now as expected, -- GIT just re-populated the gitweb
osv> directory as there is no symlink anymore.

-- 
Sergei.

^ permalink raw reply

* [PATCH] Do check_repository_format() early
From: Nguyễn Thái Ngọc Duy @ 2007-12-05 13:33 UTC (permalink / raw)
  To: git, Junio C Hamano, Johannes Schindelin
In-Reply-To: <20071128165837.GA5903@laptop>

This pushes check_repository_format() (actually _gently() version)
to setup_git_directory_gently() in order to prevent from
using unsupported repositories.

New setup_git_directory_gently()'s behaviour is stop searching
for a valid gitdir and return as if there is no gitdir if a
unsupported repository is found. Warning will be thrown in these
cases.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Another round. Test added. Behaviour changed to make it tolerate
 unsupported repos as much as possible.

 setup.c                 |   37 ++++++++++++++++++++++++++++++-------
 t/t1302-repo-version.sh |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+), 7 deletions(-)
 create mode 100755 t/t1302-repo-version.sh

diff --git a/setup.c b/setup.c
index faf4137..434a7a6 100644
--- a/setup.c
+++ b/setup.c
@@ -222,6 +222,22 @@ void setup_work_tree(void)
 	initialized = 1;
 }
 
+static int check_repository_format_gently(int *nongit_ok)
+{
+	git_config(check_repository_format_version);
+	if (GIT_REPO_VERSION < repository_format_version) {
+		if (!nongit_ok)
+			die ("Expected git repo version <= %d, found %d",
+			     GIT_REPO_VERSION, repository_format_version);
+		warning("Expected git repo version <= %d, found %d",
+			GIT_REPO_VERSION, repository_format_version);
+		warning("Please upgrade Git");
+		*nongit_ok = -1;
+		return -1;
+	}
+	return 0;
+}
+
 /*
  * We cannot decide in this function whether we are in the work tree or
  * not, since the config can only be read _after_ this function was called.
@@ -246,8 +262,15 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			static char buffer[1024 + 1];
 			const char *retval;
 
-			if (!work_tree_env)
-				return set_work_tree(gitdirenv);
+			if (!work_tree_env) {
+				retval = set_work_tree(gitdirenv);
+				/* config may override worktree */
+				if (check_repository_format_gently(nongit_ok))
+					return NULL;
+				return retval;
+			}
+			if (check_repository_format_gently(nongit_ok))
+				return NULL;
 			retval = get_relative_cwd(buffer, sizeof(buffer) - 1,
 					get_git_work_tree());
 			if (!retval || !*retval)
@@ -287,6 +310,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 			if (!work_tree_env)
 				inside_work_tree = 0;
 			setenv(GIT_DIR_ENVIRONMENT, ".", 1);
+			if (check_repository_format_gently(nongit_ok))
+				return NULL;
 			return NULL;
 		}
 		chdir("..");
@@ -307,6 +332,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	if (!work_tree_env)
 		inside_work_tree = 1;
 	git_work_tree_cfg = xstrndup(cwd, offset);
+	if (check_repository_format_gently(nongit_ok))
+		return NULL;
 	if (offset == len)
 		return NULL;
 
@@ -357,11 +384,7 @@ int check_repository_format_version(const char *var, const char *value)
 
 int check_repository_format(void)
 {
-	git_config(check_repository_format_version);
-	if (GIT_REPO_VERSION < repository_format_version)
-		die ("Expected git repo version <= %d, found %d",
-		     GIT_REPO_VERSION, repository_format_version);
-	return 0;
+	return check_repository_format_gently(NULL);
 }
 
 const char *setup_git_directory(void)
diff --git a/t/t1302-repo-version.sh b/t/t1302-repo-version.sh
new file mode 100755
index 0000000..37fc1c8
--- /dev/null
+++ b/t/t1302-repo-version.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Nguyễn Thái Ngọc Duy
+#
+
+test_description='Test repository version check'
+
+. ./test-lib.sh
+
+cat >test.patch <<EOF
+diff --git a/test.txt b/test.txt
+new file mode 100644
+--- /dev/null
++++ b/test.txt
+@@ -0,0 +1 @@
++123
+EOF
+
+test_create_repo "test"
+test_create_repo "test2"
+
+GIT_CONFIG=test2/.git/config git config core.repositoryformatversion 99 || exit 1
+
+test_expect_success 'gitdir selection on normal repos' '
+	(test "$(git config core.repositoryformatversion)" = 0 &&
+	cd test &&
+	test "$(git config core.repositoryformatversion)" = 0)'
+
+# Make sure it would stop at test2, not trash
+test_expect_success 'gitdir selection on unsupported repo' '
+	(cd test2 &&
+	test "$(git config core.repositoryformatversion)" = 99)'
+
+test_expect_success 'gitdir not required mode' '
+	(git apply --stat test.patch &&
+	cd test && git apply --stat ../test.patch &&
+	cd ../test2 && git apply --stat ../test.patch)'
+
+test_expect_success 'gitdir required mode on normal repos' '
+	(git apply --check --index test.patch &&
+	cd test && git apply --check --index ../test.patch)'
+
+test_expect_failure 'gitdir required mode on unsupported repo' '
+	(cd test2 && git apply --check --index ../test.patch)'
+
+test_done
-- 
1.5.3.6.2040.gcdff-dirty

^ permalink raw reply related

* Re: [PATCH] Color support for "git-add -i"
From: Johannes Sixt @ 2007-12-05 12:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Dan Zwell, Jeff King, Wincent Colaiuta, git
In-Reply-To: <7vbq95tnk7.fsf@gitster.siamese.dyndns.org>

Junio C Hamano schrieb:
> +color.interactive::
> +	When true (or `always`), always use colors in `git add
> +	--interactive`.  When false (or `never`), never.  When set to
> +	`auto`, use colors only when the output is to the
> +	terminal. Defaults to false.

Any particular reason why color.interactive = true should be different from
color.diff = true? See 57f2b842 ("color.diff = true" is not "always" anymore)

-- Hannes

^ permalink raw reply

* How to fix this error
From: Anton Korobeynikov @ 2007-12-05 12:04 UTC (permalink / raw)
  To: git

Hello, Everyone

Today I discovered, that one of my git-svn-pulled trees cannot sync
anymore:

$ git-svn rebase -A ../authors 
Index mismatch: cc94b590c0a458a610fca10fa01e7461c627b63b !=
09ac82e1a756c11865eca3e23c5704f73dc45244
rereading dc25ba706a6edaa0cc51dd376952b694559137c0
        D       test/Sema/undecl-objc-h.m
        M       Basic/FileManager.cpp
        M       Basic/SourceManager.cpp
        M       include/clang/Basic/FileManager.h
        M       include/clang/Basic/SourceManager.h
        M       include/clang/AST/Expr.h
        M       Sema/SemaChecking.cpp
        M       Sema/SemaType.cpp
        M       Sema/Sema.h
        M       Sema/SemaDecl.cpp
        M       Sema/SemaStmt.cpp
        M       Driver/Targets.cpp
        M       Driver/RewriteTest.cpp
Last fetched revision of refs/remotes/git-svn was r44583, but we are
about to fetch: r44571!

Maybe the actual reason were some fs transactions being rollbacked after
power loss, but I'm not sure. Any idea how this can be fixed without
repulling everything from scratch?

Thanks in advance.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.

^ permalink raw reply

* Re: [PATCH] Documentation: add a new man page for "git-help" and -i|--info option.
From: Väinö Järvelä @ 2007-12-05 11:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Christian Couder, git
In-Reply-To: <7vabopzfek.fsf@gitster.siamese.dyndns.org>

On Dec 5, 2007, at 10:58, Junio C Hamano wrote:

> Perhaps your mail and my push crossed.  The same fix is there at the  
> tip
> of 'master' branch since last night.

Ah, sorry, I didn't check the master, and didn't mention that the fix  
was for next.

--
Väinö

^ permalink raw reply

* [PATCH] Soft aliases: add "less" and minimal documentation
From: Johannes Schindelin @ 2007-12-05 11:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vzlwps8zf.fsf@gitster.siamese.dyndns.org>


Now you can use "git less HEAD" to view the raw HEAD commit object.  It
is really a soft alias (i.e. it can be overridden by any user-specified
alias) to "-p cat-file -p".

This commit refactors the code a bit, to make adding new soft aliases
much easier.

It also adds a few lines in git.txt, so that users actually have a chance
to find out about soft aliases.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	On Wed, 5 Dec 2007, Junio C Hamano wrote:

	> * jk/builtin-alias (Fri Nov 30 11:22:58 2007 -0500) 1 commit
	>  + Support builtin aliases
	> 
	> Cute hack.  I'd like to have "git less" here.

	How about this?

	BTW now it should be easy to add soft aliases for "update", "up",
	"checkin" and "ci".

 Documentation/git.txt |    9 +++++++++
 git.c                 |   13 +++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index c4e4d24..d29dfdc 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -248,6 +248,15 @@ users typically do not use them directly.
 include::cmds-purehelpers.txt[]
 
 
+Soft aliases
+~~~~~~~~~~~~
+
+There are a few hard-coded aliases which can be overridden by explicit
+aliases (see gitlink:git-config[1]).  These include "view" for viewing
+the repository graphically, and "less" to show an object from the
+database using the pager.
+
+
 Configuration Mechanism
 -----------------------
 
diff --git a/git.c b/git.c
index 92cc49b..3c82f80 100644
--- a/git.c
+++ b/git.c
@@ -148,10 +148,19 @@ static int split_cmdline(char *cmdline, const char ***argv)
 	return count;
 }
 
+static struct {
+	const char *alias, *command;
+} builtin_aliases[] = {
+	{ "view", "!gitk" },
+	{ "less", "-p cat-file -p" },
+};
+
 static char *builtin_alias(const char *cmd)
 {
-	if (!strcmp(cmd, "view"))
-		return xstrdup("!gitk");
+	int i;
+	for (i = 0; i < ARRAY_SIZE(builtin_aliases); i++)
+		if (!strcmp(cmd, builtin_aliases[i].alias))
+			return xstrdup(builtin_aliases[i].command);
 	return NULL;
 }
 
-- 
1.5.3.7.2139.g2a5a3

^ permalink raw reply related

* [PATCH] Documentation: add --patch option to synopsis of git-add
From: Matthias Kestenholz @ 2007-12-05 11:28 UTC (permalink / raw)
  To: gitster; +Cc: git, Matthias Kestenholz

Signed-off-by: Matthias Kestenholz <matthias@spinlock.ch>
---
 Documentation/git-add.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index e74f83b..bf94cd4 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -8,7 +8,7 @@ git-add - Add file contents to the index
 SYNOPSIS
 --------
 [verse]
-'git-add' [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh]
+'git-add' [-n] [-v] [-f] [--interactive | -i] [--patch | -p] [-u] [--refresh]
           [--] <filepattern>...
 
 DESCRIPTION
-- 
1.5.3.7.2094.gff6c-dirty

^ permalink raw reply related

* Re: [PATCH] git-cvsserver runs hooks/post-update
From: Junio C Hamano @ 2007-12-05 11:18 UTC (permalink / raw)
  To: Michael Witten; +Cc: git
In-Reply-To: <7245A47D-143F-4DC7-8414-D8C99C0ED9C3@mit.edu>

Michael Witten <mfwitten@MIT.EDU> writes:

> 	### Emulate git-receive-pack by running hooks/post-receive
> 	my $hook = $ENV{GIT_DIR}.'hooks/post-receive';
> 	if( -x $hook ) {
> 		open(my $pipe, "| $hook") || die "can't fork $!";
>
> 		local $SIG{PIPE} = sub { die 'pipe broke' };
>
> 		print $pipe "$parenthash $commithash refs/heads/$state->{module}\n";
>
> 		close $pipe || die "bad pipe: $! $?";
> 	}
>
>> Unfortunately, it turns out that open() with a pipe essentially
>> invokes system(); the solution is to fork a child process and
>> then to turn the child into the process with which communication
>> is desired via a call to exec().
>>
>> Because the rest of git-cvsserver.perl uses explicit system()
>> calls, I have been wondering if I am being overly cautious.
>
> Am I being overly cautious?

I do not think you are.  open($fh, "| $hook") can be confused with any
IFS in $hook (there is no problem with 'hooks/post-receive', but
$ENV{GIT_DIR} part can have pretty much anything other than NUL), so if
anything, you are not being careful enough.  Other parts of cvsserver
seem to be more careful by doing open($fh, '-|', @cmd), which does not
have this problem.

The execution environment of post-receive is probably wrong; I think
receive-pack runs the hooks with their $CWD = $GIT_DIR.

^ permalink raw reply

* Re: What's cooking in git.git (topics)
From: Jakub Narebski @ 2007-12-05 11:10 UTC (permalink / raw)
  To: git
In-Reply-To: <7vzlwps8zf.fsf@gitster.siamese.dyndns.org>

Junio C Hamano wrote:

> * jk/builtin-alias (Fri Nov 30 11:22:58 2007 -0500) 1 commit
>  + Support builtin aliases
> 
> Cute hack.  I'd like to have "git less" here.

I guess that "git whatchanged" can be implemented also as builtin alias.

BTW. now that "git show" can be used on blobs, is "git less" really
that needed?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* Re: What's cooking in git.git (topics)
From: Jakub Narebski @ 2007-12-05 11:08 UTC (permalink / raw)
  To: git
In-Reply-To: <7vzlwps8zf.fsf@gitster.siamese.dyndns.org>

Junio C Hamano wrote:

> * ns/checkout-push-pop (Wed Dec 5 07:04:06 2007 +0900) 1 commit
>  - git-checkout --push/--pop
> 
> A reasonably cleanly written cute hack, and I do not see this breaking
> the normal codepath, so I do not mind merging this as long as people
> find it useful.

I like it, although I probably would create and use 'pushb' and 'popb'
aliases, with analogy to 'pushd' and 'popd'.

I don't remember if there is a way to list this "branch stack"...

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* Re: [PATCH] git-cvsserver runs hooks/post-update
From: Michael Witten @ 2007-12-05 11:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7v63zdtnjz.fsf@gitster.siamese.dyndns.org>


On 5 Dec 2007, at 5:59:12 AM, Junio C Hamano wrote:

> +	### Then hooks/post-update
> +	$hook = $ENV{GIT_DIR}.'hooks/post-update';
> +	if (-x $hook) {
> +		system($hook, "refs/heads/$state->{module}");
> +	}
> +

Firstly, I apologize for not getting this small patch done myself;
it's very hectic this time of year.

Secondly, I'd like to recall my unanswered question:

> Also, I explicitly decided to pipe input into post-receive
> by hand rather than relying on a system() call that someone
> might exploit maliciously:

	### Emulate git-receive-pack by running hooks/post-receive
	my $hook = $ENV{GIT_DIR}.'hooks/post-receive';
	if( -x $hook ) {
		open(my $pipe, "| $hook") || die "can't fork $!";

		local $SIG{PIPE} = sub { die 'pipe broke' };

		print $pipe "$parenthash $commithash refs/heads/$state->{module}\n";

		close $pipe || die "bad pipe: $! $?";
	}

> Unfortunately, it turns out that open() with a pipe essentially
> invokes system(); the solution is to fork a child process and
> then to turn the child into the process with which communication
> is desired via a call to exec().
>
> Because the rest of git-cvsserver.perl uses explicit system()
> calls, I have been wondering if I am being overly cautious.

Am I being overly cautious?

^ permalink raw reply

* What's cooking in git.git (topics)
From: Junio C Hamano @ 2007-12-05 10:59 UTC (permalink / raw)
  To: git
In-Reply-To: <7vy7ca6ea9.fsf@gitster.siamese.dyndns.org>

Here are the topics that have been cooking.  Commits prefixed
with '-' are only in 'pu' while commits prefixed with '+' are
in 'next'.  The topics list the commits in reverse chronological
order.

----------------------------------------------------------------
[Graduated to 'master']

* sp/refspec-match (Sun Nov 11 15:01:48 2007 +0100) 4 commits
* kh/commit (Mon Dec 3 00:03:10 2007 -0800) 33 commits
* wc/add-i (Mon Dec 3 09:09:43 2007 +0100) 34 commits

----------------------------------------------------------------
[New Topics]

* jc/addi-color (Wed Dec 5 00:50:23 2007 -0800) 1 commit
 - Color support for "git-add -i"

This is Dan Zwell's colorized interactive add.  I'll wait for an ack
from Dan and will merge this to 'next', will merge by v1.5.4-rc0.

* ns/checkout-push-pop (Wed Dec 5 07:04:06 2007 +0900) 1 commit
 - git-checkout --push/--pop

A reasonably cleanly written cute hack, and I do not see this breaking
the normal codepath, so I do not mind merging this as long as people
find it useful.

* jc/clean-fix (Tue Dec 4 23:55:41 2007 -0800) 1 commit
 - git-clean: Honor pathspec.

This does fix limited test cases I tried, but I didn't check the
directory related options at all.  Sanity checking appreciated.  We need
a regression fix before v1.5.4

* jc/git-log-doc (Thu Nov 1 15:57:40 2007 +0100) 1 commit
 - Include diff options in the git-log manpage

Rewrote Miklos's patch rather extensively.  Need to be in v1.5.4.

* jc/am-fix (Tue Dec 4 23:01:30 2007 -0800) 1 commit
 - git-am -i: report rewritten title

Microfix for a UI glitch noticed by Jeff Garzik.
Will merge before v1.5.4-rc0.

* pr/mergetool (Wed Dec 5 09:19:13 2007 +0200) 1 commit
 - Open external merge tool with original file extensions for all
   three files

Waiting for Ted's Ack but I think this is safe.  Will merge before v1.5.4-rc0.

----------------------------------------------------------------
[Will cook further in 'next' and then merge to 'master' soon]

* jc/docmake-perl (Fri Nov 30 18:36:34 2007 -0800) 1 commit
 + Run the specified perl in Documentation/

Still waiting for Ack from Merlyn, but will merge before v1.5.4-rc0 anyway.

* kh/fetch-optparse (Tue Dec 4 02:25:47 2007 -0500) 1 commit
 + Rewrite builtin-fetch option parsing to use parse_options().

I need to re-read the patch just to make sure, but will merge before
v1.5.4-rc0.

----------------------------------------------------------------
[Actively cooking]

* cc/help (Sun Dec 2 06:08:00 2007 +0100) 4 commits
 - Use {web,instaweb,help}.browser config options.
 - git-help: add -w|--web option to display html man page in a
   browser.
 + Documentation: describe -i/--info option to "git-help"
 + git-help: add -i|--info option to display info page.

I haven't really read the two commits near the tip.  Comments and
nitpics are appreciated.  Nice to have in v1.5.4.

* mw/cvsserver (Wed Dec 5 01:15:01 2007 -0800) 2 commits
 - git-cvsserver runs hooks/post-update
 - git-cvsserver runs hooks/post-receive

I added the missing support for hooks/post-update; will wait for an Ack
from Michael and merge to 'next'.  Nice to have in v1.5.4.

* jc/spht (Sat Nov 24 11:57:41 2007 -0800) 6 commits
 + core.whitespace: documentation updates.
 + builtin-apply: teach whitespace_rules
 + builtin-apply: rename "whitespace" variables and fix styles
 + core.whitespace: add test for diff whitespace error highlighting
 + git-diff: complain about >=8 consecutive spaces in initial indent
 + War on whitespace: first, a bit of retreat.

Now apply also knows about the customizable definition of what
whitespace breakages are, and I was reasonably happy. But Bruce kicked
it back from "scheduled to merge" to "still cooking" status, reminding
that we would want to have this not a tree-wide configuration but
per-path attribute.  And I agree with him.

Bruce volunteered to tackle the gitattributes side.  Nice to have in
v1.5.4.

* jc/api-doc (Sat Nov 24 23:48:04 2007 -0800) 1 commit
 - Start preparing the API documents.

The primary reason of this series is because I think we made the system
a lot less approachable by losing hackability.  Although we still have
sample scripts in contrib/example for use of plumbing in scripts, they
will not help aspiring git-hacker-wannabees when our primary attention
has already shifted to moving things to C.

This currently consists of mostly stubs, although I wrote about a few
topics as examples.  Nice to have in v1.5.4.

* nd/maint-work-tree-fix (Thu Nov 29 19:21:39 2007 +0700) 2 commits
 + Do check_repository_format() early
 + Add missing inside_work_tree setting in setup_git_directory_gently

The tip one needs test script.

* jk/builtin-alias (Fri Nov 30 11:22:58 2007 -0500) 1 commit
 + Support builtin aliases

Cute hack.  I'd like to have "git less" here.

----------------------------------------------------------------
[Stalled]

* nd/dashless (Wed Nov 28 23:21:57 2007 +0700) 1 commit
 - Move all dashed-form commands to libexecdir

I think this is a sane thing to do in the longer term.  Will be in
'next' after v1.5.4.  I think "leave porcelain on PATH" might be also a
good thing as a transition measure.

Incidentally, if we do not install dashed form of built-ins anywhere
(which is not this series is about --- this is just moving them out of
user's PATH), "git help -a" will stop showing them.  I am not enthused
about removing the hardlinks to built-ins to begin with, but people who
want such a change need to first modify help.c:list_commands() to pick
up builtins without having git-foo hardlinks in gitexecdir.  This may
need to happen anyway as mingw fallouts, though ;-).

* js/reflog-delete (Wed Oct 17 02:50:45 2007 +0100) 1 commit
 + Teach "git reflog" a subcommand to delete single entries

* jc/dashless (Sat Dec 1 22:09:22 2007 -0800) 2 commits
 - Prepare execv_git_cmd() for removal of builtins from the
   filesystem
 - git-shell: accept "git foo" form

We do not plan to remove git-foo form completely from the filesystem at
this point, so these are not strictly necessary.

* jc/pathspec (Thu Sep 13 13:38:19 2007 -0700) 3 commits
 - pathspec_can_match(): move it from builtin-ls-tree.c to tree.c
 - ls-tree.c: refactor show_recursive() and rename it.
 - tree-diff.c: split out a function to match a single pattern.

* jc/nu (Sun Oct 14 22:07:34 2007 -0700) 3 commits
 - merge-nu: a new merge backend without using unpack_trees()
 - read_tree: take an explicit index structure
 - gcc 4.2.1 -Werror -Wall -ansi -pedantic -std=c99: minimum fix

* jc/cherry-pick (Tue Nov 13 12:38:51 2007 -0800) 1 commit
 - revert/cherry-pick: start refactoring call to merge_recursive

* jc/diff-pathspec (Sun Nov 25 10:03:48 2007 -0800) 1 commit
 - Making ce_path_match() more useful by accepting globs

This was to allow "git diff-files -- '*.h'" (currently diff family
knows only the leading directory match and not fileglobs), but was shot
down by Alex.  I tend to agree with him.

* dz/color-addi (Sat Nov 10 18:03:44 2007 -0600) 3 commits
 . Added diff hunk coloring to git-add--interactive
 . Let git-add--interactive read colors from .gitconfig
 . Added basic color support to git add --interactive

I'd drop this series (still parked in 'offcuts' that is 'even outside
than pu') once I hear back from Dan.

^ permalink raw reply

* [PATCH] git-cvsserver runs hooks/post-update
From: Junio C Hamano @ 2007-12-05 10:59 UTC (permalink / raw)
  To: Michael Witten; +Cc: git

Although we have introduced post-receive, we have not deprecated post-update
hook.  This adds support for it to emulate receive-pack better.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * I'd like to have the updated cvsserver by 1.5.4-rc0 so I updated the
   series myself.  Ack, improvements, fixes?

 git-cvsserver.perl |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 11f5127..ecded3b 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -1357,6 +1357,12 @@ sub req_ci
 		close $pipe || die "bad pipe: $! $?";
 	}
 
+	### Then hooks/post-update
+	$hook = $ENV{GIT_DIR}.'hooks/post-update';
+	if (-x $hook) {
+		system($hook, "refs/heads/$state->{module}");
+	}
+
     $updater->update();
 
     # foreach file specified on the command line ...
-- 
1.5.3.7-2134-g53f9

^ permalink raw reply related

* [PATCH] Color support for "git-add -i"
From: Junio C Hamano @ 2007-12-05 10:59 UTC (permalink / raw)
  To: Dan Zwell; +Cc: Jeff King, Wincent Colaiuta, git

This is mostly lifted from earlier series by Dan Zwell, but updated to
use "git config --get-color" to make it simpler and more consistent with
commands written in C.

A new configuration color.interactive variable is like color.diff and
color.status, and controls if "git-add -i" uses color.

A set of configuration variables, color.interactive.<slot>, are used to
define what color is used for the prompt, header, and help text.

For perl scripts, Git.pm provides $repo->get_color() method, which takes
the slot name and the default color, and returns the terminal escape
sequence to color the output text.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * I'd like to have the colored "add -i" by 1.5.4-rc0 so I updated the
   series myself.  Ack, improvements, fixes?

 Documentation/config.txt  |   13 +++++
 git-add--interactive.perl |  121 +++++++++++++++++++++++++++++++++++++-------
 perl/Git.pm               |   20 +++++++
 3 files changed, 134 insertions(+), 20 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 72a33e9..c94f252 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -391,6 +391,19 @@ color.diff.<slot>::
 	whitespace).  The values of these variables may be specified as
 	in color.branch.<slot>.
 
+color.interactive::
+	When true (or `always`), always use colors in `git add
+	--interactive`.  When false (or `never`), never.  When set to
+	`auto`, use colors only when the output is to the
+	terminal. Defaults to false.
+
+color.interactive.<slot>::
+	Use customized color for `git add --interactive`
+	output. `<slot>` may be `prompt`, `header`, or `help`, for
+	three distinct types of normal output from interactive
+	programs.  The values of these variables may be specified as
+	in color.branch.<slot>.
+
 color.pager::
 	A boolean to enable/disable colored output when the pager is in
 	use (default is true).
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 335c2c6..3bcccfb 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1,6 +1,57 @@
 #!/usr/bin/perl -w
 
 use strict;
+use Git;
+
+# Prompt colors:
+my ($use_color, $prompt_color, $header_color, $help_color, $normal_color);
+# Diff colors:
+my ($diff_use_color, $new_color, $old_color, $fraginfo_color,
+    $metainfo_color, $whitespace_color);
+my $color_config = qx(git config --get color.interactive);
+if ($color_config=~/true|always/ || -t STDOUT && $color_config=~/auto/) {
+	if (!$@) {
+		$use_color = 1;
+		# Set interactive colors:
+
+		# Grab the 3 main colors in git color string format, with sane
+		# (visible) defaults:
+		my $repo = Git->repository();
+		$prompt_color = $repo->get_color("color.interactive.prompt", "bold blue");
+		$header_color = $repo->get_color("color.interactive.header", "bold");
+		$help_color = $repo->get_color("color.interactive.help", "red bold");
+		$normal_color = $repo->get_color("", "reset");
+
+		# Do we also set diff colors?
+		my $diff_colors = Git::config($repo, "color.diff");
+		if ($diff_colors =~ /true/ ||
+		    (-t STDOUT && $diff_colors =~ /auto/)) {
+			$diff_use_color = 1;
+			$new_color = $repo->get_color("color.diff.new", "green");
+			$old_color = $repo->get_color("color.diff.old", "red");
+			$fraginfo_color = $repo->get_color("color.diff.frag", "cyan");
+			$metainfo_color = $repo->get_color("color.diff.meta", "bold");
+			$whitespace_color = $repo->get_color("color.diff.whitespace", "normal red");
+		}
+	}
+}
+
+sub colored {
+	my $color = shift;
+	my $string = join("", @_);
+
+	if ($use_color) {
+		# Put a color code at the beginning of each line, a reset at the end
+		# color after newlines that are not at the end of the string
+		$string =~ s/(\n+)(.)/$1$color$2/g;
+		# reset before newlines
+		$string =~ s/(\n+)/$normal_color$1/g;
+		# codes at beginning and end (if necessary):
+		$string =~ s/^/$color/;
+		$string =~ s/$/$normal_color/ unless $string =~ /\n$/;
+	}
+	return $string;
+}
 
 # command line options
 my $patch_mode;
@@ -246,10 +297,20 @@ sub is_valid_prefix {
 sub highlight_prefix {
 	my $prefix = shift;
 	my $remainder = shift;
-	return $remainder unless defined $prefix;
-	return is_valid_prefix($prefix) ?
-	    "[$prefix]$remainder" :
-	    "$prefix$remainder";
+
+	if (!defined $prefix) {
+		return $remainder;
+	}
+
+	if (!is_valid_prefix($prefix)) {
+		return "$prefix$remainder";
+	}
+
+	if (!$use_color) {
+		return "[$prefix]$remainder";
+	}
+
+	return "$prompt_color$prefix$normal_color$remainder";
 }
 
 sub list_and_choose {
@@ -266,7 +327,7 @@ sub list_and_choose {
 			if (!$opts->{LIST_FLAT}) {
 				print "     ";
 			}
-			print "$opts->{HEADER}\n";
+			print colored $header_color, "$opts->{HEADER}\n";
 		}
 		for ($i = 0; $i < @stuff; $i++) {
 			my $chosen = $chosen[$i] ? '*' : ' ';
@@ -304,7 +365,7 @@ sub list_and_choose {
 
 		return if ($opts->{LIST_ONLY});
 
-		print $opts->{PROMPT};
+		print colored $prompt_color, $opts->{PROMPT};
 		if ($opts->{SINGLETON}) {
 			print "> ";
 		}
@@ -371,7 +432,7 @@ sub list_and_choose {
 }
 
 sub singleton_prompt_help_cmd {
-	print <<\EOF ;
+	print colored $help_color, <<\EOF ;
 Prompt help:
 1          - select a numbered item
 foo        - select item based on unique prefix
@@ -380,7 +441,7 @@ EOF
 }
 
 sub prompt_help_cmd {
-	print <<\EOF ;
+	print colored $help_color, <<\EOF ;
 Prompt help:
 1          - select a single item
 3-5        - select a range of items
@@ -477,6 +538,31 @@ sub parse_diff {
 	return @hunk;
 }
 
+sub colored_diff_hunk {
+	my ($text) = @_;
+	# return the text, so that it can be passed to print()
+	my @ret;
+	for (@$text) {
+		if (!$diff_use_color) {
+			push @ret, $_;
+			next;
+		}
+
+		if (/^\+/) {
+			push @ret, colored($new_color, $_);
+		} elsif (/^\-/) {
+			push @ret, colored($old_color, $_);
+		} elsif (/^\@/) {
+			push @ret, colored($fraginfo_color, $_);
+		} elsif (/^ /) {
+			push @ret, colored($normal_color, $_);
+		} else {
+			push @ret, colored($metainfo_color, $_);
+		}
+	}
+	return @ret;
+}
+
 sub hunk_splittable {
 	my ($text) = @_;
 
@@ -671,7 +757,7 @@ sub coalesce_overlapping_hunks {
 }
 
 sub help_patch_cmd {
-	print <<\EOF ;
+	print colored $help_color, <<\EOF ;
 y - stage this hunk
 n - do not stage this hunk
 a - stage this and all the remaining hunks in the file
@@ -710,9 +796,7 @@ sub patch_update_file {
 	my ($ix, $num);
 	my $path = shift;
 	my ($head, @hunk) = parse_diff($path);
-	for (@{$head->{TEXT}}) {
-		print;
-	}
+	print colored_diff_hunk($head->{TEXT});
 	$num = scalar @hunk;
 	$ix = 0;
 
@@ -754,10 +838,8 @@ sub patch_update_file {
 		if (hunk_splittable($hunk[$ix]{TEXT})) {
 			$other .= '/s';
 		}
-		for (@{$hunk[$ix]{TEXT}}) {
-			print;
-		}
-		print "Stage this hunk [y/n/a/d$other/?]? ";
+		print colored_diff_hunk($hunk[$ix]{TEXT});
+		print colored $prompt_color, "Stage this hunk [y/n/a/d$other/?]? ";
 		my $line = <STDIN>;
 		if ($line) {
 			if ($line =~ /^y/i) {
@@ -811,7 +893,7 @@ sub patch_update_file {
 			elsif ($other =~ /s/ && $line =~ /^s/) {
 				my @split = split_hunk($hunk[$ix]{TEXT});
 				if (1 < @split) {
-					print "Split into ",
+					print colored $header_color, "Split into ",
 					scalar(@split), " hunks.\n";
 				}
 				splice(@hunk, $ix, 1,
@@ -894,8 +976,7 @@ sub diff_cmd {
 				     HEADER => $status_head, },
 				   @mods);
 	return if (!@them);
-	system(qw(git diff-index -p --cached HEAD --),
-	       map { $_->{VALUE} } @them);
+	system(qw(git diff -p --cached HEAD --), map { $_->{VALUE} } @them);
 }
 
 sub quit_cmd {
@@ -904,7 +985,7 @@ sub quit_cmd {
 }
 
 sub help_cmd {
-	print <<\EOF ;
+	print colored $help_color, <<\EOF ;
 status        - show paths with changes
 update        - add working tree state to the staged set of changes
 revert        - revert staged set of changes back to the HEAD version
diff --git a/perl/Git.pm b/perl/Git.pm
index 7468460..0f7156e 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -581,6 +581,26 @@ sub config_int {
 	};
 }
 
+=item get_color ( SLOT, COLOR )
+
+Finds color for SLOT from the configuration, while defaulting to COLOR,
+and returns the ANSI color escape sequence:
+
+	print $repo->get_color("color.interactive.prompt", "underline blue white");
+	print "some text";
+	print $repo->get_color("", "normal");
+
+=cut
+
+sub get_color {
+	my ($self, $slot, $default) = @_;
+	my $color = $self->command_oneline('config', '--get-color', $slot, $default);
+	if (!defined $color) {
+		$color = "";
+	}
+	return $color;
+}
+
 =item ident ( TYPE | IDENTSTR )
 
 =item ident_person ( TYPE | IDENTSTR | IDENTARRAY )
-- 
1.5.3.7-2134-g53f9

^ permalink raw reply related

* What's in git.git (stable)
From: Junio C Hamano @ 2007-12-05 10:57 UTC (permalink / raw)
  To: git
In-Reply-To: <7vsl2i6ea4.fsf@gitster.siamese.dyndns.org>

I haven't tagged the tip of 'master' as -rc0 yet, this has more than 80%
of it.  Graduated to 'master' tonight are:

 * Wincent's "git add -p"
 * "git commit in C" by Kristian and others
 * Steffen Prohaska's clean-up of push/fetch refspec handling.

----------------------------------------------------------------

* The 'master' branch has these since the last announcement
  in addition to the above.

Alex Riesen (2):
  Do not generate full commit log message if it is not going to be used
  Simplify crud() in ident.c

H.Merijn Brand (1):
  Do not rely on the exit status of "unset" for unset variables

Jakub Narebski (1):
  contrib: Make remotes2config.sh script more robust

Jeff King (3):
  git-commit: clean up die messages
  quote_path: fix collapsing of relative paths
  t9600: require cvsps 2.1 to perform tests

Johannes Schindelin (8):
  launch_editor(): read the file, even when EDITOR=:
  builtin-commit: fix reflog message generation
  git status: show relative paths when run in a subdirectory
  builtin-commit: fix --signoff
  builtin-commit --s: add a newline if the last line was not a S-o-b
  builtin-commit: resurrect behavior for multiple -m options
  builtin-commit: Add newline when showing which commit was created
  Replace "runstatus" with "status" in the tests

Junio C Hamano (15):
  file_exists(): dangling symlinks do exist
  builtin-commit: do not color status output shown in the message template
  builtin-commit: run commit-msg hook with correct message file
  Export three helper functions from ls-files
  Fix add_files_to_cache() to take pathspec, not user specified list of
    files
  builtin-commit: fix partial-commit support
  git-add -i: allow multiple selection in patch subcommand
  Add a few more tests for git-commit
  builtin-add: fix command line building to call interactive
  add -i: Fix running from a subdirectory
  Fix --signoff in builtin-commit differently.
  git-commit: Allow to amend a merge commit that does not change the tree
  git-commit --allow-empty
  Documentation/git.txt: typofix
  t5510: add a bit more tests for fetch

Kristian Høgsberg (10):
  Add testcase for amending and fixing author in git commit.
  Export launch_editor() and make it accept ':' as a no-op editor.
  Port git commit to C.
  builtin-commit: Refresh cache after adding files.
  Call refresh_cache() when updating the user index for --only commits.
  builtin-commit: Clean up an unused variable and a debug fprintf().
  t7501-commit: Add test for git commit <file> with dirty index.
  builtin-commit: Include the diff in the commit message when verbose.
  Fix off-by-one error when truncating the diff out of the commit message.
  Use a strbuf for copying the command line for the reflog.

Pascal Obry (1):
  Set OLD_ICONV on Cygwin.

Pierre Habouzit (1):
  builtin-commit.c: export GIT_INDEX_FILE for launch_editor as well.

Ralf Wildenhues (1):
  Document all help keys in "git add -i" patch mode.

Shawn Bohrer (1):
  Make git status usage say git status instead of git commit

Shawn O. Pearce (1):
  Remove git-status from list of scripts as it is builtin

Steffen Prohaska (4):
  push: support pushing HEAD to real branch name
  add refname_match()
  push: use same rules as git-rev-parse to resolve refspecs
  refactor fetch's ref matching to use refname_match()

Wincent Colaiuta (6):
  Teach builtin-add to pass multiple paths to git-add--interactive
  Add path-limiting to git-add--interactive
  Add "--patch" option to git-add--interactive
  Highlight keyboard shortcuts in git-add--interactive
  add -i: allow prefix highlighting for "Add untracked" as well.
  git-add -i: add help text for list-and-choose UI

İsmail Dönmez (1):
  gitweb: use Perl built-in utf8 function for UTF-8 decoding.

^ permalink raw reply

* Re: Building git-1.5.3.7 on HP-UX 11.00
From: H.Merijn Brand @ 2007-12-05 10:49 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Andreas Ericsson, git, Sam Vilain
In-Reply-To: <Pine.LNX.4.64.0712041625530.27959@racer.site>

On Tue, 4 Dec 2007 16:28:40 +0000 (GMT), Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:

> Hi,
> 
> On Tue, 4 Dec 2007, H.Merijn Brand wrote:
> 
> > I found it! unset returns false
> 
> Oh, wow!  The question is now: how to deal with it (there are quite a few 
> unsets in the test scripts).

HP-UX 11.23/IPF 64bit gcc-4.2.1

env CC=gcc configure --disable-nls --prefix=/pro/local --without-iconv --with-perl=/pro/bin/perl

ifeq ($(uname_S),HP-UX)
	BASIC_CFLAGS += -mlp64
	NO_UNSETENV = YesPlease
endif

needs the unset patch

fails at the same point.

So at least all of HP-UX is consistent, which means that any of the HP
testdrive systems might be worth looking at for you lot.

http://www.testdrive.hp.com/current.shtml

-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.10.x  on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin.       http://qa.perl.org
http://mirrors.develooper.com/hpux/            http://www.test-smoke.org
                        http://www.goldmark.org/jeff/stupid-disclaimers/

^ permalink raw reply

* Re: * [BUG] "git clean" does not pay attention to its parameters
From: Sam Ravnborg @ 2007-12-05 10:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nanako Shiraishi, Shawn Bohrer, git
In-Reply-To: <7veje1zibm.fsf@gitster.siamese.dyndns.org>

On Tue, Dec 04, 2007 at 11:55:41PM -0800, Junio C Hamano wrote:
> Nanako Shiraishi <nanako3@bluebottle.com> writes:
> 
> > In a repository with LaTeX documents, I tried to see what *.aux files are left behind after formatting, by running "git clean -n" with the latest git (1.5.3.7-1005-gdada0c1):
> >
> >   % git clean -n '*.aux'
> >
> > This however showed more than just '*.aux' files.  With the released version 1.5.3.6, the output is correctly limited to the files that match the pattern.
> 
> Yuck.  People actually use git-clean?

git clean -d -x is my friend.
It it a great way to delete all my temporary files named 'kurt', 'fisk', 'viggo', 'x*' etc.

	Sam

^ permalink raw reply

* Re: [PATCH] xdiff-interface.c (buffer_is_binary): Remove buffer size limitation
From: David Kastrup @ 2007-12-05 10:47 UTC (permalink / raw)
  To: Johannes Schindelin
  Cc: Linus Torvalds, Dmitry V. Levin, Junio C Hamano, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0712040054280.27959@racer.site>

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> On Mon, 3 Dec 2007, Linus Torvalds wrote:
>
>> On Tue, 4 Dec 2007, Dmitry V. Levin wrote:
>> >
>> > Average file size in the linux-2.6.23.9 kernel tree is 10944 bytes,
>> 
>> Don't do "average" sizes. That's an almost totally meaningless number.
>> 
>> "Average" makes sense if you have some kind of gaussian distribution or 
>> similar.
>
> To enhance on that: Gaussian is symmetric, which cannot be the proper 
> distribution for anything that is non-negative.

This reasoning is nonsense, since Gaussians are not necessarily
symmetric about zero, and for example the equally distributed
probability between 0 and 1 is both symmetric and non-negative.  And the
trivial distribution of "always zero" is even _both_ symmetric around
zero and non-negative.

What is true for Gaussians is that their probability is non-zero
everywhere.  But with a meaning of "non-zero" that should let the kind
of people using hashes for unique file identification sleep well.

> I see so many mis-applications of statistics/probability theory in my
> day job that I cannot resist pointing people to the Poisson
> distribution here (in whose context "average" actually makes kind of
> sense).

The main point of Gaussians is that they approximate a distribution
coming from a sum of independent random sources pretty well, even if the
individual sources are not Gaussians themselves.

Poisson distributions come about as the sum of independent exponential
distributions, and yes, when the number of summands grows, the result is
quite well modeled by a Gaussian: the impossible outliers predicted by
the Gaussian approximation take a negligible probability of the total.

If the distribution is more like coming from a product of independent
sources, the results will be better modeled by log-Gaussian
distributions (which happen to be non-negative).

The exponential distribution happens to be the log-distribution of the
(0,1) equal probability distribution, so for lower order Poisson
distributions, approximation with log-Gaussians may seem more
straightforward.

> But back to the problem: if you have a truly binary file, then _every_
> byte (absent further information, of course) has a probability of
> 1/256 of being 0.

Absent any information, there is no reason to assume equal probability
as more likely than other probabilities.

> Which means that if a file is binary,

is _random_ binary.  Few people version random binary files.  It is
rather pointless.

> but is unusual enough to have that property only for half of the first
> 8192 bytes, you get a probability of 1 - 1 / 256^4096 = 1 - 1 / 2 ^
> 32768 that the current test succeeds.

Rather

(1-1/256)^4096 ~= exp(-4096/256) = about 1 in 10 million

Which means that the test would yield a false negative (with regard to
the data being binary) about once in 10000000 times when done on 4096
bytes, even given your rather absurd assumption of random binary data
being versioned.

To make this somewhat more obvious: let's take a look at the probability
of 128 random bytes being all non-zero.  According to your model, that
should be (1-1/256^128)=1-1/32768.  According to mine, (1-1/256)^128 ~=
exp(-0.5) ~= 60%.  Why is this even more than 50%, which would be the
naive assumption?  Because it is likely that we will have duplicate
bytes among our 128 bytes, so the probability for an occurence of 0
becomes less.

> I fail to see how this test can possibly fail for the average case.

You start with a nonsensical mathematical model, and don't even do the
math right that would follow from it.

The "average case" is not random equidistributed uncorrelated data,
anyway.

> So if it fails only for special cases, we are probably (in the common,
> not the mathematical, sense) better off asking those people
> encountering them to add git-attributes for the files.
>
> IMHO that is not asking for too much.

That the problem has actually been encountered in real life does not
exactly do much to support your assumptions and your conclusions, does
it?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply

* Re: [PATCH] Use perl builtin class utf8 for UTF-8 decoding
From: Junio C Hamano @ 2007-12-05 10:33 UTC (permalink / raw)
  To: Ismail Dönmez
  Cc: Martin Koegler, git, Alexandre Julliard, Benjamin Close
In-Reply-To: <200712051226.30162.ismail@pardus.org.tr>

Thanks.  Already queued, but I've been busy and haven't pushed out yet.

^ permalink raw reply

* Re: [PATCH] git-checkout --push/--pop
From: Matthieu Moy @ 2007-12-05 10:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nanako Shiraishi, Salikh Zakirov, git
In-Reply-To: <7vprxl1v9v.fsf@gitster.siamese.dyndns.org>

Junio C Hamano <gitster@pobox.com> writes:

> Matthieu, is this something that forgetful people would find useful?

Not sure. That's obviously an interesting feature, but adding two more
options to checkout (which is already a huge swiss-army knife) might
not be worth the trouble.

And the issue with push/pop approaches is that I usually notice I have
to use pop after not having used push (i.e. I use "cd -" all the time,
but rarely "pushd"/"popd").

-- 
Matthieu

^ permalink raw reply

* [PATCH] Use perl builtin class utf8 for UTF-8 decoding
From: Ismail Dönmez @ 2007-12-05 10:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Martin Koegler, git, Alexandre Julliard, Benjamin Close

Junio it would be very nice to get this in 1.5.4, fixes multiple problems and 
tested with many distros with success.

Use perl builtin class utf8 for UTF-8 decoding, this fixes Encode problems 
with older Encode and avoids problems on UTF-8 locales.

Signed-off-by: İsmail Dönmez <ismail@pardus.org.tr>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Tested-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Tested-by: Wincent Colaiuta <win@wincent.com>

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ff5daa7..db255c1 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -695,10 +695,9 @@ sub validate_refname {
 # in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
 sub to_utf8 {
 	my $str = shift;
-	my $res;
-	eval { $res = decode_utf8($str, Encode::FB_CROAK); };
-	if (defined $res) {
-		return $res;
+        if (utf8::valid($str)) {
+                utf8::decode($str);
+                return $str;
 	} else {
 		return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
 	}


-- 
Never learn by your mistakes, if you do you may never dare to try again.

^ permalink raw reply related

* Re: [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name
From: Jakub Narebski @ 2007-12-05 10:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Guillaume Seguin
In-Reply-To: <7v3auh1v75.fsf@gitster.siamese.dyndns.org>

On Wed, 5 Dec 2007, Junio C Hamano wrote:

> I have these two patches still in my mailbox, unapplied:
> 
> [PATCH] gitweb: disambiguate heads and tags withs the same name
> [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name

Actually second should be [PATCH/RFC] as it penalizes the "not found"
case (extra check 'if really not found').

First patch, which is modified version of Guillaume Seguin patch solves
problem that links in gitweb does lead to correct 'tag' view, while the
second one solves the problem from the other side: instead of ensuring
that links in gitweb are unambiguous it tries to resolve ambiguity.


The problem is caused by the fact that git _always_ prefer heads (head
refs) to tags (tag refs), even when it is clear
  $ git cat-file tags ambiguous-ref
that we want a tag. So alternate solution would be to correct
git-cat-file.
 

> I am wondering if they should be part of 1.5.4.  They look Ok but it is
> not very easy to pick up what the real breakage it is trying to fix from
> Perl gibberish.
> 
> Can we have tests (not just "we do not spit out anything to stderr") for
> gitweb so that each patch can demonstrate the existing breakage, to make
> judging easier?

True, current way of testing gitweb does not allow for test which would
detect breakage noticed by Guillaume.

It would be quite easy I think to add checking if gitweb returns
expected HTTP return code (HTTP status). So what is the portable way
to check if first line of some output matches given regexp (given fixed
string)?

-- 
Jakub Narebski
Poland

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox