From ad2c82c0e1a543f4475a948ccb3eb4afcce86f26 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Wed, 13 Dec 2006 16:25:26 -0500 Subject: [PATCH 1/8] repacked packs should be read-only ... just like the other pack creating tools do. Signed-off-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- git-repack.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-repack.sh b/git-repack.sh index f150a558ca..067898f120 100755 --- a/git-repack.sh +++ b/git-repack.sh @@ -67,6 +67,8 @@ name=$(git-pack-objects --non-empty --all $args Date: Wed, 13 Dec 2006 15:58:41 -0800 Subject: [PATCH 2/8] git-svn: allow both diff.color and color.diff The list concensus is to group color related configuration under "color.*" so let's be consistent. Inspired by Andy Parkins's patch to do the same for diff/log family. With fixes from Eric Wong. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano --- git-svn.perl | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index ec92b440b9..73ab8d873f 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -925,19 +925,38 @@ sub cmt_showable { sub log_use_color { return 1 if $_color; - my $dc; - chomp($dc = `git-repo-config --get diff.color`); + my ($dc, $dcvar); + $dcvar = 'color.diff'; + $dc = `git-repo-config --get $dcvar`; + if ($dc eq '') { + # nothing at all; fallback to "diff.color" + $dcvar = 'diff.color'; + $dc = `git-repo-config --get $dcvar`; + } + chomp($dc); if ($dc eq 'auto') { - if (-t *STDOUT || (defined $_pager && - `git-repo-config --bool --get pager.color` !~ /^false/)) { + my $pc; + $pc = `git-repo-config --get color.pager`; + if ($pc eq '') { + # does not have it -- fallback to pager.color + $pc = `git-repo-config --bool --get pager.color`; + } + else { + $pc = `git-repo-config --bool --get color.pager`; + if ($?) { + $pc = 'false'; + } + } + chomp($pc); + if (-t *STDOUT || (defined $_pager && $pc eq 'true')) { return ($ENV{TERM} && $ENV{TERM} ne 'dumb'); } return 0; } return 0 if $dc eq 'never'; return 1 if $dc eq 'always'; - chomp($dc = `git-repo-config --bool --get diff.color`); - $dc eq 'true'; + chomp($dc = `git-repo-config --bool --get $dcvar`); + return ($dc eq 'true'); } sub git_svn_log_cmd { From f5e6b89b3a4420481a6ecdc05df325cb6d69d114 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 14 Dec 2006 00:03:18 -0800 Subject: [PATCH 3/8] Update git-diff documentation Porcelain documentation should talk in terms of end-user workflow, not in terms of implementation details. Do not suggest update-index, but git-add instead. Explain differences among 0-, 1- and 2-tree cases not as differences of number of trees given to the command, but say why user would want to give these number of trees to the command in what situation. Signed-off-by: Junio C Hamano --- Documentation/git-diff.txt | 52 +++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/Documentation/git-diff.txt b/Documentation/git-diff.txt index 228c4d95bd..127d68c962 100644 --- a/Documentation/git-diff.txt +++ b/Documentation/git-diff.txt @@ -14,30 +14,48 @@ DESCRIPTION ----------- Show changes between two trees, a tree and the working tree, a tree and the index file, or the index file and the working tree. -The combination of what is compared with what is determined by -the number of trees given to the command. -* When no is given, the working tree and the index - file are compared, using `git-diff-files`. +'git-diff' [--options] [--] [...]:: -* When one is given, the working tree and the named - tree are compared, using `git-diff-index`. The option - `--cached` can be given to compare the index file and - the named tree. + This form is to view the changes you made relative to + the index (staging area for the next commit). In other + words, the differences are what you _could_ tell git to + further add to the index but you still haven't. You can + stage these changes by using gitlink:git-add[1]. + +'git-diff' [--options] --cached [] [--] [...]:: + + This form is to view the changes you staged for the next + commit relative to the named . Typically you + would want comparison with the latest commit, so if you + do not give , it defaults to HEAD. + +'git-diff' [--options] -- [...]:: + + This form is to view the changes you have in your + working tree relative to the named . You can + use HEAD to compare it with the latest commit, or a + branch name to compare with the tip of a different + branch. + +'git-diff' [--options] -- [...]:: + + This form is to view the changes between two , + for example, tips of two branches. + +Just in case if you are doing something exotic, it should be +noted that all of the in the above description can be +any . -* When two s are given, these two trees are compared - using `git-diff-tree`. OPTIONS ------- ---diff-options:: - '--diff-options' are passed to the `git-diff-files`, - `git-diff-index`, and `git-diff-tree` commands. See the - documentation for these commands for description. +include::diff-options.txt[] ...:: - The arguments are also passed to `git-diff-\*` - commands. + The parameters, when given, are used to limit + the diff to the named paths (you can give directory + names and get diff for all files under them). EXAMPLES @@ -51,7 +69,7 @@ $ git diff --cached <2> $ git diff HEAD <3> ------------ + -<1> changes in the working tree since your last git-update-index. +<1> changes in the working tree not yet staged for the next commit. <2> changes between the index and your last commit; what you would be committing if you run "git commit" without "-a" option. <3> changes in the working tree since your last commit; what you From 7da41f48c8acea834e8204917fe59da2b975903b Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 14 Dec 2006 05:07:46 -0500 Subject: [PATCH 4/8] Bypass expensive content comparsion during rename detection. When comparing file contents during the second loop through a rename detection attempt we can skip the expensive byte-by-byte comparsion if both source and destination files have valid SHA1 values. This improves performance by avoiding either an expensive open/mmap to read the working tree copy, or an expensive inflate of a blob object. Unfortunately we still have to at least initialize the sizes of the source and destination files even if the SHA1 values don't match. Failing to initialize the sizes causes a number of test cases to fail and start reporting different copy/rename behavior than was expected. Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- diffcore-rename.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/diffcore-rename.c b/diffcore-rename.c index 57a74b6bb8..91fa2bea51 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -109,6 +109,8 @@ static int is_exact_match(struct diff_filespec *src, return 0; if (src->size != dst->size) return 0; + if (src->sha1_valid && dst->sha1_valid) + return !hashcmp(src->sha1, dst->sha1); if (diff_populate_filespec(src, 0) || diff_populate_filespec(dst, 0)) return 0; if (src->size == dst->size && From 02c9e93547d4c21635beb30895ebb6e37f67833c Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 14 Dec 2006 11:40:21 +0100 Subject: [PATCH 5/8] INSTALL: no need to have GNU diff installed Since a long time, we have inbuilt diff generation. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- INSTALL | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/INSTALL b/INSTALL index b5dd9f0abb..e7aea60e92 100644 --- a/INSTALL +++ b/INSTALL @@ -72,16 +72,6 @@ Issues of note: - expat library; git-http-push uses it for remote lock management over DAV. Similar to "curl" above, this is optional. - - "GNU diff" to generate patches. Of course, you don't _have_ to - generate patches if you don't want to, but let's face it, you'll - be wanting to. Or why did you get git in the first place? - - Non-GNU versions of the diff/patch programs don't generally support - the unified patch format (which is the one git uses), so you - really do want to get the GNU one. Trust me, you will want to - do that even if it wasn't for git. There's no point in living - in the dark ages any more. - - "wish", the Tcl/Tk windowing shell is used in gitk to show the history graphically From 4da9028578ffaaf8985e1436e2e1cf16bd3b9023 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 14 Dec 2006 00:36:23 -0800 Subject: [PATCH 6/8] git-fetch: make it work from within a subdirectory. Signed-off-by: Junio C Hamano --- git-fetch.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-fetch.sh b/git-fetch.sh index 4eecf148ea..fb35815a5f 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -2,7 +2,13 @@ # USAGE=' ...' +SUBDIRECTORY_OK=Yes . git-sh-setup +TOP=$(git-rev-parse --show-cdup) +if test ! -z "$TOP" +then + cd "$TOP" +fi . git-parse-remote _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" From a81c311f23a5fadd6c1da38d46781644cd9db6e8 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 14 Dec 2006 00:40:15 -0800 Subject: [PATCH 7/8] git-reset: make it work from within a subdirectory. If you typically sit in, say "src/", it's annoying to have to change directory to do a reset. This may need to be reworked when we add "git reset -- paths..." to encapsulate the "ls-tree $tree | update-index --index-info" pattern. Signed-off-by: Junio C Hamano --- git-reset.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/git-reset.sh b/git-reset.sh index c0feb4435d..03d2c3b937 100755 --- a/git-reset.sh +++ b/git-reset.sh @@ -1,8 +1,15 @@ #!/bin/sh USAGE='[--mixed | --soft | --hard] []' +SUBDIRECTORY_OK=Yes . git-sh-setup +TOP=$(git-rev-parse --show-cdup) +if test ! -z "$TOP" +then + cd "$TOP" +fi + update= reset_type=--mixed case "$1" in From 2ce633b928f78224a37308f45810e76fefe8df56 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 14 Dec 2006 01:19:19 -0800 Subject: [PATCH 8/8] git-reset [--mixed] [--] ... Sometimes it is asked on the list how to revert selected path in the index from a tree, most often HEAD, without affecting the files in the working tree. A similar operation that also affects the working tree files has been available in the form of "git checkout -- ...". By definition --soft would never affect either the index nor the working tree files, and --hard is the way to make the working tree files as close to pristine, so this new option is available only for the default --mixed case. Signed-off-by: Junio C Hamano --- git-reset.sh | 69 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/git-reset.sh b/git-reset.sh index 03d2c3b937..8d95e3748d 100755 --- a/git-reset.sh +++ b/git-reset.sh @@ -1,35 +1,60 @@ #!/bin/sh - -USAGE='[--mixed | --soft | --hard] []' +# +# Copyright (c) 2005, 2006 Linus Torvalds and Junio C Hamano +# +USAGE='[--mixed | --soft | --hard] [] [ [--] ...]' SUBDIRECTORY_OK=Yes . git-sh-setup +update= reset_type=--mixed +unset rev + +while case $# in 0) break ;; esac +do + case "$1" in + --mixed | --soft | --hard) + reset_type="$1" + ;; + --) + break + ;; + -*) + usage + ;; + *) + rev=$(git-rev-parse --verify "$1") || exit + shift + break + ;; + esac + shift +done + +: ${rev=HEAD} +rev=$(git-rev-parse --verify $rev^0) || exit + +# Skip -- in "git reset HEAD -- foo" and "git reset -- foo". +case "$1" in --) shift ;; esac + +# git reset --mixed tree [--] paths... can be used to +# load chosen paths from the tree into the index without +# affecting the working tree nor HEAD. +if test $# != 0 +then + test "$reset_type" == "--mixed" || + die "Cannot do partial $reset_type reset." + git ls-tree -r --full-name $rev -- "$@" | + git update-index --add --index-info || exit + git update-index --refresh + exit +fi + TOP=$(git-rev-parse --show-cdup) if test ! -z "$TOP" then cd "$TOP" fi -update= -reset_type=--mixed -case "$1" in ---mixed | --soft | --hard) - reset_type="$1" - shift - ;; --*) - usage ;; -esac - -case $# in -0) rev=HEAD ;; -1) rev=$(git-rev-parse --verify "$1") || exit ;; -*) usage ;; -esac -rev=$(git-rev-parse --verify $rev^0) || exit - -# We need to remember the set of paths that _could_ be left -# behind before a hard reset, so that we can remove them. if test "$reset_type" = "--hard" then update=-u