From a9f979093dabe8b1c7bf8d67863adc378a8bec45 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 3 Mar 2010 21:10:21 +0100 Subject: [PATCH 1/6] hash-object: support --stdin-paths with --no-filters Signed-off-by: Erik Faye-Lund Acked-by: Junio C Hamano --- Documentation/git-hash-object.txt | 2 +- builtin-hash-object.c | 8 ++++---- t/t1007-hash-object.sh | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Documentation/git-hash-object.txt b/Documentation/git-hash-object.txt index 479fce4693..6904739a48 100644 --- a/Documentation/git-hash-object.txt +++ b/Documentation/git-hash-object.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git hash-object' [-t ] [-w] [--path=|--no-filters] [--stdin] [--] ... -'git hash-object' [-t ] [-w] --stdin-paths < +'git hash-object' [-t ] [-w] --stdin-paths [--no-filters] < DESCRIPTION ----------- diff --git a/builtin-hash-object.c b/builtin-hash-object.c index 6a5f5b5f0e..080af1a01b 100644 --- a/builtin-hash-object.c +++ b/builtin-hash-object.c @@ -33,6 +33,8 @@ static void hash_object(const char *path, const char *type, int write_object, hash_fd(fd, type, write_object, vpath); } +static int no_filters; + static void hash_stdin_paths(const char *type, int write_objects) { struct strbuf buf = STRBUF_INIT, nbuf = STRBUF_INIT; @@ -44,7 +46,8 @@ static void hash_stdin_paths(const char *type, int write_objects) die("line is badly quoted"); strbuf_swap(&buf, &nbuf); } - hash_object(buf.buf, type, write_objects, buf.buf); + hash_object(buf.buf, type, write_objects, + no_filters ? NULL : buf.buf); } strbuf_release(&buf); strbuf_release(&nbuf); @@ -60,7 +63,6 @@ static const char *type; static int write_object; static int hashstdin; static int stdin_paths; -static int no_filters; static const char *vpath; static const struct option hash_object_options[] = { @@ -100,8 +102,6 @@ int cmd_hash_object(int argc, const char **argv, const char *prefix) errstr = "Can't specify files with --stdin-paths"; else if (vpath) errstr = "Can't use --stdin-paths with --path"; - else if (no_filters) - errstr = "Can't use --stdin-paths with --no-filters"; } else { if (hashstdin > 1) diff --git a/t/t1007-hash-object.sh b/t/t1007-hash-object.sh index fd98e445bf..dd32432d62 100755 --- a/t/t1007-hash-object.sh +++ b/t/t1007-hash-object.sh @@ -65,10 +65,6 @@ test_expect_success "Can't use --path with --stdin-paths" ' echo example | test_must_fail git hash-object --stdin-paths --path=foo ' -test_expect_success "Can't use --stdin-paths with --no-filters" ' - echo example | test_must_fail git hash-object --stdin-paths --no-filters -' - test_expect_success "Can't use --path with --no-filters" ' test_must_fail git hash-object --no-filters --path=foo ' @@ -141,6 +137,20 @@ test_expect_success 'check that --no-filters option works' ' git config --unset core.autocrlf ' +test_expect_success 'check that --no-filters option works with --stdin-paths' ' + echo fooQ | tr Q "\\015" >file0 && + cp file0 file1 && + echo "file0 -crlf" >.gitattributes && + echo "file1 crlf" >>.gitattributes && + git config core.autocrlf true && + file0_sha=$(git hash-object file0) && + file1_sha=$(git hash-object file1) && + test "$file0_sha" != "$file1_sha" && + nofilters_file1=$(echo "file1" | git hash-object --stdin-paths --no-filters) && + test "$file0_sha" = "$nofilters_file1" && + git config --unset core.autocrlf +' + pop_repo for args in "-w --stdin" "--stdin -w"; do From 402e139c7e30eb95312aeafdc1a9e8e8167c14cb Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 3 Mar 2010 21:10:22 +0100 Subject: [PATCH 2/6] git-svn: support fetch with autocrlf on Before commit d3c9634e, performing a "git svn rebase" that fetched a change containing CRLFs corrupted the git-svn meta-data. This was worked around in d3c9634e by setting core.autocrlf to "false" in the per-repo config when initing the clone. However, if the config variable was later changed, the corruption would still occur. This patch tries to fix it while allowing core.autocrlf to be enabled, by disabling filters when when hashing. git-svn is currently the only call-site for hash_and_insert_object (apart from the test-suite), so changing it should be safe. Signed-off-by: Erik Faye-Lund Acked-by: Eric Wong --- perl/Git.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl/Git.pm b/perl/Git.pm index 970fe434ed..1926dc9a4b 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -842,7 +842,7 @@ sub _open_hash_and_insert_object_if_needed { ($self->{hash_object_pid}, $self->{hash_object_in}, $self->{hash_object_out}, $self->{hash_object_ctx}) = - command_bidi_pipe(qw(hash-object -w --stdin-paths)); + command_bidi_pipe(qw(hash-object -w --stdin-paths --no-filters)); } sub _close_hash_and_insert_object { From 942c9aad4f3b69f6f53af77321662d9d69a1bdeb Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Wed, 3 Mar 2010 21:10:23 +0100 Subject: [PATCH 3/6] Revert "git-svn: always initialize with core.autocrlf=false" git-svn rebase used to have issues with CRLF conversion. Since these issues have been fixed, we can safely revert the work-around that disables CRLF conversion. This reverts commit d3c9634eacdcaa71cbd69a160e6f4e80ddb7ab63. Signed-off-by: Erik Faye-Lund Acked-by: Eric Wong --- git-svn.perl | 1 - 1 file changed, 1 deletion(-) diff --git a/git-svn.perl b/git-svn.perl index bae7231096..7bca381c4b 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -369,7 +369,6 @@ sub do_git_init_db { command_noisy(@init_db); $_repository = Git->repository(Repository => ".git"); } - command_noisy('config', 'core.autocrlf', 'false'); my $set; my $pfx = "svn-remote.$Git::SVN::default_repo_id"; foreach my $i (keys %icv) { From b0779246a11d4213c4d9d8af8d3f6e39649c9b4a Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 4 Mar 2010 11:23:53 +0100 Subject: [PATCH 4/6] git-svn: make git svn --version work again by requesting SVN::Core which is needed for the svn version. Signed-off-by: Michael J Gruber Acked-by: Eric Wong --- git-svn.perl | 1 + 1 file changed, 1 insertion(+) diff --git a/git-svn.perl b/git-svn.perl index 7bca381c4b..1a26843f44 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -351,6 +351,7 @@ information. } sub version { + ::_req_svn(); print "git-svn version $VERSION (svn $SVN::Core::VERSION)\n"; exit 0; } From c9c8c56e072ae568b480eb1a808bd172bf373431 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Fri, 5 Mar 2010 00:20:38 -0800 Subject: [PATCH 5/6] t7406: Fix submodule init config tests These tests have been broken since they were introduced in commits ca2cedb (git-submodule: add support for --rebase., 2009-04-24) and 42b4917 (git-submodule: add support for --merge., 2009-06-03). 'git submodule init' expects the submodules to exist in the index. In this case, the submodules don't exist and therefore looking for the submodules will always fail. To make matters worse, git submodule fails visibly to the user by saying: error: pathspec 'rebasing' did not match any file(s) known to git. Did you forget to 'git add'? but doesn't return an error code. This allows the test to fail silently. Fix it by adding the submodules first. Cc: Johan Herland Cc: Peter Hutterer Cc: Johannes Schindelin Signed-off-by: Stephen Boyd Signed-off-by: Junio C Hamano --- t/t7406-submodule-update.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index 8e2449d244..1382a8e58a 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -28,6 +28,8 @@ test_expect_success 'setup a submodule tree' ' git commit -m upstream git clone . super && git clone super submodule && + git clone super rebasing && + git clone super merging && (cd super && git submodule add ../submodule submodule && test_tick && @@ -45,6 +47,16 @@ test_expect_success 'setup a submodule tree' ' ) && git add submodule && git commit -m "submodule update" + ) && + (cd super && + git submodule add ../rebasing rebasing && + test_tick && + git commit -m "rebasing" + ) && + (cd super && + git submodule add ../merging merging && + test_tick && + git commit -m "rebasing" ) ' @@ -177,21 +189,17 @@ test_expect_success 'submodule update - checkout in .git/config' ' test_expect_success 'submodule init picks up rebase' ' (cd super && - git config submodule.rebasing.url git://non-existing/git && - git config submodule.rebasing.path does-not-matter && - git config submodule.rebasing.update rebase && + git config -f .gitmodules submodule.rebasing.update rebase && git submodule init rebasing && - test "rebase" = $(git config submodule.rebasing.update) + test "rebase" = "$(git config submodule.rebasing.update)" ) ' test_expect_success 'submodule init picks up merge' ' (cd super && - git config submodule.merging.url git://non-existing/git && - git config submodule.merging.path does-not-matter && - git config submodule.merging.update merge && + git config -f .gitmodules submodule.merging.update merge && git submodule init merging && - test "merge" = $(git config submodule.merging.update) + test "merge" = "$(git config submodule.merging.update)" ) ' From 5d005922bc781c1f6ec9ae0af466f308a7576612 Mon Sep 17 00:00:00 2001 From: Matthieu Moy Date: Fri, 5 Mar 2010 19:43:23 +0100 Subject: [PATCH 6/6] stash: suggest the correct command line for unknown options. Signed-off-by: Matthieu Moy Signed-off-by: Junio C Hamano --- git-stash.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/git-stash.sh b/git-stash.sh index 2d69196393..aa47e541ee 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -151,6 +151,7 @@ save_stash () { ;; -*) echo "error: unknown option for 'stash save': $1" + echo " To provide a message, use git stash save -- '$1'" usage ;; *)