* [PATCH] Fail properly when cloning from invalid HTTP URL
From: pasky @ 2008-08-07 0:06 UTC (permalink / raw)
To: gitster; +Cc: git, barkalow, Petr Baudis
From: Petr Baudis <pasky@suse.cz>
Currently, when cloning from invalid HTTP URL, git clone will possibly
return curl error, then a confusing message about remote HEAD and then
return success and leave an empty repository behind, confusing either
the end-user or the automated service calling it (think repo.or.cz).
This patch changes the error() calls in get_refs_via_curl() to die()s,
akin to the other get_refs_*() functions.
Cc: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
transport.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/transport.c b/transport.c
index 6eb65b8..b88b89b 100644
--- a/transport.c
+++ b/transport.c
@@ -464,16 +464,15 @@ static struct ref *get_refs_via_curl(struct transport *transport)
if (results.curl_result != CURLE_OK) {
strbuf_release(&buffer);
if (missing_target(&results)) {
+ die("%s not found: did you run git update-server-info on the server?", refs_url);
return NULL;
} else {
- error("%s", curl_errorstr);
- return NULL;
+ die("%s download error - %s", refs_url, curl_errorstr);
}
}
} else {
strbuf_release(&buffer);
- error("Unable to start request");
- return NULL;
+ die("Unable to start HTTP request");
}
data = buffer.buf;
--
1.5.6.3.392.g292f1
^ permalink raw reply related
* [PATCH] Documentation: clarify that git-commit only works with tracked files
From: Jonathan Nieder @ 2008-08-07 0:15 UTC (permalink / raw)
To: Miklos Vajna; +Cc: git
In-Reply-To: <Pine.GSO.4.62.0808061725450.21683@harper.uchicago.edu>
A user unfamiliar with CVS might not realize that a git-add is
needed before commiting new files. So emphasize that "git commit
<path>..." only commits files already in the index.
Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
---
I keep on forgetting and getting annoyed when "git commit
newfile.c" does not work. From the same confusion I suggested
git commit -A without really thinking about what it meant.
This change should make the behavior easier to understand
and remember. Thanks for the help.
Documentation/git-commit.txt | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt
index 0e25bb8..9b00ccb 100644
--- a/Documentation/git-commit.txt
+++ b/Documentation/git-commit.txt
@@ -27,9 +27,10 @@ The content to be added can be specified in several ways:
2. by using 'git-rm' to remove files from the working tree
and the index, again before using the 'commit' command;
-3. by listing files as arguments to the 'commit' command, in which
- case the commit will ignore changes staged in the index, and instead
- record the current content of the listed files;
+3. by listing some known files as arguments to the 'commit'
+ command, in which case the commit will ignore changes staged
+ in the index and instead record the current content of the
+ listed files;
4. by using the -a switch with the 'commit' command to automatically
"add" changes from all known files (i.e. all files that are already
--
1.6.0.rc1.91.gf0c3
^ permalink raw reply related
* Re: [PATCH] perl/Makefile: handle paths with spaces in the NO_PERL_MAKEMAKER section
From: Brandon Casey @ 2008-08-07 0:23 UTC (permalink / raw)
To: Git Mailing List
In-Reply-To: <1JOFfIWYHgmUErPhpB6xWtV5uZYv3_v3tBnt928x644O-1AquEzzIA@cipher.nrlssc.navy.mil>
Brandon Casey wrote:
> Junio C Hamano wrote:
>> Brandon Casey <casey@nrlssc.navy.mil> writes:
>>
>>> There are problems here with spaces, single quotes, and double quotes.
>>> I'll follow up in another email.
>> I guess we've opened up a large can of worms. Let's have the minimum fix
>> that says "We do support whitespace in these paths but no other funnies"
>> and leave the more intrusive one for post 1.6.0, for now.
>
> I think those two patches I just sent are enough.
>
> You can apply the double-quote escaping patch I sent earlier if you want
> (the one that escapes double quotes in the macros compiled in c programs).
> But we'd have a problem installing the perl scripts using MakeMaker, and
> we'd have a problem _running_ the perl scripts since the single double
> quote causes a syntax error in the perl script. Let's wait till someone
> wants to have " in their path shows up (and let them figure out how to
> fix it).
ok, here's a patch that allows me to compile, install using MakeMaker, and
actually use the perl scripts generated by the make file when the installation
prefix contains odd characters like double quote, single quote, space or
semi-colon. The patch below includes that patch I mentioned about escaping
double quotes for c macros.
-brandon
--->8---
diff --git a/Makefile b/Makefile
index 0d373f7..21241b4 100644
--- a/Makefile
+++ b/Makefile
@@ -1031,15 +1031,15 @@ endif
# Shell quote (do not use $(call) to accommodate ancient setups);
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
-ETC_GITCONFIG_SQ = $(subst ','\'',$(ETC_GITCONFIG))
+ETC_GITCONFIG_SQ = $(subst ",\",$(subst ','\'',$(ETC_GITCONFIG)))
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
bindir_SQ = $(subst ','\'',$(bindir))
-mandir_SQ = $(subst ','\'',$(mandir))
-infodir_SQ = $(subst ','\'',$(infodir))
-gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
-template_dir_SQ = $(subst ','\'',$(template_dir))
-htmldir_SQ = $(subst ','\'',$(htmldir))
+mandir_SQ = $(subst ",\",$(subst ','\'',$(mandir)))
+infodir_SQ = $(subst ",\",$(subst ','\'',$(infodir)))
+gitexecdir_SQ = $(subst ",\",$(subst ','\'',$(gitexecdir)))
+template_dir_SQ = $(subst ",\",$(subst ','\'',$(template_dir)))
+htmldir_SQ = $(subst ",\",$(subst ','\'',$(htmldir)))
prefix_SQ = $(subst ','\'',$(prefix))
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
@@ -1116,11 +1116,11 @@ perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
$(QUIET_GEN)$(RM) $@ $@+ && \
- INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
+ INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir | sed -e 's/"/\\\\\\\"/g'` && \
sed -e '1{' \
-e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-e ' h' \
- -e ' s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || "@@INSTLIBDIR@@"));=' \
+ -e ' s=.*=use lib (split(/:/, $$ENV{GITPERLLIB} || q"@@INSTLIBDIR@@"));=' \
-e ' H' \
-e ' x' \
-e '}' \
@@ -1134,7 +1134,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
$(QUIET_GEN)$(RM) $@ $@+ && \
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
- -e 's|++GIT_BINDIR++|$(bindir)|g' \
+ -e 's|++GIT_BINDIR++|$(subst ",\\",$(bindir_SQ))|g' \
-e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
-e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 90cd99b..155b1ac 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -29,7 +29,7 @@ our $my_uri = $cgi->url(-absolute => 1);
# core git executable to use
# this can just be "git" if your webserver has a sensible PATH
-our $GIT = "++GIT_BINDIR++/git";
+our $GIT = q"++GIT_BINDIR++/git";
# absolute fs-path which will be prepended to the project path
#our $projectroot = "/pub/scm";
diff --git a/perl/Makefile b/perl/Makefile
index dcbd2dd..2597d60 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -39,7 +39,7 @@ $(makfile): ../GIT-CFLAGS Makefile
echo " echo "\''$(subst ','\'',$(instdir_SQ))'\' >> $@
else
$(makfile): Makefile.PL ../GIT-CFLAGS
- $(PERL_PATH) $< PREFIX=\''$(prefix_SQ)'\'
+ $(PERL_PATH) $< PREFIX=\''$(subst ','\'',$(prefix_SQ))'\'
endif
# this is just added comfort for calling make directly in perl dir
diff --git a/perl/Makefile.PL b/perl/Makefile.PL
index 320253e..e1e465c 100644
--- a/perl/Makefile.PL
+++ b/perl/Makefile.PL
@@ -3,7 +3,7 @@ use ExtUtils::MakeMaker;
sub MY::postamble {
return <<'MAKE_FRAG';
instlibdir:
- @echo '$(INSTALLSITELIB)'
+ @echo $(INSTALLSITELIB)
MAKE_FRAG
}
--
1.5.6.2
^ permalink raw reply related
* Re: [PATCH] Fail properly when cloning from invalid HTTP URL
From: Junio C Hamano @ 2008-08-07 0:24 UTC (permalink / raw)
To: pasky; +Cc: git, barkalow
In-Reply-To: <1218067590-31590-1-git-send-email-pasky@suse.cz>
pasky@suse.cz writes:
> diff --git a/transport.c b/transport.c
> index 6eb65b8..b88b89b 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -464,16 +464,15 @@ static struct ref *get_refs_via_curl(struct transport *transport)
> if (results.curl_result != CURLE_OK) {
> strbuf_release(&buffer);
> if (missing_target(&results)) {
> + die("%s not found: did you run git update-server-info on the server?", refs_url);
> return NULL;
Hmm, I do not see a deletion of a line here...
Everybody else in the get_refs_via_ family just die()s, and the caller of
them do not notice nor treat NULL as anything special; I think your patch
is a sensible thing to do.
^ permalink raw reply
* [ANNOUNCE] GIT 1.5.6.5
From: Junio C Hamano @ 2008-08-07 0:28 UTC (permalink / raw)
To: git; +Cc: linux-kernel
The latest maintenance release GIT 1.5.6.5 is available at the
usual places:
http://www.kernel.org/pub/software/scm/git/
git-1.5.6.5.tar.{gz,bz2} (source tarball)
git-htmldocs-1.5.6.5.tar.{gz,bz2} (preformatted docs)
git-manpages-1.5.6.5.tar.{gz,bz2} (preformatted docs)
The RPM binary packages for a few architectures are also provided
as courtesy.
RPMS/$arch/git-*-1.5.6.5-1.fc9.$arch.rpm (RPM)
GIT v1.5.6.5 Release Notes
==========================
Fixes since v1.5.6.4
--------------------
* "git cvsimport" used to spit out "UNKNOWN LINE..." diagnostics to stdout.
* "git commit -F filename" and "git tag -F filename" run from subdirectories
did not read the right file.
* "git init --template=" with blank "template" parameter linked files
under root directories to .git, which was a total nonsense. Instead, it
means "I do not want to use anything from the template directory".
* "git diff-tree" and other diff plumbing ignored diff.renamelimit configuration
variable when the user explicitly asked for rename detection.
* "git name-rev --name-only" did not work when "--stdin" option was in effect.
* "git show-branch" mishandled its 8th branch.
* Addition of "git update-index --ignore-submodules" that happened during
1.5.6 cycle broke "git update-index --ignore-missing".
* "git send-email" did not parse charset from an existing Content-type:
header properly.
Contains other various documentation fixes.
----------------------------------------------------------------
Changes since v1.5.6.4 are as follows:
Anders Melchiorsen (1):
Documentation: fix diff.external example
Björn Steinbrink (1):
index-pack.c: correctly initialize appended objects
Brandon Casey (1):
t/t4202-log.sh: add newline at end of file
Ciaran McCreesh (1):
Make git-add -i accept ranges like 7-
Jeff King (1):
init: handle empty "template" parameter
Jim Meyering (1):
git-cvsimport.perl: Print "UNKNOWN LINE..." on stderr, not stdout.
Johannes Schindelin (1):
sort_in_topological_order(): avoid setting a commit flag
Jonathan Nieder (2):
fix usage string for git grep
git-diff(1): "--c" -> "--cc" typo fix
Junio C Hamano (12):
refresh-index: fix bitmask assignment
tests: propagate $(TAR) down from the toplevel Makefile
Makefile: fix shell quoting
make sure parsed wildcard refspec ends with slash
Documentation: clarify diff --cc
Update my e-mail address
Start 1.5.6.5 RelNotes to describe accumulated fixes
builtin-name-rev.c: split deeply nested part from the main function
RelNotes 1.5.6.5 updates
fix diff-tree --stdin documentation
Files given on the command line are relative to $cwd
GIT 1.5.6.5
Linus Torvalds (1):
diff.renamelimit is a basic diff configuration
Mike Ralphson (1):
Documentation: typos / spelling fixes in older RelNotes
Peter Valdemar Mørch (1):
send-email: find body-encoding correctly
Pierre Habouzit (2):
git-checkout: fix command line parsing.
git-submodule: move ill placed shift.
Pieter de Bie (1):
git-name-rev: allow --name-only in combination with --stdin
René Scharfe (1):
git-name-rev: don't use printf without format
Stephan Beyer (1):
builtin-revert.c: typofix
Steve Haslam (1):
Propagate -u/--upload-pack option of "git clone" to transport.
^ permalink raw reply
* [ANNOUNCE] GIT 1.6.0-rc2
From: Junio C Hamano @ 2008-08-07 0:31 UTC (permalink / raw)
To: git; +Cc: linux-kernel
GIT 1.6.0-rc2 is the second (or should we call it the third?) preview of
the upcoming release. It is available at the usual places:
http://www.kernel.org/pub/software/scm/git/
git-1.6.0-rc2.tar.{gz,bz2} (source tarball)
git-htmldocs-1.6.0-rc2.tar.{gz,bz2} (preformatted docs)
git-manpages-1.6.0-rc2.tar.{gz,bz2} (preformatted docs)
The RPM binary packages for a few architectures are also provided
as courtesy.
testing/RPMS/$arch/*-1.6.0.rc2-1.fc9.$arch.rpm (RPM)
----------------------------------------------------------------
Changes since v1.6.0-rc1 are as follows:
Abhijit Menon-Sen (7):
`git submodule add` now requires a <path>
Make it clear that push can take multiple refspecs
Make the DESCRIPTION match <x>... items in the SYNOPSIS
Git.pm: localise $? in command_close_bidi_pipe()
Fix hash slice syntax error
Fix typo in perl/Git.pm
Fix typos in INSTALL
Alex Riesen (1):
Make use of stat.ctime configurable
Alexander Gavrilov (9):
git-gui: Fix the Remote menu separator.
git-gui: Preserve scroll position on reshow_diff.
Support copy and rename detection in fast-export.
gitk: Kill back-end processes on window close
gitk: Arrange to kill diff-files & diff-index on quit
gitk: On Windows, use a Cygwin-specific flag for kill
gitk: Fixed broken exception handling in diff
gitk: Fixed automatic row selection during load
gitk: Fallback to selecting the head commit upon load
Anders Melchiorsen (4):
Advertise the ability to abort a commit
Documentation: fix diff.external example
Flush output in start_async
Add output flushing before fork()
Avery Pennarun (2):
Teach "git diff -p" Pascal/Delphi funcname pattern
git-svn: Abort with an error if 'fetch' parameter is invalid.
Brandon Casey (3):
t/t4202-log.sh: add newline at end of file
Teach fsck and prune that tmp_obj_ file names may not be 14 bytes long
perl/Makefile: handle paths with spaces in the NO_PERL_MAKEMAKER section
Brian Gernhardt (1):
Documentation: Remove mentions of git-svnimport.
Cesar Eduardo Barros (1):
Documentation/git-rev-parse.txt: update for new git-describe output format
Christian Couder (2):
merge-base: die with an error message if not passed a commit ref
documentation: user-manual: update "using-bisect" section
Christian Stimming (2):
git-gui: Update German translation
gitk: Updated German translation
Ciaran McCreesh (1):
Make git-add -i accept ranges like 7-
David D. Kilzer (1):
Fix race condition in t9119-git-svn-info.sh
Dmitry Potapov (1):
correct access right for git-svn-dcommit test
Eric Wong (2):
git-svn: properly set path for "info" command
t9119: conditionally re-enable test depending on svn(1) version
Giuseppe Bilotta (2):
diff: add ruby funcname pattern
diff: chapter and part in funcname for tex
Jeff King (3):
init: handle empty "template" parameter
Compact commit template message
init: handle empty "template" parameter
Jim Meyering (1):
git-cvsimport.perl: Print "UNKNOWN LINE..." on stderr, not stdout.
Johannes Schindelin (3):
sort_in_topological_order(): avoid setting a commit flag
clone: Add an option to set up a mirror
clone --bare: Add ".git" suffix to the directory name to clone into
Johannes Sixt (1):
git-gui: Adapt discovery of oguilib to execdir 'libexec/git-core'
Jon Jensen (1):
Fix reference to Everyday Git, which is an HTML document and not a man page.
Jonathan Nieder (1):
git-diff(1): "--c" -> "--cc" typo fix
Junio C Hamano (19):
Allow building without any git installed
Allow installing in the traditional way
ls-tree documentation: enhance notes on subdirectory and pathspec behaviour
Documentation: clarify what is shown in "git-ls-files -s" output
t7001: fix "git mv" test
Teach gitlinks to ie_modified() and ce_modified_check_fs()
Fix merge name generation in "merge in C"
Fix test-parse-options "integer" test
Teach --find-copies-harder to "git blame"
make sure parsed wildcard refspec ends with slash
Documentation: clarify diff --cc
Update my e-mail address
Start 1.5.6.5 RelNotes to describe accumulated fixes
builtin-name-rev.c: split deeply nested part from the main function
RelNotes 1.5.6.5 updates
fix diff-tree --stdin documentation
Files given on the command line are relative to $cwd
GIT 1.5.6.5
GIT 1.6.0-rc2
Kevin Ballard (1):
format-patch: Produce better output with --inline or --attach
Lee Marlow (11):
bash completion: remove unused function _git_diff_tree
bash completion: Add more long options for 'git log'
bash completion: Add completion for 'git grep'
bash completion: Add completion for 'git clone'
bash completion: Add completion for 'git clean'
bash completion: Add completion for 'git init'
bash completion: Add completion for 'git revert'
bash completion: More completions for 'git stash'
bash completion: Add completion for 'git archive'
bash completion: Add completion for 'git ls-files'
bash completion: Add completion for 'git mv'
Linus Torvalds (1):
diff.renamelimit is a basic diff configuration
Michele Ballabio (2):
git-gui: update po/it.po
git-gui: add a part about format strings in po/README
Mikael Magnusson (2):
git-gui: Update swedish translation.
gitk: Update swedish translation.
Mike Ralphson (2):
Documentation: typos / spelling fixes in older RelNotes
Documentation: typos / spelling fixes
Nanako Shiraishi (1):
git-gui: update Japanese translation
Olivier Marin (1):
builtin-verify-tag: fix -v option parsing
Pierre Habouzit (2):
Allow "non-option" revision options in parse_option-enabled commands
git-submodule: move ill placed shift.
Pieter de Bie (1):
git-name-rev: allow --name-only in combination with --stdin
René Scharfe (2):
archive: allow --exec and --remote without equal sign
git-name-rev: don't use printf without format
Shawn O. Pearce (2):
git-gui: Fix gitk search in $PATH to work on Windows
git-gui: Update git-gui.pot for 0.11 nearing release
Steffen Prohaska (6):
Refactor, adding prepare_git_cmd(const char **argv)
run-command (Windows): Run dashless "git <cmd>"
git-gui: Correct installation of library to be $prefix/share
git-gui (Windows): Switch to relative discovery of oguilib
git-gui (Windows): Change wrapper to execdir 'libexec/git-core'
Modify mingw_main() workaround to avoid link errors
Stephan Beyer (1):
builtin-revert.c: typofix
Steve Haslam (1):
Propagate -u/--upload-pack option of "git clone" to transport.
Steven Grimm (1):
Optimize sha1_object_info for loose objects, not concurrent repacks
Todd Zullinger (1):
Replace uses of "git-var" with "git var"
^ permalink raw reply
* Re: [PATCH] Documentation: clarify that git-commit only works with tracked files
From: Johannes Schindelin @ 2008-08-07 0:39 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Miklos Vajna, git
In-Reply-To: <Pine.GSO.4.62.0808061906490.24977@harper.uchicago.edu>
Hi,
On Wed, 6 Aug 2008, Jonathan Nieder wrote:
> A user unfamiliar with CVS might not realize that a git-add is
> needed before commiting new files.
Funny. I haven't used CVS for a while now, but I seem to remember that
"cvs commit newfile.c" without a prior "cvs add newfile.c" is not allowed.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] Documentation: clarify that git-commit only works with tracked files
From: Jonathan Nieder @ 2008-08-07 1:14 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Miklos Vajna, git
In-Reply-To: <alpine.DEB.1.00.0808070239120.9611@pacific.mpi-cbg.de.mpi-cbg.de>
Hi,
On Thu, 7 Aug 2008, Johannes Schindelin wrote:
> On Wed, 6 Aug 2008, Jonathan Nieder wrote:
>
> > A user unfamiliar with CVS might not realize that a git-add is
> > needed before commiting new files.
>
> Funny. I haven't used CVS for a while now, but I seem to remember that
> "cvs commit newfile.c" without a prior "cvs add newfile.c" is not allowed.
Yes, this is a closely related statement: a user familiar with CVS should
already know to add. :)
Jonathan
^ permalink raw reply
* NO_MMAP and cygwin
From: Marcus Griep @ 2008-08-07 2:32 UTC (permalink / raw)
To: Git Mailing List
Is there any reason that NO_MMAP should continue to be
set by default for cygwin?
--
Marcus Griep
GPG Key ID: 0x5E968152
——
http://www.boohaunt.net
את.ψο´
^ permalink raw reply
* Re: NO_MMAP and cygwin
From: Junio C Hamano @ 2008-08-07 3:07 UTC (permalink / raw)
To: Marcus Griep; +Cc: Git Mailing List
In-Reply-To: <489A5ED7.7060100@griep.us>
Marcus Griep <marcus@griep.us> writes:
> Is there any reason that NO_MMAP should continue to be
> set by default for cygwin?
Think of it not as the one true way but a mere hint that suggests the safe
default.
^ permalink raw reply
* git svn rebase - could not detach HEAD
From: Tony Stubbs @ 2008-08-07 6:49 UTC (permalink / raw)
To: git
Having trouble rebasing against svn off a clean repo.
I am using windows / cygwin.
Here's the output:
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git status
# On branch master
nothing to commit (working directory clean)
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git svn rebase
First, rewinding head to replay your work on top of it...
could not detach HEAD
rebase refs/remotes/git-svn: command returned error: 1
stubbsa@VFNZV95336 /cygdrive/c/dev
$
I already tried asking on the channel...
Any ideas? I'm kind of stuck as I have commits I need to dcommit.
p.s. git stash also shows:
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git stash
No local changes to save
^ permalink raw reply
* Re: Not going beyond symbolic links
From: Junio C Hamano @ 2008-08-07 6:52 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git, Petr Baudis, Shawn O. Pearce, Johannes Schindelin
In-Reply-To: <alpine.LFD.1.10.0808041719380.3299@nehalem.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
> On Mon, 4 Aug 2008, Junio C Hamano wrote:
>>
>> I started to revisit this issue and patched "git update-index --add"
>> and "git add" so far. Patches follow.
>
> Patches look good to me, but did you check the performance impact?
>
> The rewritten 'has_symlink_leading_path()' should do ok, but it migth
> still be a huge performance downside to check all the paths for things
> like "git add -u".
I couldn't quite measure much meaningful performance impact.
My test repository was the kernel tree at v2.6.27-rc2-20-g685d87f, without
any build products nor editor temporary crufts.
By the way, if anybody wants to reproduce this, be careful with the tests
that run "rm -f .git/index" before adding everything. After doing so, if
you check the result with "git diff --stat HEAD", you will notice many
missing files --- I almost got a heart attack before inspecting this file:
$ cat arch/powerpc/.gitignore
include
Yes, it excludes 261 already tracked files. Is it intended? I dunno.
The file is there since 06f2138 ([POWERPC] Add files build to .gitignore,
2006-11-26). Not that having tracked files in an entirely ignored
directory is a bug, but the .gitignore entry seems to me an Oops waiting
to happen. There are three commits that affect this directory that is
entirely ignored after that entry is added:
b5b9309 (remove unnecessary <linux/hdreg.h> includes, 2008-08-05)
9c4cb82 (powerpc: Remove use of CONFIG_PPC_MERGE, 2008-08-02)
b8b572e (powerpc: Move include files to arch/powerpc/include/asm, 2008-08-01)
Anyhow, back on topic. Here are the numbers.
Test #1: With fully up-to-date .git/index, "git add .", best of 5 runs
* v1.6.0-rc2
0.20user 0.20system 0:00.41elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+3622minor)pagefaults 0swaps
* v1.6.0-rc1-73-g725b060 (with patch)
0.22user 0.19system 0:00.41elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+3635minor)pagefaults 0swaps
Test #2: After "rm -f .git/index", "git add .", best of 5 runs
* v1.6.0-rc2
1.81user 0.55system 0:02.51elapsed 93%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+92855minor)pagefaults 0swaps
* v1.6.0-rc1-73-g725b060 (with patch)
1.76user 0.56system 0:02.58elapsed 89%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+92852minor)pagefaults 0swaps
Test #3: same as #2, after dropping cache with "echo 3 > /proc/sys/vm/drop_caches".
(Yes, I have slow disks).
* v1.6.0-rc2
3.43user 2.29system 2:02.45elapsed 4%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (29611major+63244minor)pagefaults 0swaps
* v1.6.0-rc1-73-g725b060 (with patch)
3.55user 2.33system 1:54.77elapsed 5%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (29616major+63236minor)pagefaults 0swaps
Test #4: same as #1, "strace -c -e lstat"
* v1.6.0-rc2
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000247 0 23993 lstat
* v1.6.0-rc1-73-g725b060 (with patch)
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000261 0 23993 lstat
Test #5: same as #2, "strace -c -e lstat"
* v1.6.0-rc2
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000639 0 23993 lstat
* v1.6.0-rc1-73-g725b060 (with patch)
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000427 0 23993 lstat
^ permalink raw reply
* Re: git filter-branch --subdirectory-filter, still a mistery
From: Jan Wielemaker @ 2008-08-07 7:13 UTC (permalink / raw)
To: git
In-Reply-To: <200808061539.50268.J.Wielemaker@uva.nl>
On Wednesday 06 August 2008 15:39:50 you wrote:
> Hi,
>
> I've been puzzling most of today to do something that must be simple.
> I've got a big repo which contains a project with several nicely related
> subprojects in directories. Only now, we want to share some of these
> subprojects with another project. I.e. they must start to live there own
> life. Of course, I would like to keep the history. So, I did (git
> --version: 1.5.6.GIT):
>
> % git clone /home/git/pl.git
> % cd pl
> % git filter-branch --subdirectory-filter packages/chr HEAD
>
> This indeed creates a nice directory holding only the contents of
> packages/chr. But, starting qgit I see that all commits, also those
> that had absolutely nothing to do with this dir are still there. Also,
> all tags are still there with exactly the same SHA1 as the original.
> I'd expect the tags to be rewritten such that their SHA1 refers to the
> state of this single directory and its contents!? Of course, these
> tags give me access to everything, so the repository doesn't shrink
> much too.
>
> I must be missing something important ... I found similar complaints,
> but few decent answers and the few answer I did find appeared outdated.
> The one at http://use.perl.org/~rjbs/journal/34411 comes closest, although
> the reset --hard is no longer needed and the copying and gc-ing doesn't
> help much anymore.
>
> Should I write a tree-filter that removes all but the directory I want
> to keep? I.e. something like this? Feels like and overkill and I fear
> I'll have a lot of empty commits left.
>
> 'mv packages/chr .. && rm -r * && mv ../chr/* . && rmdir ../chr'
>
> I'll be grateful for a clue!
Weirdness goes on. I tried this:
git filter-branch --tree-filter '/home/jan/nobackup/tmp2/keep
packages/chr'
where `keep' is a shell-script:
----------------------------------------------------------------
tmp=/home/jan/nobackup/tmp2
dir="$1"
if [ -d "$dir" ]; then
b=`basename $dir`
mv "$dir" $tmp/$b
rm -rf *
mv $tmp/$b/* .
mv $tmp/$b/.??* .
rmdir $tmp/$b
else
rm -rf *
fi
----------------------------------------------------------------
This kind of works. I.e. I end up (after 3 hours) with a tree that only
contains files from packages/chr. Using qgit it no longer shows the
other files in the `tree' view. Only, it has *all* commits of the
original project, most of which of course do not change this directory,
but now at least their diff is empty. I'd assume there is a command to
remove these (which?)
Space wise this isn't ok. The original project GIT is 140M, after this
action and a git gc, it is 63M: *much* too big.
Whats more weird: all tags still have the same sha1. I copied using git
clone --no-hardlinks pl chr, deleted all refs/tags from packed-refs and
gave a "git gc --prune", to end up with 1.1 GIGABYTE repository!?
I'm starting to feel a bit stupid that I can't get this done ...
Clues? --- Jan
^ permalink raw reply
* Re: git svn rebase - could not detach HEAD
From: Tony Stubbs @ 2008-08-07 7:19 UTC (permalink / raw)
To: git
In-Reply-To: <f7d8f60b0808062349q92fffb9l33de5550250e4e13@mail.gmail.com>
Some more info...:
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git merge-base HEAD git-svn
5bfad5dee44fd18f7c3a39e7dcb234828c840c24
commit 5bfad5dee44fd18f7c3a39e7dcb234828c840c24
Author: boses <boses@c07779a9-5238-0410-8e60-f4d13a72d009>
Date: Thu Aug 7 01:28:44 2008 +0000
Siebel Java Interface Merged
git-svn-id:
http://10.107.6.150/repos/portal/oasis/branches/oasis-cr@3273
c07779a9-5238-0410-8e60-f4d13a72d009
$ git branch -a
emailTemplateWork
hibernate
integration
* master
git-svn
git-svn@1775
git-svn@2473
laptop/emailTemplateWork
laptop/hibernate
laptop/master
temp/master
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git checkout hibernate
Switched to branch "hibernate"
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git checkout master
Checking out files: 100% (295/295), done.
Switched to branch "master"
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git svn rebase
First, rewinding head to replay your work on top of it...
could not detach HEAD
rebase refs/remotes/git-svn: command returned error: 1
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git rebase
fatal: Needed a single revision
invalid upstream
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git rebase git-svn
First, rewinding head to replay your work on top of it...
could not detach HEAD
2008/8/7 Tony Stubbs <antony.stubbs@gmail.com>:
> Having trouble rebasing against svn off a clean repo.
>
> I am using windows / cygwin.
>
> Here's the output:
>
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git status
> # On branch master
> nothing to commit (working directory clean)
>
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git svn rebase
> First, rewinding head to replay your work on top of it...
> could not detach HEAD
> rebase refs/remotes/git-svn: command returned error: 1
>
>
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $
>
> I already tried asking on the channel...
> Any ideas? I'm kind of stuck as I have commits I need to dcommit.
>
> p.s. git stash also shows:
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git stash
> No local changes to save
>
--
___________________________
http://stubbisms.wordpress.com/
^ permalink raw reply
* Re: git svn rebase - could not detach HEAD
From: Junio C Hamano @ 2008-08-07 7:20 UTC (permalink / raw)
To: Tony Stubbs; +Cc: git
In-Reply-To: <f7d8f60b0808062349q92fffb9l33de5550250e4e13@mail.gmail.com>
"Tony Stubbs" <antony.stubbs@gmail.com> writes:
> $ git svn rebase
> First, rewinding head to replay your work on top of it...
> could not detach HEAD
> rebase refs/remotes/git-svn: command returned error: 1
It is somewhat unfortunate that git-svn does not say anything about what
ref it is trying to rebase onto here. I do not use git-svn nor know much
about the code myself, but here are some ideas.
* Try "rebase --dry-run" and see what you see from this part of the code:
sub cmd_rebase {
...
if ($_dry_run) {
print "Remote Branch: " . $gs->refname . "\n";
print "SVN URL: " . $url . "\n";
return;
}
Most interesting is what $gs->refname is;
* If you are using recent enough git (I think 1.5.2 is Ok), update your
copy of git-rebase like this, so that you would at least see *why* you
cannot detach HEAD. It is possible that git-svn is giving a nonsense
ref to detach to.
diff --git a/git-rebase.sh b/git-rebase.sh
index e2d85ee..7825f88 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -376,9 +376,7 @@ fi
# Detach HEAD and reset the tree
echo "First, rewinding head to replay your work on top of it..."
-git checkout "$onto^0" >/dev/null 2>&1 ||
- die "could not detach HEAD"
-# git reset --hard "$onto^0"
+git checkout -q "$onto^0" || die "could not detach HEAD"
# If the $onto is a proper descendant of the tip of the branch, then
# we just fast forwarded.
^ permalink raw reply related
* Re: git svn rebase - could not detach HEAD
From: Tony Stubbs @ 2008-08-07 7:33 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vd4kljnpn.fsf@gitster.siamese.dyndns.org>
Ok, woah. that's really weird... note the strange behaviour of
git-clean (i had my ide open, then clossed it. but it still acted
strange)
that seems to have got it. so are you going to apply that patch to git proper?
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git --version
git version 1.5.6.4
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git svn rebase --dry-run
Remote Branch: refs/remotes/git-svn
SVN URL: http://10.107.6.150/repos/portal/oasis/branches/oasis-cr
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git rebase git-svn
First, rewinding head to replay your work on top of it...
error: Untracked working tree file
'webnonline-db-access/target/hanson-db-access-1.0.jar' would be
overwritten by merge.
could not detach HEAD
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git clean -df
Removing .temp/
Removing Libraries/release/
Removing SiebelJavaInterface/release/
Removing SiebelJavaInterface/src/generated/
Removing SiebelJavaInterface/tmp/
Removing Utilities/.apt_src/
Removing Utilities/build/
Removing VFSecurityProviders/build/
Removing VFSecurityProviders/vfSecurityProviders.jar
Removing VFSecurityProviders/vfSecurityProviders_r1_00_01.jar
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git rebase git-svn
First, rewinding head to replay your work on top of it...
error: Untracked working tree file
'webnonline-db-access/target/hanson-db-access-1.0.jar' would be
overwritten by merge.
could not detach HEAD
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git clean -df
Removing Utilities/.apt_src/
Removing Utilities/build/
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git clean -df
Removing Utilities/.apt_src/
Removing Utilities/build/
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git clean -df
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git rebase git-svn
First, rewinding head to replay your work on top of it...
error: Untracked working tree file
'webnonline-db-access/target/hanson-db-access-1.0.jar' would be
overwritten by merge.
could not detach HEAD
<manually deleted "untracked file" here>
stubbsa@VFNZV95336 /cygdrive/c/dev
$ git rebase git-svn
First, rewinding head to replay your work on top of it...
Applying removed generated files
Applying Changed maven call method
Applying Switched dependency to project from jar
Applying Added dependency build
Applying Updated notification service build target
2008/8/7 Junio C Hamano <gitster@pobox.com>:
> "Tony Stubbs" <antony.stubbs@gmail.com> writes:
>
>> $ git svn rebase
>> First, rewinding head to replay your work on top of it...
>> could not detach HEAD
>> rebase refs/remotes/git-svn: command returned error: 1
>
> It is somewhat unfortunate that git-svn does not say anything about what
> ref it is trying to rebase onto here. I do not use git-svn nor know much
> about the code myself, but here are some ideas.
>
> * Try "rebase --dry-run" and see what you see from this part of the code:
>
> sub cmd_rebase {
> ...
> if ($_dry_run) {
> print "Remote Branch: " . $gs->refname . "\n";
> print "SVN URL: " . $url . "\n";
> return;
> }
>
> Most interesting is what $gs->refname is;
>
> * If you are using recent enough git (I think 1.5.2 is Ok), update your
> copy of git-rebase like this, so that you would at least see *why* you
> cannot detach HEAD. It is possible that git-svn is giving a nonsense
> ref to detach to.
>
> diff --git a/git-rebase.sh b/git-rebase.sh
> index e2d85ee..7825f88 100755
> --- a/git-rebase.sh
> +++ b/git-rebase.sh
> @@ -376,9 +376,7 @@ fi
>
> # Detach HEAD and reset the tree
> echo "First, rewinding head to replay your work on top of it..."
> -git checkout "$onto^0" >/dev/null 2>&1 ||
> - die "could not detach HEAD"
> -# git reset --hard "$onto^0"
> +git checkout -q "$onto^0" || die "could not detach HEAD"
>
> # If the $onto is a proper descendant of the tip of the branch, then
> # we just fast forwarded.
>
--
___________________________
http://stubbisms.wordpress.com/
^ permalink raw reply
* Re: git svn rebase - could not detach HEAD
From: Björn Steinbrink @ 2008-08-07 7:41 UTC (permalink / raw)
To: Tony Stubbs; +Cc: Junio C Hamano, git
In-Reply-To: <f7d8f60b0808070033g7a322ee4w9147dd51e41850c6@mail.gmail.com>
On 2008.08.07 19:33:36 +1200, Tony Stubbs wrote:
> Ok, woah. that's really weird... note the strange behaviour of
> git-clean (i had my ide open, then clossed it. but it still acted
> strange)
>
> that seems to have got it. so are you going to apply that patch to git proper?
It already is.
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git clean -df
> Removing Utilities/.apt_src/
> Removing Utilities/build/
>
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git clean -df
>
> stubbsa@VFNZV95336 /cygdrive/c/dev
> $ git rebase git-svn
> First, rewinding head to replay your work on top of it...
> error: Untracked working tree file
> 'webnonline-db-access/target/hanson-db-access-1.0.jar' would be
> overwritten by merge.
> could not detach HEAD
>
> <manually deleted "untracked file" here>
Maybe you're ignoring that file? git clean deletes ignored files only if
you use -x/-X.
Björn
^ permalink raw reply
* Re: git filter-branch --subdirectory-filter, still a mistery
From: Thomas Rast @ 2008-08-07 7:50 UTC (permalink / raw)
To: Jan Wielemaker; +Cc: git
In-Reply-To: <200808061539.50268.J.Wielemaker@uva.nl>
[-- Attachment #1: Type: text/plain, Size: 837 bytes --]
Jan Wielemaker wrote:
[...]
> % git filter-branch --subdirectory-filter packages/chr HEAD
>
> This indeed creates a nice directory holding only the contents of
> packages/chr. But, starting qgit I see that all commits, also those
> that had absolutely nothing to do with this dir are still there.
The trick is to rewrite all refs, not just HEAD. I usually proceed as
follows:
cp -a repo repo.old # just to keep a backup
cd repo
git filter-branch --subdirectory-filter somedir -- --all
The --all tells it to rewrite as many refs as possible. Note that the
-- is required. Also note that refs/original/* will still point to
the old commits, so they won't "just vanish". You may want to clone
the repository or delete them manually once you are sure the
filter-branch did the right thing.
- Thomas
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply
* Re: [PATCH] files given on the command line are relative to $cwd
From: Samuel Tardieu @ 2008-08-07 8:45 UTC (permalink / raw)
To: Junio C Hamano
Cc: git list, Luciano Rocha, pascal, Pierre Habouzit,
Kristian Høgsberg
In-Reply-To: <7vr692oufw.fsf@gitster.siamese.dyndns.org>
>>>>> "Junio" == Junio C Hamano <gitster@pobox.com> writes:
Junio> When running "git commit -F file" and "git tag -F file" from a
Junio> subdirectory, we should take it as relative to the directory we
Junio> started from, not relative to the top-level directory.
Don't we have the same problem with "git show"? If you go into
the "gitweb" directory of the GIT source, "git show HEAD:README" will
show you the toplevel "README" instead of the one in the "gitweb"
directory.
Sam
--
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/
^ permalink raw reply
* [PATCH] git grep colorized
From: Thiago Alves @ 2008-08-07 11:53 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 621 bytes --]
Hi guys,
recently I try to put some colors on my git-grep and found a patch
from Nguyễn Thái Ngọc Duy <pclouds@gmail.com> to do it!
The problem with this patch is that it doesn't support the config file
to persist the color option on grep.
I took the liberty to change his patch and add support to config files
and bash completion.
Attached is the resultant patch!
I hope this could be useful to someone.
Thiago dos Santos Alves
Computer Scientist
thiago.salves@gmail.com
-----------------------------------------------------
"Man's mind, once stretched by a new idea, never regains it's original
dimensions."
[-- Attachment #2: git_grep_color.patch --]
[-- Type: application/octet-stream, Size: 10212 bytes --]
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index fa4d133..8554068 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -15,7 +15,7 @@ SYNOPSIS
[-E | --extended-regexp] [-G | --basic-regexp]
[-F | --fixed-strings] [-n]
[-l | --files-with-matches] [-L | --files-without-match]
- [-c | --count] [--all-match]
+ [-c | --count] [--all-match] [--color | --no-color]
[-A <post-context>] [-B <pre-context>] [-C <context>]
[-f <file>] [-e] <pattern>
[--and|--or|--not|(|)|-e <pattern>...] [<tree>...]
@@ -99,6 +99,13 @@ OPTIONS
Instead of showing every matched line, show the number of
lines that match.
+--color::
+ Colorize grep output highlighting matches, file names and line numbers.
+
+--no-color::
+ Turn off grep colors, even when the configuration file gives the
+ default to color output.
+
-[ABC] <context>::
Show `context` trailing (`A` -- after), or leading (`B`
-- before), or both (`C` -- context) lines, and place a
diff --git a/builtin-grep.c b/builtin-grep.c
index 631129d..29e7d5a 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -11,6 +11,7 @@
#include "tree-walk.h"
#include "builtin.h"
#include "grep.h"
+#include "color.h"
#ifndef NO_EXTERNAL_GREP
#ifdef __unix__
@@ -20,6 +21,7 @@
#endif
#endif
+static int grep_use_color = -1;
/*
* git grep pathspecs are somewhat different from diff-tree pathspecs;
* pathname wildcards are allowed.
@@ -386,7 +388,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
* we grep through the checked-out files. It tends to
* be a lot more optimized
*/
- if (!cached) {
+ if (!cached && !opt->color) {
hit = external_grep(opt, paths, cached);
if (hit >= 0)
return hit;
@@ -507,6 +509,22 @@ static const char emsg_missing_context_len[] =
static const char emsg_missing_argument[] =
"option requires an argument -%s";
+static int git_grep_config(const char *var, const char *value, void *cb)
+{
+ if (!strcmp(var, "color.grep")) {
+ grep_use_color = git_config_colorbool(var, value, -1);
+ return 0;
+ }
+ if (!prefixcmp(var, "color.grep.")) {
+ int slot = parse_grep_color_slot(var, 11);
+ if (!value)
+ return config_error_nonbool(var);
+ color_parse(value, var, grep_get_color(slot));
+ return 0;
+ }
+ return git_color_default_config(var, value, cb);
+}
+
int cmd_grep(int argc, const char **argv, const char *prefix)
{
int hit = 0;
@@ -524,6 +542,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
opt.pattern_tail = &opt.pattern_list;
opt.regflags = REG_NEWLINE;
+ git_config(git_grep_config, NULL);
+ if (grep_use_color == -1)
+ grep_use_color = git_use_color_default;
+ opt.color = grep_use_color;
+
/*
* If there is no -- then the paths must exist in the working
* tree. If there is no explicit pattern specified with -e or
@@ -711,6 +734,14 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
opt.relative = 0;
continue;
}
+ if (!strcmp("--color", arg)) {
+ opt.color = 1;
+ continue;
+ }
+ if (!strcmp("--no-color", arg)) {
+ opt.color = 0;
+ continue;
+ }
if (!strcmp("--", arg)) {
/* later processing wants to have this at argv[1] */
argv--;
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3396e35..ee4d509 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1157,7 +1157,7 @@ _git_config ()
__gitcomp "$(__git_merge_strategies)"
return
;;
- color.branch|color.diff|color.status)
+ color.branch|color.diff|color.status|color.grep)
__gitcomp "always never auto"
return
;;
@@ -1240,6 +1240,11 @@ _git_config ()
color.diff.new
color.diff.commit
color.diff.whitespace
+ color.grep
+ color.grep.filepath
+ color.grep.lineno
+ color.grep.separator
+ color.grep.match
color.pager
color.status
color.status.header
@@ -1390,6 +1395,22 @@ _git_shortlog ()
__git_complete_revlist
}
+_git_grep ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --cached --text --ignore-case --word-regexp --invert-match
+ --full-name --extend-regexp --fixed-strings --files-with-matches
+ --files-without-match --count --and --or --not --all-match
+ --color
+ "
+ return
+ ;;
+ esac
+}
+
_git_show ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -1642,7 +1663,7 @@ _git ()
fetch) _git_fetch ;;
format-patch) _git_format_patch ;;
gc) _git_gc ;;
- grep) _git_grep ;;
+ grep) _git_grep ;;
help) _git_help ;;
init) _git_init ;;
log) _git_log ;;
diff --git a/grep.c b/grep.c
index f67d671..5c3e6cd 100644
--- a/grep.c
+++ b/grep.c
@@ -1,7 +1,39 @@
#include "cache.h"
#include "grep.h"
+#include "color.h"
#include "xdiff-interface.h"
+static char grep_colors[][COLOR_MAXLEN] = {
+ "\033[m", /* reset */
+ "", /* PLAIN (normal) */
+ "\033[35m", /* FILEPATH (magenta) */
+ "\033[32m", /* LINENO (green) */
+ "\033[36m", /* SEPARATOR (cyan) */
+ "\033[1m\033[31m", /* MATCH (red)*/
+};
+
+const char *grep_get_color(enum color_grep ix)
+{
+ return grep_colors[ix];
+}
+
+int parse_grep_color_slot(const char *var, int ofs)
+{
+ if (!strcasecmp(var+ofs, "plain"))
+ return COLOR_GREP_PLAIN;
+ if (!strcasecmp(var+ofs, "reset"))
+ return COLOR_GREP_RESET;
+ if (!strcasecmp(var+ofs, "filepath"))
+ return COLOR_GREP_FILEPATH;
+ if (!strcasecmp(var+ofs, "lineno"))
+ return COLOR_GREP_LINENO;
+ if (!strcasecmp(var+ofs, "separator"))
+ return COLOR_GREP_SEPARATOR;
+ if (!strcasecmp(var+ofs, "match"))
+ return COLOR_GREP_MATCH;
+ die("bad config variable '%s'", var);
+}
+
void append_grep_pattern(struct grep_opt *opt, const char *pat,
const char *origin, int no, enum grep_pat_token t)
{
@@ -247,7 +279,10 @@ static int fixmatch(const char *pattern, char *line, regmatch_t *match)
}
}
-static int match_one_pattern(struct grep_opt *opt, struct grep_pat *p, char *bol, char *eol, enum grep_context ctx)
+static int match_one_pattern_1(struct grep_opt *opt, struct grep_pat *p,
+ char *bol, char *eol,
+ enum grep_context ctx, int eflags,
+ int *rm_so, int *rm_eo)
{
int hit = 0;
int at_true_bol = 1;
@@ -261,7 +296,7 @@ static int match_one_pattern(struct grep_opt *opt, struct grep_pat *p, char *bol
if (!opt->fixed) {
regex_t *exp = &p->regexp;
hit = !regexec(exp, bol, ARRAY_SIZE(pmatch),
- pmatch, 0);
+ pmatch, eflags);
}
else {
hit = !fixmatch(p->pattern, bol, pmatch);
@@ -298,9 +333,20 @@ static int match_one_pattern(struct grep_opt *opt, struct grep_pat *p, char *bol
goto again;
}
}
+ if (hit) {
+ if (rm_so)
+ *rm_so = pmatch[0].rm_so;
+ if (rm_eo)
+ *rm_eo = pmatch[0].rm_eo;
+ }
return hit;
}
+static int match_one_pattern(struct grep_opt *opt, struct grep_pat *p, char *bol, char *eol, enum grep_context ctx)
+{
+ return match_one_pattern_1(opt, p, bol, eol, ctx, 0, NULL, NULL);
+}
+
static int match_expr_eval(struct grep_opt *o,
struct grep_expr *x,
char *bol, char *eol,
@@ -365,6 +411,54 @@ static int match_line(struct grep_opt *opt, char *bol, char *eol,
return 0;
}
+static void show_line_colored(struct grep_opt *opt, char *bol, char *eol,
+ const char *name, unsigned lno, char sign)
+{
+ struct grep_pat *p;
+ int rm_so, rm_eo, eflags = 0;
+ int ch;
+
+ if (opt->pathname)
+ printf("%s%s%s%c%s",
+ grep_get_color(COLOR_GREP_FILEPATH),
+ name,
+ grep_get_color(COLOR_GREP_SEPARATOR),
+ sign,
+ grep_get_color(COLOR_GREP_RESET));
+ if (opt->linenum)
+ printf("%s%d%s%c%s",
+ grep_get_color(COLOR_GREP_LINENO),
+ lno,
+ grep_get_color(COLOR_GREP_SEPARATOR),
+ sign,
+ grep_get_color(COLOR_GREP_RESET));
+
+ ch = *eol;
+ *eol = 0;
+ while (bol < eol) {
+ for (p = opt->pattern_list; p; p = p->next) {
+ if (match_one_pattern_1(opt, p, bol, eol, GREP_CONTEXT_BODY, eflags, &rm_so, &rm_eo))
+ break;
+ }
+
+ /* No match, break the loop */
+ if (!p ||
+ (rm_so < 0) || (eol - bol) <= rm_so ||
+ (rm_eo < 0) || (eol - bol) < rm_eo)
+ break;
+
+ printf("%.*s%s%.*s%s",
+ rm_so, bol,
+ grep_get_color(COLOR_GREP_MATCH),
+ rm_eo-rm_so, bol+rm_so,
+ grep_get_color(COLOR_GREP_RESET));
+ bol += rm_eo;
+ eflags = REG_NOTBOL;
+ }
+ printf("%s\n", bol);
+ *eol = ch;
+}
+
static int grep_buffer_1(struct grep_opt *opt, const char *name,
char *buf, unsigned long size, int collect_hits)
{
@@ -466,8 +560,12 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
}
if (last_shown && lno != last_shown + 1)
printf(hunk_mark);
- if (!opt->count)
- show_line(opt, bol, eol, name, lno, ':');
+ if (!opt->count) {
+ if (opt->color)
+ show_line_colored(opt, bol, eol, name, lno, ':');
+ else
+ show_line(opt, bol, eol, name, lno, ':');
+ }
last_shown = last_hit = lno;
}
else if (last_hit &&
diff --git a/grep.h b/grep.h
index d252dd2..9073114 100644
--- a/grep.h
+++ b/grep.h
@@ -33,6 +33,15 @@ enum grep_expr_node {
GREP_NODE_OR,
};
+enum color_grep {
+ COLOR_GREP_RESET = 0,
+ COLOR_GREP_PLAIN = 1,
+ COLOR_GREP_FILEPATH = 2,
+ COLOR_GREP_LINENO = 3,
+ COLOR_GREP_SEPARATOR = 4,
+ COLOR_GREP_MATCH = 5,
+};
+
struct grep_expr {
enum grep_expr_node node;
unsigned hit;
@@ -68,11 +77,14 @@ struct grep_opt {
unsigned extended:1;
unsigned relative:1;
unsigned pathname:1;
+ unsigned color:1;
int regflags;
unsigned pre_context;
unsigned post_context;
};
+extern const char *grep_get_color(enum color_grep ix);
+extern int parse_grep_color_slot(const char *var, int ofs);
extern void append_grep_pattern(struct grep_opt *opt, const char *pat, const char *origin, int no, enum grep_pat_token t);
extern void compile_grep_patterns(struct grep_opt *opt);
extern void free_grep_patterns(struct grep_opt *opt);
^ permalink raw reply related
* Re: [ANNOUNCE] GIT 1.6.0-rc2
From: Junio C Hamano @ 2008-08-07 10:00 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: git, linux-kernel
In-Reply-To: <1218099517.8625.3.camel@twins>
Peter Zijlstra <peterz@infradead.org> writes:
> Quick question - where does one go to find out the cool new features
> that make it 1.6 and should convince me to upgrade and try this whicked
> new release?
Draft release notes for 1.6.0 was posted to the list some time ago
already, but as always:
http://www.kernel.org/pub/software/scm/git/docs/RelNotes-1.6.0.txt
^ permalink raw reply
* Re: [PATCH] files given on the command line are relative to $cwd
From: Junio C Hamano @ 2008-08-07 9:47 UTC (permalink / raw)
To: Luciano Rocha
Cc: Samuel Tardieu, git list, pascal, Pierre Habouzit,
Kristian Høgsberg
In-Reply-To: <20080807090341.GA6421@bit.office.eurotux.com>
Luciano Rocha <luciano@eurotux.com> writes:
> On Thu, Aug 07, 2008 at 10:45:21AM +0200, Samuel Tardieu wrote:
>> >>>>> "Junio" == Junio C Hamano <gitster@pobox.com> writes:
>>
>> Junio> When running "git commit -F file" and "git tag -F file" from a
>> Junio> subdirectory, we should take it as relative to the directory we
>> Junio> started from, not relative to the top-level directory.
>>
>> Don't we have the same problem with "git show"? If you go into
>> the "gitweb" directory of the GIT source, "git show HEAD:README" will
>> show you the toplevel "README" instead of the one in the "gitweb"
>> directory.
>
> No, git show has different semantics. It has been discussed often in
> this list.
You are half correct --- it is not show but tree:path syntax.
^ permalink raw reply
* [PATCH] git-svn: add ability to specify --commit-url for dcommit
From: Eric Wong @ 2008-08-07 9:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
This allows one to use public svn:// URLs for fetch and
svn+ssh:// URLs for committing (without using the complicated
rewriteRoot option, reimporting or git-filter-branch).
Using this can also help avoid unnecessary server
authentication/encryption overhead on busy SVN servers.
Along with the new --revision option, this can also be allowed
to override the branch detection in dcommit, too. This is
potentially dangerous and not recommended! (And also purposely
undocumented, but the loaded gun is there in case somebody
wants to make it safe).
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
Documentation/git-svn.txt | 9 +++++++++
git-svn.perl | 9 ++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 773ae96..1e644ca 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -138,6 +138,15 @@ and have no uncommitted changes.
+
--no-rebase;;
After committing, do not rebase or reset.
+--commit-url <URL>;;
+ Commit to this SVN URL (the full path). This is intended to
+ allow existing git-svn repositories created with one transport
+ method (e.g. `svn://` or `http://` for anonymous read) to be
+ reused if a user is later given access to an alternate transport
+ method (e.g. `svn+ssh://` or `https://`) for commit.
+
+ Using this option for any other purpose (don't ask)
+ is very strongly discouraged.
--
'log'::
diff --git a/git-svn.perl b/git-svn.perl
index df0ed90..06a82c8 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -66,7 +66,7 @@ my ($_stdin, $_help, $_edit,
$_version, $_fetch_all, $_no_rebase,
$_merge, $_strategy, $_dry_run, $_local,
$_prefix, $_no_checkout, $_url, $_verbose,
- $_git_format);
+ $_git_format, $_commit_url);
$Git::SVN::_follow_parent = 1;
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@ -127,6 +127,8 @@ my %cmd = (
'verbose|v' => \$_verbose,
'dry-run|n' => \$_dry_run,
'fetch-all|all' => \$_fetch_all,
+ 'commit-url=s' => \$_commit_url,
+ 'revision|r=i' => \$_revision,
'no-rebase' => \$_no_rebase,
%cmt_opts, %fc_opts } ],
'set-tree' => [ \&cmd_set_tree,
@@ -416,6 +418,8 @@ sub cmd_dcommit {
$head ||= 'HEAD';
my @refs;
my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
+ $url = $_commit_url if defined $_commit_url;
+ my $last_rev = $_revision if defined $_revision;
if ($url) {
print "Committing to $url ...\n";
}
@@ -423,7 +427,6 @@ sub cmd_dcommit {
die "Unable to determine upstream SVN information from ",
"$head history.\nPerhaps the repository is empty.";
}
- my $last_rev;
my ($linear_refs, $parents) = linearize_history($gs, \@refs);
if ($_no_rebase && scalar(@$linear_refs) > 1) {
warn "Attempting to commit more than one change while ",
@@ -446,7 +449,7 @@ sub cmd_dcommit {
my $cmt_rev;
my %ed_opts = ( r => $last_rev,
log => get_commit_entry($d)->{log},
- ra => Git::SVN::Ra->new($gs->full_url),
+ ra => Git::SVN::Ra->new($url),
config => SVN::Core::config_get_config(
$Git::SVN::Ra::config_dir
),
--
Eric Wong
^ permalink raw reply related
* Re: Documentation: user-manual: "git commit -a" doesn't motivate .gitignore
From: J. Bruce Fields @ 2008-08-07 12:24 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git
In-Reply-To: <Pine.GSO.4.62.0808061603340.18817@harper.uchicago.edu>
On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder wrote:
> "git commit -a" ignores untracked files and follows all tracked
> files, regardless of whether they are listed in .gitignore. So
> don't use it to motivate gitignore.
Makes sense to me.
--b.
>
> Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
> ---
> I noticed this while reading through the git-scm book, which
> looks very good. If I am missing something, I would be very
> happy to know. Maybe the sort of person that wants to track the
> exact contents of the working tree would prefer
> "git commit -a -i ." over "git commit -a"?
>
> Documentation/user-manual.txt | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
> index 43f4e39..f421689 100644
> --- a/Documentation/user-manual.txt
> +++ b/Documentation/user-manual.txt
> @@ -1128,8 +1128,8 @@ This typically includes files generated by a build process or temporary
> backup files made by your editor. Of course, 'not' tracking files with git
> is just a matter of 'not' calling "`git-add`" on them. But it quickly becomes
> annoying to have these untracked files lying around; e.g. they make
> -"`git add .`" and "`git commit -a`" practically useless, and they keep
> -showing up in the output of "`git status`".
> +"`git add .`" practically useless, and they keep showing up in the output of
> +"`git status`".
>
> You can tell git to ignore certain files by creating a file called .gitignore
> in the top level of your working directory, with contents such as:
> --
> 1.6.0.rc1.228.ge730
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH 2/2] git-svn: Allow deep branch names by supporting multi-globs
From: Eric Wong @ 2008-08-07 9:00 UTC (permalink / raw)
To: Marcus Griep; +Cc: Git Mailing List
In-Reply-To: <489A025C.50507@griep.us>
Marcus Griep <marcus@griep.us> wrote:
> Some repositories use a deep branching strategy, such as:
> branches/1.0/1.0.rc1
> branches/1.0/1.0.rc2
> branches/1.0/1.0.rtm
> branches/1.0/1.0.gold
>
> Only allowing a single glob stiffles this.
>
> This change allows for a single glob 'set' to accept this deep branching
> strategy.
>
> The ref glob depth must match the branch glob depth. When using the -b or -t
> options for init or clone, this is automatically done.
>
> For example, using the above branches:
> svn-remote.svn.branches = branches/*/*:refs/remote/*/*
> gives the following branch names:
> 1.0/1.0.rc1
> 1.0/1.0.rc2
> 1.0/1.0.rtm
> 1.0/1.0.gold
Hi Marcus,
This looks awesome. Some folks have been wanting to do this for a
long time but I was always too lazy to touch this code.
Unfortunately, I'm having trouble applying your patches due to
whitespace conversion issues with your MUA. I suggest taking a look at
Documentation/SubmittingPatches on how to submit easily applyable
patches to the mailing list.
I usually use git-send-email myself, but sometimes mutt, too.
Also, there are some long lines that need to be wrapped at
80 characters or less to conform to the existing coding
conventions.
I look forward to applying and testing your patches,
Thank you!
--
Eric Wong
^ 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