From 3c7406d4b595c9e8c8dfcff2739bab9412add5a3 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 26 Jun 2010 14:23:02 -0500 Subject: [PATCH 01/12] t7006 (pager): introduce helper for parameterized tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current tests test pager configuration for ‘git log’, but other commands use a different setup procedure and should therefore be tested separately. Add a helper to make this easier. This patch introduces the helper and changes some existing tests to use it. The only functional change should be the introduction of ‘git log - ’ to a few test descriptions. Signed-off-by: Jonathan Nieder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- t/t7006-pager.sh | 72 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 18 deletions(-) diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index 9a83241c94..b117ebb5a7 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -172,58 +172,94 @@ then test_set_prereq SIMPLEPAGER fi -test_expect_success SIMPLEPAGER 'default pager is used by default' ' +# Use this helper to make it easy for the caller of your +# terminal-using function to specify whether it should fail. +# If you write +# +# your_test() { +# parse_args "$@" +# +# $test_expectation "$cmd - behaves well" " +# ... +# $full_command && +# ... +# " +# } +# +# then your test can be used like this: +# +# your_test expect_(success|failure) [test_must_fail] 'git foo' +# +parse_args() { + test_expectation="test_$1" + shift + if test "$1" = test_must_fail + then + full_command="test_must_fail test_terminal " + shift + else + full_command="test_terminal " + fi + cmd=$1 + full_command="$full_command $1" +} + +parse_args expect_success 'git log' +$test_expectation SIMPLEPAGER "$cmd - default pager is used by default" " unset PAGER GIT_PAGER; test_might_fail git config --unset core.pager && rm -f default_pager_used || cleanup_fail && - cat >$less <<-\EOF && + cat >\$less <<-\EOF && #!/bin/sh wc >default_pager_used EOF - chmod +x $less && + chmod +x \$less && ( - PATH=.:$PATH && + PATH=.:\$PATH && export PATH && - test_terminal git log + $full_command ) && test -e default_pager_used -' +" -test_expect_success TTY 'PAGER overrides default pager' ' +parse_args expect_success 'git log' +$test_expectation TTY "$cmd - PAGER overrides default pager" " unset GIT_PAGER; test_might_fail git config --unset core.pager && rm -f PAGER_used || cleanup_fail && - PAGER="wc >PAGER_used" && + PAGER='wc >PAGER_used' && export PAGER && - test_terminal git log && + $full_command && test -e PAGER_used -' +" -test_expect_success TTY 'core.pager overrides PAGER' ' +parse_args expect_success 'git log' +$test_expectation TTY "$cmd - core.pager overrides PAGER" " unset GIT_PAGER; rm -f core.pager_used || cleanup_fail && PAGER=wc && export PAGER && - git config core.pager "wc >core.pager_used" && - test_terminal git log && + git config core.pager 'wc >core.pager_used' && + $full_command && test -e core.pager_used -' +" -test_expect_success TTY 'GIT_PAGER overrides core.pager' ' +parse_args expect_success 'git log' +$test_expectation TTY "$cmd - GIT_PAGER overrides core.pager" " rm -f GIT_PAGER_used || cleanup_fail && git config core.pager wc && - GIT_PAGER="wc >GIT_PAGER_used" && + GIT_PAGER='wc >GIT_PAGER_used' && export GIT_PAGER && - test_terminal git log && + $full_command && test -e GIT_PAGER_used -' +" test_done From 8f81449e885ab2b9bac09b5b835314d26f107b3f Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 26 Jun 2010 14:24:50 -0500 Subject: [PATCH 02/12] t7006: test pager configuration for several git commands Test choice of pager at several stages of repository setup. This provides some (admittedly uninteresting) examples to keep in mind when considering changes to the setup procedure. Improved-by: Johannes Sixt Signed-off-by: Jonathan Nieder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- t/t7006-pager.sh | 132 +++++++++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 50 deletions(-) diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index b117ebb5a7..4420f91693 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -204,62 +204,94 @@ parse_args() { full_command="$full_command $1" } -parse_args expect_success 'git log' -$test_expectation SIMPLEPAGER "$cmd - default pager is used by default" " - unset PAGER GIT_PAGER; - test_might_fail git config --unset core.pager && - rm -f default_pager_used || - cleanup_fail && +test_default_pager() { + parse_args "$@" - cat >\$less <<-\EOF && - #!/bin/sh - wc >default_pager_used - EOF - chmod +x \$less && - ( - PATH=.:\$PATH && - export PATH && - $full_command - ) && - test -e default_pager_used -" + $test_expectation SIMPLEPAGER "$cmd - default pager is used by default" " + unset PAGER GIT_PAGER; + test_might_fail git config --unset core.pager && + rm -f default_pager_used || + cleanup_fail && -parse_args expect_success 'git log' -$test_expectation TTY "$cmd - PAGER overrides default pager" " - unset GIT_PAGER; - test_might_fail git config --unset core.pager && - rm -f PAGER_used || - cleanup_fail && + cat >\$less <<-\EOF && + #!/bin/sh + wc >default_pager_used + EOF + chmod +x \$less && + ( + PATH=.:\$PATH && + export PATH && + $full_command + ) && + test -e default_pager_used + " +} - PAGER='wc >PAGER_used' && - export PAGER && - $full_command && - test -e PAGER_used -" +test_PAGER_overrides() { + parse_args "$@" -parse_args expect_success 'git log' -$test_expectation TTY "$cmd - core.pager overrides PAGER" " - unset GIT_PAGER; - rm -f core.pager_used || - cleanup_fail && + $test_expectation TTY "$cmd - PAGER overrides default pager" " + unset GIT_PAGER; + test_might_fail git config --unset core.pager && + rm -f PAGER_used || + cleanup_fail && - PAGER=wc && - export PAGER && - git config core.pager 'wc >core.pager_used' && - $full_command && - test -e core.pager_used -" + PAGER='wc >PAGER_used' && + export PAGER && + $full_command && + test -e PAGER_used + " +} -parse_args expect_success 'git log' -$test_expectation TTY "$cmd - GIT_PAGER overrides core.pager" " - rm -f GIT_PAGER_used || - cleanup_fail && +test_core_pager_overrides() { + parse_args "$@" - git config core.pager wc && - GIT_PAGER='wc >GIT_PAGER_used' && - export GIT_PAGER && - $full_command && - test -e GIT_PAGER_used -" + $test_expectation TTY "$cmd - core.pager overrides PAGER" " + unset GIT_PAGER; + rm -f core.pager_used || + cleanup_fail && + + PAGER=wc && + export PAGER && + git config core.pager 'wc >core.pager_used' && + $full_command && + test -e core.pager_used + " +} + +test_GIT_PAGER_overrides() { + parse_args "$@" + + $test_expectation TTY "$cmd - GIT_PAGER overrides core.pager" " + rm -f GIT_PAGER_used || + cleanup_fail && + + git config core.pager wc && + GIT_PAGER='wc >GIT_PAGER_used' && + export GIT_PAGER && + $full_command && + test -e GIT_PAGER_used + " +} + +test_default_pager expect_success 'git log' +test_PAGER_overrides expect_success 'git log' +test_core_pager_overrides expect_success 'git log' +test_GIT_PAGER_overrides expect_success 'git log' + +test_default_pager expect_success 'git -p log' +test_PAGER_overrides expect_success 'git -p log' +test_core_pager_overrides expect_success 'git -p log' +test_GIT_PAGER_overrides expect_success 'git -p log' + +test_default_pager expect_success test_must_fail 'git -p' +test_PAGER_overrides expect_success test_must_fail 'git -p' +test_core_pager_overrides expect_success test_must_fail 'git -p' +test_GIT_PAGER_overrides expect_success test_must_fail 'git -p' + +test_default_pager expect_success test_must_fail 'git -p nonsense' +test_PAGER_overrides expect_success test_must_fail 'git -p nonsense' +test_core_pager_overrides expect_success test_must_fail 'git -p nonsense' +test_GIT_PAGER_overrides expect_success test_must_fail 'git -p nonsense' test_done From bce2c9ae9ff458b6090953ab9f639255f757a104 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Sat, 26 Jun 2010 14:25:37 -0500 Subject: [PATCH 03/12] tests: local config file should be honored from subdirs of toplevel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When git is passed the --paginate option, starting up a pager requires deciding what pager to start, which requires access to the core.pager configuration. If --paginate is handled before searching for the git dir, this configuration will be missed. In other words, with --paginate and only with --paginate, any repository-local core.pager setting is being ignored [*]. [*] unless the git directory is ./.git or GIT_DIR or GIT_CONFIG was set explicitly. Add a test to demonstrate this counterintuitive behavior. Noticed while reading over a patch by Duy that fixes it. Cc: Nguyễn Thái Ngọc Duy Improved-by: Johannes Sixt Signed-off-by: Jonathan Nieder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- t/t7006-pager.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index 4420f91693..2b106be9e9 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -259,6 +259,28 @@ test_core_pager_overrides() { " } +test_core_pager_subdir() { + parse_args "$@" + + $test_expectation TTY "$cmd - core.pager from subdirectory" " + unset GIT_PAGER; + rm -f core.pager_used && + rm -fr sub || + cleanup_fail && + + PAGER=wc && + stampname=\$(pwd)/core.pager_used && + export PAGER stampname && + git config core.pager 'wc >\"\$stampname\"' && + mkdir sub && + ( + cd sub && + $full_command + ) && + test -e core.pager_used + " +} + test_GIT_PAGER_overrides() { parse_args "$@" @@ -277,21 +299,25 @@ test_GIT_PAGER_overrides() { test_default_pager expect_success 'git log' test_PAGER_overrides expect_success 'git log' test_core_pager_overrides expect_success 'git log' +test_core_pager_subdir expect_success 'git log' test_GIT_PAGER_overrides expect_success 'git log' test_default_pager expect_success 'git -p log' test_PAGER_overrides expect_success 'git -p log' test_core_pager_overrides expect_success 'git -p log' +test_core_pager_subdir expect_failure 'git -p log' test_GIT_PAGER_overrides expect_success 'git -p log' test_default_pager expect_success test_must_fail 'git -p' test_PAGER_overrides expect_success test_must_fail 'git -p' test_core_pager_overrides expect_success test_must_fail 'git -p' +test_core_pager_subdir expect_failure test_must_fail 'git -p' test_GIT_PAGER_overrides expect_success test_must_fail 'git -p' test_default_pager expect_success test_must_fail 'git -p nonsense' test_PAGER_overrides expect_success test_must_fail 'git -p nonsense' test_core_pager_overrides expect_success test_must_fail 'git -p nonsense' +test_core_pager_subdir expect_failure test_must_fail 'git -p nonsense' test_GIT_PAGER_overrides expect_success test_must_fail 'git -p nonsense' test_done From 73e25e7cc80e175b5c94678188333e42107fa16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 26 Jun 2010 14:26:37 -0500 Subject: [PATCH 04/12] git --paginate: do not commit pager choice too early MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When git is passed the --paginate option, starting up a pager requires deciding what pager to start, which requires access to the core.pager configuration. At the relevant moment, the repository has not been searched for yet. Attempting to access the configuration at this point results in git_dir being set to .git [*], which is almost certainly not what was wanted. In particular, when run from a subdirectory of the toplevel, git --paginate does not respect the core.pager setting from the current repository. [*] unless GIT_DIR or GIT_CONFIG is set So delay the pager startup when possible: 1. run_argv() already commits pager choice inside run_builtin() if a command is found. For commands that use RUN_SETUP, waiting until then fixes the problem described above: once git knows where to look, it happily respects the core.pager setting. 2. list_common_cmds_help() prints out 29 lines and exits. This can benefit from pagination, so we need to commit the pager choice before writing this output. Luckily ‘git’ without subcommand has no other reason to access a repository, so it would be intuitive to ignore repository-local configuration in this case. Simpler for now to choose a pager using the funny code that notices a repository that happens to be at .git. That this accesses a repository when it is very convenient to is a bug but not an important one. 3. help_unknown_cmd() prints out a few lines to stderr. It is not important to paginate this, so don’t. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Jonathan Nieder Acked-by: Jeff King Signed-off-by: Junio C Hamano --- git.c | 2 +- t/t7006-pager.sh | 58 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/git.c b/git.c index 99f036302a..25e76939e2 100644 --- a/git.c +++ b/git.c @@ -511,12 +511,12 @@ int main(int argc, const char **argv) argv++; argc--; handle_options(&argv, &argc, NULL); - commit_pager_choice(); if (argc > 0) { if (!prefixcmp(argv[0], "--")) argv[0] += 2; } else { /* The user didn't specify a command; give them help */ + commit_pager_choice(); printf("usage: %s\n\n", git_usage_string); list_common_cmds_help(); printf("\n%s\n", git_more_info_string); diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index 2b106be9e9..eefef45cc3 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -244,9 +244,21 @@ test_PAGER_overrides() { } test_core_pager_overrides() { + if_local_config= + used_if_wanted='overrides PAGER' + test_core_pager "$@" +} + +test_local_config_ignored() { + if_local_config='! ' + used_if_wanted='is not used' + test_core_pager "$@" +} + +test_core_pager() { parse_args "$@" - $test_expectation TTY "$cmd - core.pager overrides PAGER" " + $test_expectation TTY "$cmd - repository-local core.pager setting $used_if_wanted" " unset GIT_PAGER; rm -f core.pager_used || cleanup_fail && @@ -255,14 +267,26 @@ test_core_pager_overrides() { export PAGER && git config core.pager 'wc >core.pager_used' && $full_command && - test -e core.pager_used + ${if_local_config}test -e core.pager_used " } test_core_pager_subdir() { + if_local_config= + used_if_wanted='overrides PAGER' + test_pager_subdir_helper "$@" +} + +test_no_local_config_subdir() { + if_local_config='! ' + used_if_wanted='is not used' + test_pager_subdir_helper "$@" +} + +test_pager_subdir_helper() { parse_args "$@" - $test_expectation TTY "$cmd - core.pager from subdirectory" " + $test_expectation TTY "$cmd - core.pager $used_if_wanted from subdirectory" " unset GIT_PAGER; rm -f core.pager_used && rm -fr sub || @@ -277,7 +301,7 @@ test_core_pager_subdir() { cd sub && $full_command ) && - test -e core.pager_used + ${if_local_config}test -e core.pager_used " } @@ -296,6 +320,20 @@ test_GIT_PAGER_overrides() { " } +test_doesnt_paginate() { + parse_args "$@" + + $test_expectation TTY "no pager for '$cmd'" " + rm -f GIT_PAGER_used || + cleanup_fail && + + GIT_PAGER='wc >GIT_PAGER_used' && + export GIT_PAGER && + $full_command && + ! test -e GIT_PAGER_used + " +} + test_default_pager expect_success 'git log' test_PAGER_overrides expect_success 'git log' test_core_pager_overrides expect_success 'git log' @@ -305,19 +343,15 @@ test_GIT_PAGER_overrides expect_success 'git log' test_default_pager expect_success 'git -p log' test_PAGER_overrides expect_success 'git -p log' test_core_pager_overrides expect_success 'git -p log' -test_core_pager_subdir expect_failure 'git -p log' +test_core_pager_subdir expect_success 'git -p log' test_GIT_PAGER_overrides expect_success 'git -p log' test_default_pager expect_success test_must_fail 'git -p' test_PAGER_overrides expect_success test_must_fail 'git -p' -test_core_pager_overrides expect_success test_must_fail 'git -p' -test_core_pager_subdir expect_failure test_must_fail 'git -p' +test_local_config_ignored expect_failure test_must_fail 'git -p' +test_no_local_config_subdir expect_success test_must_fail 'git -p' test_GIT_PAGER_overrides expect_success test_must_fail 'git -p' -test_default_pager expect_success test_must_fail 'git -p nonsense' -test_PAGER_overrides expect_success test_must_fail 'git -p nonsense' -test_core_pager_overrides expect_success test_must_fail 'git -p nonsense' -test_core_pager_subdir expect_failure test_must_fail 'git -p nonsense' -test_GIT_PAGER_overrides expect_success test_must_fail 'git -p nonsense' +test_doesnt_paginate expect_success test_must_fail 'git -p nonsense' test_done From 5e5ffa091bc272f5034a8e3f2bf9fbb0bd79086c Mon Sep 17 00:00:00 2001 From: Nicolas Sebrecht Date: Fri, 9 Jul 2010 22:27:49 +0200 Subject: [PATCH 05/12] merge-recursive: use "up-to-date" instead of "uptodate" in error message for consistency Signed-off-by: Nicolas Sebrecht Signed-off-by: Junio C Hamano --- merge-recursive.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/merge-recursive.c b/merge-recursive.c index 856e98c083..fb6aa4a551 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1214,7 +1214,7 @@ int merge_trees(struct merge_options *o, } if (sha_eq(common->object.sha1, merge->object.sha1)) { - output(o, 0, "Already uptodate!"); + output(o, 0, "Already up-to-date!"); *result = head; return 1; } From f32e9852d40e26da0c042ca35bf07fa456c9832b Mon Sep 17 00:00:00 2001 From: Will Palmer Date: Wed, 14 Jul 2010 18:04:06 +0100 Subject: [PATCH 06/12] add basic tests for merge-tree merge-tree had no test cases, so here we add some very basic tests for it, including some known-breakages. [jc: with obvious/trivial fixups] Signed-off-by: Will Palmer Signed-off-by: Junio C Hamano --- t/t4300-merge-tree.sh | 257 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100755 t/t4300-merge-tree.sh diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh new file mode 100755 index 0000000000..1eba862369 --- /dev/null +++ b/t/t4300-merge-tree.sh @@ -0,0 +1,257 @@ +#!/bin/sh +# +# Copyright (c) 2010 Will Palmer +# + +test_description='git merge-tree' +. ./test-lib.sh + +test_expect_success setup ' + test_commit "initial" "initial-file" "initial" +' + +test_expect_success 'file add A, !B' ' + cat >expected <<\EXPECTED && +added in remote + their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE +@@ -0,0 +1 @@ ++AAA +EXPECTED + + git reset --hard initial && + test_commit "add-a-not-b" "ONE" "AAA" && + git merge-tree initial initial add-a-not-b >actual && + test_cmp expected actual +' + +test_expect_failure 'file add !A, B' ' + cat >expected <<\EXPECTED && +added in local + our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE +EXPECTED + + git reset --hard initial && + test_commit "add-not-a-b" "ONE" "AAA" && + git merge-tree initial add-not-a-b initial >actual && + test_cmp expected actual +' + +test_expect_success 'file add A, B (same)' ' + cat >expected <<\EXPECTED && +added in both + our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE + their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE +EXPECTED + + git reset --hard initial && + test_commit "add-a-b-same-A" "ONE" "AAA" && + git reset --hard initial && + test_commit "add-a-b-same-B" "ONE" "AAA" && + git merge-tree initial add-a-b-same-A add-a-b-same-B >actual && + test_cmp expected actual +' + +test_expect_success 'file add A, B (different)' ' + cat >expected <<\EXPECTED && +added in both + our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE + their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE +@@ -1 +1,5 @@ ++<<<<<<< .our + AAA ++======= ++BBB ++>>>>>>> .their +EXPECTED + + git reset --hard initial && + test_commit "add-a-b-diff-A" "ONE" "AAA" && + git reset --hard initial && + test_commit "add-a-b-diff-B" "ONE" "BBB" && + git merge-tree initial add-a-b-diff-A add-a-b-diff-B >actual && + test_cmp expected actual +' + +test_expect_success 'file change A, !B' ' + cat >expected <<\EXPECTED && +EXPECTED + + git reset --hard initial && + test_commit "change-a-not-b" "initial-file" "BBB" && + git merge-tree initial change-a-not-b initial >actual && + test_cmp expected actual +' + +test_expect_success 'file change !A, B' ' + cat >expected <<\EXPECTED && +merged + result 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file + our 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file +@@ -1 +1 @@ +-initial ++BBB +EXPECTED + + git reset --hard initial && + test_commit "change-not-a-b" "initial-file" "BBB" && + git merge-tree initial initial change-not-a-b >actual && + test_cmp expected actual +' + +test_expect_success 'file change A, B (same)' ' + cat >expected <<\EXPECTED && +EXPECTED + + git reset --hard initial && + test_commit "change-a-b-same-A" "initial-file" "AAA" && + git reset --hard initial && + test_commit "change-a-b-same-B" "initial-file" "AAA" && + git merge-tree initial change-a-b-same-A change-a-b-same-B >actual && + test_cmp expected actual +' + +test_expect_success 'file change A, B (different)' ' + cat >expected <<\EXPECTED && +changed in both + base 100644 e79c5e8f964493290a409888d5413a737e8e5dd5 initial-file + our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d initial-file + their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 initial-file +@@ -1 +1,5 @@ ++<<<<<<< .our + AAA ++======= ++BBB ++>>>>>>> .their +EXPECTED + + git reset --hard initial && + test_commit "change-a-b-diff-A" "initial-file" "AAA" && + git reset --hard initial && + test_commit "change-a-b-diff-B" "initial-file" "BBB" && + git merge-tree initial change-a-b-diff-A change-a-b-diff-B >actual && + test_cmp expected actual +' + +test_expect_success 'file change A, B (mixed)' ' + cat >expected <<\EXPECTED && +changed in both + base 100644 f4f1f998c7776568c4ff38f516d77fef9399b5a7 ONE + our 100644 af14c2c3475337c73759d561ef70b59e5c731176 ONE + their 100644 372d761493f524d44d59bd24700c3bdf914c973c ONE +@@ -7,7 +7,11 @@ + AAA + AAA + AAA ++<<<<<<< .our + BBB ++======= ++CCC ++>>>>>>> .their + AAA + AAA + AAA +EXPECTED + + git reset --hard initial && + test_commit "change-a-b-mix-base" "ONE" " +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA +AAA" && + test_commit "change-a-b-mix-A" "ONE" \ + "$(sed -e "1{s/AAA/BBB/;}" -e "10{s/AAA/BBB/;}" actual && + test_cmp expected actual +' + +test_expect_success 'file remove A, !B' ' + cat >expected <<\EXPECTED && +removed in local + base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE + their 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE +EXPECTED + + git reset --hard initial && + test_commit "rm-a-not-b-base" "ONE" "AAA" && + git rm ONE && + git commit -m "rm-a-not-b" && + git tag "rm-a-not-b" && + git merge-tree rm-a-not-b-base rm-a-not-b rm-a-not-b-base >actual && + test_cmp expected actual +' + +test_expect_failure 'file remove !A, B' ' + cat >expected <<\EXPECTED && +removed in remote + base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE + our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE +@@ -1 +0,0 @@ +-AAA +EXPECTED + + git reset --hard initial && + test_commit "rm-not-a-b-base" "ONE" "AAA" && + git rm ONE && + git commit -m "rm-not-a-b" && + git tag "rm-not-a-b" && + git merge-tree rm-a-not-b-base rm-a-not-b-base rm-a-not-b >actual && + test_cmp expected actual +' + +test_expect_failure 'file change A, remove B' ' + cat >expected <<\EXPECTED && +removed in remote + base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE + our 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE +@@ -1 +0,0 @@ +-BBB +EXPECTED + + git reset --hard initial && + test_commit "change-a-rm-b-base" "ONE" "AAA" && + test_commit "change-a-rm-b-A" "ONE" "BBB" && + git reset --hard change-a-rm-b-base && + git rm ONE && + git commit -m "change-a-rm-b-B" && + git tag "change-a-rm-b-B" && + git merge-tree change-a-rm-b-base change-a-rm-b-A change-a-rm-b-B \ + >actual && + test_cmp expected actual +' + +test_expect_success 'file remove A, change B' ' + cat >expected <<\EXPECTED && +removed in local + base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE + their 100644 ba629238ca89489f2b350e196ca445e09d8bb834 ONE +EXPECTED + + git reset --hard initial && + test_commit "rm-a-change-b-base" "ONE" "AAA" && + + git rm ONE && + git commit -m "rm-a-change-b-A" && + git tag "rm-a-change-b-A" && + git reset --hard rm-a-change-b-base && + test_commit "rm-a-change-b-B" "ONE" "BBB" && + git merge-tree rm-a-change-b-base rm-a-change-b-A rm-a-change-b-B \ + >actual && + test_cmp expected actual +' + +test_done From 21baa6e0c56d229866c02c4b42b8b53af648d853 Mon Sep 17 00:00:00 2001 From: Will Palmer Date: Wed, 14 Jul 2010 18:04:07 +0100 Subject: [PATCH 07/12] merge-tree: fix where two branches share no changes 15b4f7a (merge-tree: use ll_merge() not xdl_merge(), 2010-01-16) introduced a regression to merge-tree to cause it to segfault when merging files which existed in one branch, but not in the other or in the merge-base. This was caused by referencing entry->path at a time when entry was known to be possibly-NULL. To correct the problem, we save the path of the entry we came in with, as the path should be the same among all the stages no matter which sides are involved in the merge. Signed-off-by: Will Palmer Signed-off-by: Junio C Hamano --- builtin/merge-tree.c | 3 ++- t/t4300-merge-tree.sh | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c index fc00d794d6..9b25ddc979 100644 --- a/builtin/merge-tree.c +++ b/builtin/merge-tree.c @@ -60,6 +60,7 @@ static void *result(struct merge_list *entry, unsigned long *size) { enum object_type type; struct blob *base, *our, *their; + const char *path = entry->path; if (!entry->stage) return read_sha1_file(entry->blob->object.sha1, &type, size); @@ -76,7 +77,7 @@ static void *result(struct merge_list *entry, unsigned long *size) their = NULL; if (entry) their = entry->blob; - return merge_file(entry->path, base, our, their, size); + return merge_file(path, base, our, their, size); } static void *origin(struct merge_list *entry, unsigned long *size) diff --git a/t/t4300-merge-tree.sh b/t/t4300-merge-tree.sh index 1eba862369..46c3fe76d3 100755 --- a/t/t4300-merge-tree.sh +++ b/t/t4300-merge-tree.sh @@ -24,7 +24,7 @@ EXPECTED test_cmp expected actual ' -test_expect_failure 'file add !A, B' ' +test_expect_success 'file add !A, B' ' cat >expected <<\EXPECTED && added in local our 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE @@ -195,7 +195,7 @@ EXPECTED test_cmp expected actual ' -test_expect_failure 'file remove !A, B' ' +test_expect_success 'file remove !A, B' ' cat >expected <<\EXPECTED && removed in remote base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE @@ -213,7 +213,7 @@ EXPECTED test_cmp expected actual ' -test_expect_failure 'file change A, remove B' ' +test_expect_success 'file change A, remove B' ' cat >expected <<\EXPECTED && removed in remote base 100644 43d5a8ed6ef6c00ff775008633f95787d088285d ONE From 3ca399d40ae024a1eaf5c8f71c9cf13da3198cf3 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Wed, 14 Jul 2010 13:18:11 -0400 Subject: [PATCH 08/12] MERGE_RR is in .git, not .git/rr-cache 0af0ac7 (Move MERGE_RR from .git/rr-cache/ into .git/) moved the location of MERGE_RR but I found a few references to the old location. Signed-off-by: Jay Soffian Signed-off-by: Junio C Hamano --- builtin/rerere.c | 2 +- t/t4151-am-abort.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/rerere.c b/builtin/rerere.c index 0048f9ef7f..1207cb1ea5 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -135,7 +135,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) if (!has_rerere_resolution(name)) unlink_rr_item(name); } - unlink_or_warn(git_path("rr-cache/MERGE_RR")); + unlink_or_warn(git_path("MERGE_RR")); } else if (!strcmp(argv[1], "gc")) garbage_collect(&merge_rr); else if (!strcmp(argv[1], "status")) diff --git a/t/t4151-am-abort.sh b/t/t4151-am-abort.sh index 2b912d7728..b55c411788 100755 --- a/t/t4151-am-abort.sh +++ b/t/t4151-am-abort.sh @@ -47,7 +47,7 @@ do test_must_fail git am$with3 --skip >output && test "$(grep "^Applying" output)" = "Applying: 6" && test_cmp file-2-expect file-2 && - test ! -f .git/rr-cache/MERGE_RR + test ! -f .git/MERGE_RR ' test_expect_success "am --abort goes back after failed am$with3" ' @@ -57,7 +57,7 @@ do test_cmp expect actual && test_cmp file-2-expect file-2 && git diff-index --exit-code --cached HEAD && - test ! -f .git/rr-cache/MERGE_RR + test ! -f .git/MERGE_RR ' done From 030149a4dcd584f6b47221f5b087d081e582d790 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Wed, 14 Jul 2010 17:55:12 -0500 Subject: [PATCH 09/12] git --paginate: paginate external commands again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 73e25e7c (git --paginate: do not commit pager choice too early, 2010-06-26) failed to take some cases into account. 1b. Builtins that do not use RUN_SETUP (like git config) do not find GIT_DIR set correctly when the pager is launched from run_builtin(). So the core.pager configuration is not honored from subdirectories of the toplevel for them. 4a. External git commands (like git request-pull) relied on the early pager launch to take care of handling the -p option. Ever since 73e25e7c, they do not honor the -p option at all. 4b. Commands invoked through ! aliases (like ls) were also relying on the early pager launch. Fix (4a) by launching the pager (if requested) before running such a “dashed external”. For simplicity, this still does not search for a .git directory before running the external command; when run from a subdirectory of the toplevel, therefore, the “[core] pager” configuration is still not honored. Fix (4b) by launching pager if requested before carrying out such an alias. Actually doing this has no effect, since the pager (if any) would have already been launched in a failed attempt to try a dashed external first. The choice-of-pager-not-honored-from- subdirectory bug still applies here, too. (1b) is not a regression. There is no need to fix it yet. Noticed by Junio. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- git.c | 3 +++ t/t7006-pager.sh | 45 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/git.c b/git.c index 25e76939e2..99517dd83a 100644 --- a/git.c +++ b/git.c @@ -167,6 +167,7 @@ static int handle_alias(int *argcp, const char ***argv) alias_string = alias_lookup(alias_command); if (alias_string) { if (alias_string[0] == '!') { + commit_pager_choice(); if (*argcp > 1) { struct strbuf buf; @@ -432,6 +433,8 @@ static void execv_dashed_external(const char **argv) const char *tmp; int status; + commit_pager_choice(); + strbuf_addf(&cmd, "git-%s", argv[0]); /* diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index eefef45cc3..9215c2ff56 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -334,17 +334,40 @@ test_doesnt_paginate() { " } -test_default_pager expect_success 'git log' -test_PAGER_overrides expect_success 'git log' -test_core_pager_overrides expect_success 'git log' -test_core_pager_subdir expect_success 'git log' -test_GIT_PAGER_overrides expect_success 'git log' +test_pager_choices() { + test_default_pager expect_success "$@" + test_PAGER_overrides expect_success "$@" + test_core_pager_overrides expect_success "$@" + test_core_pager_subdir expect_success "$@" + test_GIT_PAGER_overrides expect_success "$@" +} -test_default_pager expect_success 'git -p log' -test_PAGER_overrides expect_success 'git -p log' -test_core_pager_overrides expect_success 'git -p log' -test_core_pager_subdir expect_success 'git -p log' -test_GIT_PAGER_overrides expect_success 'git -p log' +test_expect_success 'setup: some aliases' ' + git config alias.aliasedlog log && + git config alias.true "!true" +' + +test_pager_choices 'git log' +test_pager_choices 'git -p log' +test_pager_choices 'git aliasedlog' + +test_default_pager expect_success 'git -p aliasedlog' +test_PAGER_overrides expect_success 'git -p aliasedlog' +test_core_pager_overrides expect_success 'git -p aliasedlog' +test_core_pager_subdir expect_failure 'git -p aliasedlog' +test_GIT_PAGER_overrides expect_success 'git -p aliasedlog' + +test_default_pager expect_success 'git -p true' +test_PAGER_overrides expect_success 'git -p true' +test_core_pager_overrides expect_success 'git -p true' +test_core_pager_subdir expect_failure 'git -p true' +test_GIT_PAGER_overrides expect_success 'git -p true' + +test_default_pager expect_success test_must_fail 'git -p request-pull' +test_PAGER_overrides expect_success test_must_fail 'git -p request-pull' +test_core_pager_overrides expect_success test_must_fail 'git -p request-pull' +test_core_pager_subdir expect_failure test_must_fail 'git -p request-pull' +test_GIT_PAGER_overrides expect_success test_must_fail 'git -p request-pull' test_default_pager expect_success test_must_fail 'git -p' test_PAGER_overrides expect_success test_must_fail 'git -p' @@ -352,6 +375,6 @@ test_local_config_ignored expect_failure test_must_fail 'git -p' test_no_local_config_subdir expect_success test_must_fail 'git -p' test_GIT_PAGER_overrides expect_success test_must_fail 'git -p' -test_doesnt_paginate expect_success test_must_fail 'git -p nonsense' +test_doesnt_paginate expect_failure test_must_fail 'git -p nonsense' test_done From 109988f2cb00f78b746d05c40b8a8960bbb12ff8 Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Thu, 15 Jul 2010 12:59:01 +0530 Subject: [PATCH 10/12] gitweb: fix esc_url Earlier, 452e225 (gitweb: fix esc_param, 2009-10-13) fixed CGI escaping rules used in esc_url. A very similar logic exists in esc_param and needs to be fixed the same way. Signed-off-by: Pavan Kumar Sunkara Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index c356e95f18..a97ce03444 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1173,8 +1173,7 @@ sub esc_param { sub esc_url { my $str = shift; return undef unless defined $str; - $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg; - $str =~ s/\+/%2B/g; + $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&= ]+)/CGI::escape($1)/eg; $str =~ s/ /\+/g; return $str; } From 47dc5d5fda291bc399da54648ca27e8df4ddfd2c Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Thu, 15 Jul 2010 02:41:55 -0500 Subject: [PATCH 11/12] gitmodules.5: url can be a relative path There is already excellent documentation for this facility in git-submodule.1, but it is not so discoverable. Relative paths in .gitmodules can be useful for serving the same repository over multiple protocols, for example. Thanks to Peter for pointing this out. Cc: Peter Krefting Signed-off-by: Jonathan Nieder Acked-by: Johan Herland Signed-off-by: Junio C Hamano --- Documentation/gitmodules.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt index 5daf750d19..72a13d18e0 100644 --- a/Documentation/gitmodules.txt +++ b/Documentation/gitmodules.txt @@ -29,6 +29,9 @@ submodule..path:: submodule..url:: Defines an url from where the submodule repository can be cloned. + This may be either an absolute URL ready to be passed to + linkgit:git-clone[1] or (if it begins with ./ or ../) a location + relative to the superproject's origin repository. submodule..update:: Defines what to do when the submodule is updated by the superproject. From 0ad0a61f05fe521a63ade9bfafd2f589fba0df33 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Thu, 15 Jul 2010 02:51:19 -0500 Subject: [PATCH 12/12] Documentation: add submodule.* to the big configuration variable list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The url, path, and the update items in [submodule "foo"] stanzas are nicely explained in the .gitmodules and ‘git submodule’ documentation. Point there from the config documentation. Signed-off-by: Jonathan Nieder Acked-by: Johan Herland Signed-off-by: Junio C Hamano --- Documentation/config.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index 1029bc46ca..eae06e7c3e 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1685,6 +1685,15 @@ status.submodulesummary:: summary of commits for modified submodules will be shown (see --summary-limit option of linkgit:git-submodule[1]). +submodule..path:: +submodule..url:: +submodule..update:: + The path within this project, URL, and the updating strategy + for a submodule. These variables are initially populated + by 'git submodule init'; edit them to override the + URL and other values found in the `.gitmodules` file. See + linkgit:git-submodule[1] and linkgit:gitmodules[5] for details. + tar.umask:: This variable can be used to restrict the permission bits of tar archive entries. The default is 0002, which turns off the