From: Junio C Hamano Date: Wed, 14 May 2008 20:45:16 +0000 (-0700) Subject: Merge branch 'bd/tests' X-Git-Tag: v1.5.6-rc0~57 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/761adeb4dba3305d0810b5340a71783d29484fb0?hp=-c Merge branch 'bd/tests' * bd/tests: Rename the test trash directory to contain spaces. Fix tests breaking when checkout path contains shell metacharacters Don't use the 'export NAME=value' in the test scripts. lib-git-svn.sh: Fix quoting issues with paths containing shell metacharacters test-lib.sh: Fix some missing path quoting Use test_set_editor in t9001-send-email.sh test-lib.sh: Add a test_set_editor function to safely set $VISUAL git-send-email.perl: Handle shell metacharacters in $EDITOR properly config.c: Escape backslashes in section names properly git-rebase.sh: Fix --merge --abort failures when path contains whitespace Conflicts: t/t9115-git-svn-dcommit-funky-renames.sh --- 761adeb4dba3305d0810b5340a71783d29484fb0 diff --combined config.c index 0e22c7a642,f0ac4569a3..e42ada78f8 --- a/config.c +++ b/config.c @@@ -350,11 -350,6 +350,11 @@@ int git_default_config(const char *var return 0; } + if (!strcmp(var, "core.ignorecase")) { + ignore_case = git_config_bool(var, value); + return 0; + } + if (!strcmp(var, "core.bare")) { is_bare_repository_cfg = git_config_bool(var, value); return 0; @@@ -492,21 -487,6 +492,21 @@@ git_branch_track = git_config_bool(var, value); return 0; } + if (!strcmp(var, "branch.autosetuprebase")) { + if (!value) + return config_error_nonbool(var); + else if (!strcmp(value, "never")) + autorebase = AUTOREBASE_NEVER; + else if (!strcmp(value, "local")) + autorebase = AUTOREBASE_LOCAL; + else if (!strcmp(value, "remote")) + autorebase = AUTOREBASE_REMOTE; + else if (!strcmp(value, "always")) + autorebase = AUTOREBASE_ALWAYS; + else + return error("Malformed value for %s", var); + return 0; + } /* Add other config variables here and to Documentation/config.txt. */ return 0; @@@ -627,9 -607,11 +627,9 @@@ static int store_aux(const char* key, c case KEY_SEEN: if (matches(key, value)) { if (store.seen == 1 && store.multi_replace == 0) { - fprintf(stderr, - "Warning: %s has multiple values\n", - key); + warning("%s has multiple values", key); } else if (store.seen >= MAX_MATCHES) { - fprintf(stderr, "Too many matches\n"); + error("too many matches for %s", key); return 1; } @@@ -679,9 -661,9 +679,9 @@@ return 0; } -static int write_error(void) +static int write_error(const char *filename) { - fprintf(stderr, "Failed to write new configuration file\n"); + error("failed to write new configuration file %s", filename); /* Same error code as "failed to rename". */ return 4; @@@ -698,7 -680,7 +698,7 @@@ static int store_write_section(int fd, if (dot) { strbuf_addf(&sb, "[%.*s \"", (int)(dot - key), key); for (i = dot - key + 1; i < store.baselen; i++) { - if (key[i] == '"') + if (key[i] == '"' || key[i] == '\\') strbuf_addch(&sb, '\\'); strbuf_addch(&sb, key[i]); } @@@ -840,7 -822,7 +840,7 @@@ int git_config_set_multivar(const char */ if (last_dot == NULL) { - fprintf(stderr, "key does not contain a section: %s\n", key); + error("key does not contain a section: %s", key); ret = 2; goto out_free; } @@@ -860,14 -842,14 +860,14 @@@ /* Leave the extended basename untouched.. */ if (!dot || i > store.baselen) { if (!iskeychar(c) || (i == store.baselen+1 && !isalpha(c))) { - fprintf(stderr, "invalid key: %s\n", key); + error("invalid key: %s", key); free(store.key); ret = 1; goto out_free; } c = tolower(c); } else if (c == '\n') { - fprintf(stderr, "invalid key (newline): %s\n", key); + error("invalid key (newline): %s", key); free(store.key); ret = 1; goto out_free; @@@ -883,7 -865,7 +883,7 @@@ lock = xcalloc(sizeof(struct lock_file), 1); fd = hold_lock_file_for_update(lock, config_filename, 0); if (fd < 0) { - fprintf(stderr, "could not lock config file\n"); + error("could not lock config file %s", config_filename); free(store.key); ret = -1; goto out_free; @@@ -930,7 -912,8 +930,7 @@@ store.value_regex = (regex_t*)xmalloc(sizeof(regex_t)); if (regcomp(store.value_regex, value_regex, REG_EXTENDED)) { - fprintf(stderr, "Invalid pattern: %s\n", - value_regex); + error("invalid pattern: %s", value_regex); free(store.value_regex); ret = 6; goto out_free; @@@ -948,7 -931,7 +948,7 @@@ * existing config file. */ if (git_config_from_file(store_aux, config_filename)) { - fprintf(stderr, "invalid config file\n"); + error("invalid config file %s", config_filename); free(store.key); if (store.value_regex != NULL) { regfree(store.value_regex); @@@ -1027,7 -1010,7 +1027,7 @@@ } if (commit_lock_file(lock) < 0) { - fprintf(stderr, "Cannot commit config file!\n"); + error("could not commit config file %s", config_filename); ret = 4; goto out_free; } @@@ -1048,7 -1031,7 +1048,7 @@@ out_free return ret; write_err_out: - ret = write_error(); + ret = write_error(lock->filename); goto out_free; } @@@ -1098,7 -1081,7 +1098,7 @@@ int git_config_rename_section(const cha config_filename = xstrdup(config_filename); out_fd = hold_lock_file_for_update(lock, config_filename, 0); if (out_fd < 0) { - ret = error("Could not lock config file!"); + ret = error("could not lock config file %s", config_filename); goto out; } @@@ -1122,7 -1105,7 +1122,7 @@@ } store.baselen = strlen(new_name); if (!store_write_section(out_fd, new_name)) { - ret = write_error(); + ret = write_error(lock->filename); goto out; } continue; @@@ -1133,14 -1116,14 +1133,14 @@@ continue; length = strlen(buf); if (write_in_full(out_fd, buf, length) != length) { - ret = write_error(); + ret = write_error(lock->filename); goto out; } } fclose(config_file); unlock_and_out: if (commit_lock_file(lock) < 0) - ret = error("Cannot commit config file!"); + ret = error("could not commit config file %s", config_filename); out: free(config_filename); return ret; diff --combined git-rebase.sh index fbb0f288b3,c43afe51ab..68855c18ae --- a/git-rebase.sh +++ b/git-rebase.sh @@@ -214,7 -214,7 +214,7 @@@ d else die "No rebase in progress?" fi - git reset --hard $(cat $dotest/orig-head) + git reset --hard $(cat "$dotest/orig-head") rm -r "$dotest" exit ;; @@@ -353,7 -353,7 +353,7 @@@ orig_head=$branc mb=$(git merge-base "$onto" "$branch") if test "$upstream" = "$onto" && test "$mb" = "$onto" && # linear history? - ! git rev-list --parents "$onto".."$branch" | grep " .* " > /dev/null + ! (git rev-list --parents "$onto".."$branch" | grep " .* ") > /dev/null then # Lazily switch to the target branch if needed... test -z "$switch_to" || git checkout "$switch_to" diff --combined git-send-email.perl index cb05cf5b9e,b50239636d..1e1d98656d --- a/git-send-email.perl +++ b/git-send-email.perl @@@ -203,7 -203,6 +203,7 @@@ my %config_settings = "smtpuser" => \$smtp_authuser, "smtppass" => \$smtp_authpass, "to" => \@to, + "cc" => \@initial_cc, "cccmd" => \$cc_cmd, "aliasfiletype" => \$aliasfiletype, "bcc" => \@bcclist, @@@ -513,7 -512,7 +513,7 @@@ EO close(C); my $editor = $ENV{GIT_EDITOR} || Git::config(@repo, "core.editor") || $ENV{VISUAL} || $ENV{EDITOR} || "vi"; - system('sh', '-c', '$0 $@', $editor, $compose_filename); + system('sh', '-c', $editor.' "$@"', $editor, $compose_filename); open(C2,">",$compose_filename . ".final") or die "Failed to open $compose_filename.final : " . $!; diff --combined t/lib-git-svn.sh index d8f3355791,445df78cac..5d3bd9dda9 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@@ -20,12 -20,13 +20,13 @@@ the fi svnrepo=$PWD/svnrepo + export svnrepo perl -w -e " use SVN::Core; use SVN::Repos; \$SVN::Core::VERSION gt '1.1.0' or exit(42); - system(qw/svnadmin create --fs-type fsfs/, '$svnrepo') == 0 or exit(41); + system(qw/svnadmin create --fs-type fsfs/, \$ENV{svnrepo}) == 0 or exit(41); " >&3 2>&4 x=$? if test $x -ne 0 @@@ -73,16 -74,11 +74,16 @@@ for d in done start_httpd () { + repo_base_path="$1" if test -z "$SVN_HTTPD_PORT" then echo >&2 'SVN_HTTPD_PORT is not defined!' return fi + if test -z "$repo_base_path" + then + repo_base_path=svn + fi mkdir "$GIT_DIR"/logs @@@ -95,13 -91,13 +96,13 @@@ LockFile logs/accept.loc Listen 127.0.0.1:$SVN_HTTPD_PORT LoadModule dav_module $SVN_HTTPD_MODULE_PATH/mod_dav.so LoadModule dav_svn_module $SVN_HTTPD_MODULE_PATH/mod_dav_svn.so - + DAV svn SVNPath $rawsvnrepo EOF "$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k start - svnrepo=http://127.0.0.1:$SVN_HTTPD_PORT/svn + svnrepo="http://127.0.0.1:$SVN_HTTPD_PORT/$repo_base_path" } stop_httpd () { diff --combined t/t3400-rebase.sh index fdad7dad61,10d7449b54..91bb5e1d9e --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@@ -9,7 -9,8 +9,8 @@@ This test runs git rebase and checks th ' . ./test-lib.sh - export GIT_AUTHOR_EMAIL=bogus_email_address + GIT_AUTHOR_EMAIL=bogus_email_address + export GIT_AUTHOR_EMAIL test_expect_success \ 'prepare repository with topic branches' \ @@@ -44,13 -45,13 +45,13 @@@ test_expect_success 'rebase against mas test_expect_success \ 'the rebase operation should not have destroyed author information' \ - '! git log | grep "Author:" | grep "<>"' + '! (git log | grep "Author:" | grep "<>")' test_expect_success 'rebase after merge master' ' git reset --hard topic && git merge master && git rebase master && - ! git show | grep "^Merge:" + ! (git show | grep "^Merge:") ' test_expect_success 'rebase of history with merges is linearized' ' diff --combined t/t6200-fmt-merge-msg.sh index bd4e49bf1e,9c0b92632c..c9bf6fdba3 --- a/t/t6200-fmt-merge-msg.sh +++ b/t/t6200-fmt-merge-msg.sh @@@ -82,14 -82,14 +82,14 @@@ test_expect_success 'merge-msg test #1 git diff actual expected ' - cat >expected <<\EOF - Merge branch 'left' of ../trash + cat >expected <actual && git diff actual expected @@@ -106,24 -106,8 +106,24 @@@ Merge branch 'left Common #1 EOF -test_expect_success 'merge-msg test #3' ' +test_expect_success 'merge-msg test #3-1' ' + git config --unset-all merge.log + git config --unset-all merge.summary + git config merge.log true && + + git checkout master && + setdate && + git fetch . left && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + git diff actual expected +' + +test_expect_success 'merge-msg test #3-2' ' + + git config --unset-all merge.log + git config --unset-all merge.summary git config merge.summary true && git checkout master && @@@ -152,24 -136,8 +152,24 @@@ Merge branches 'left' and 'right Common #1 EOF -test_expect_success 'merge-msg test #4' ' +test_expect_success 'merge-msg test #4-1' ' + + git config --unset-all merge.log + git config --unset-all merge.summary + git config merge.log true && + + git checkout master && + setdate && + git fetch . left right && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + git diff actual expected +' + +test_expect_success 'merge-msg test #4-2' ' + git config --unset-all merge.log + git config --unset-all merge.summary git config merge.summary true && git checkout master && @@@ -180,24 -148,8 +180,24 @@@ git diff actual expected ' -test_expect_success 'merge-msg test #5' ' +test_expect_success 'merge-msg test #5-1' ' + + git config --unset-all merge.log + git config --unset-all merge.summary + git config merge.log yes && + + git checkout master && + setdate && + git fetch . left right && + + git fmt-merge-msg <.git/FETCH_HEAD >actual && + git diff actual expected +' + +test_expect_success 'merge-msg test #5-2' ' + git config --unset-all merge.log + git config --unset-all merge.summary git config merge.summary yes && git checkout master && diff --combined t/t7003-filter-branch.sh index 16df3d4adb,fd09030208..1639c7aa96 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@@ -125,7 -125,7 +125,7 @@@ test_expect_success 'use index-filter t "git ls-files -s | sed \"s-\\t-&newsubdir/-\" | GIT_INDEX_FILE=\$GIT_INDEX_FILE.new \ git update-index --index-info && - mv \$GIT_INDEX_FILE.new \$GIT_INDEX_FILE" directorymoved && + mv \"\$GIT_INDEX_FILE.new\" \"\$GIT_INDEX_FILE\"" directorymoved && test -z "$(git diff HEAD directorymoved:newsubdir)"' test_expect_success 'stops when msg filter fails' ' @@@ -219,36 -219,4 +219,36 @@@ test_expect_success 'Subdirectory filte test $(git rev-list master | wc -l) = 3 ' +test_expect_success 'Tag name filtering retains tag message' ' + git tag -m atag T && + git cat-file tag T > expect && + git filter-branch -f --tag-name-filter cat && + git cat-file tag T > actual && + git diff expect actual +' + +faux_gpg_tag='object XXXXXX +type commit +tag S +tagger T A Gger 1206026339 -0500 + +This is a faux gpg signed tag. +-----BEGIN PGP SIGNATURE----- +Version: FauxGPG v0.0.0 (FAUX/Linux) + +gdsfoewhxu/6l06f1kxyxhKdZkrcbaiOMtkJUA9ITAc1mlamh0ooasxkH1XwMbYQ +acmwXaWET20H0GeAGP+7vow= +=agpO +-----END PGP SIGNATURE----- +' +test_expect_success 'Tag name filtering strips gpg signature' ' + sha1=$(git rev-parse HEAD) && + sha1t=$(echo "$faux_gpg_tag" | sed -e s/XXXXXX/$sha1/ | git mktag) && + git update-ref "refs/tags/S" "$sha1t" && + echo "$faux_gpg_tag" | sed -e s/XXXXXX/$sha1/ | head -n 6 > expect && + git filter-branch -f --tag-name-filter cat && + git cat-file tag S > actual && + git diff expect actual +' + test_done diff --combined t/t7501-commit.sh index 89710afcb5,e5fdb63851..d3370ff7ff --- a/t/t7501-commit.sh +++ b/t/t7501-commit.sh @@@ -41,7 -41,7 +41,7 @@@ test_expect_success test_expect_success \ "using paths with --interactive" \ "echo bong-o-bong >file && - ! echo 7 | git-commit -m foo --interactive file" + ! (echo 7 | git-commit -m foo --interactive file)" test_expect_success \ "using invalid commit with -C" \ @@@ -79,8 -79,8 +79,8 @@@ test_expect_success cat >editor <<\EOF #!/bin/sh - sed -e "s/a file/an amend commit/g" < $1 > $1- - mv $1- $1 + sed -e "s/a file/an amend commit/g" < "$1" > "$1-" + mv "$1-" "$1" EOF chmod 755 editor @@@ -99,8 -99,8 +99,8 @@@ test_expect_success cat >editor <<\EOF #!/bin/sh - sed -e "s/amend/older/g" < $1 > $1- - mv $1- $1 + sed -e "s/amend/older/g" < "$1" > "$1-" + mv "$1-" "$1" EOF chmod 755 editor diff --combined t/t9001-send-email.sh index af655cf526,0a65785573..04baa61c04 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@@ -139,15 -139,16 +139,16 @@@ test_expect_success 'Valid In-Reply-To test_expect_success 'setup fake editor' ' (echo "#!/bin/sh" && - echo "echo fake edit >>\$1" + echo "echo fake edit >>\"\$1\"" ) >fake-editor && chmod +x fake-editor ' + test_set_editor "$(pwd)/fake-editor" + test_expect_success '--compose works' ' clean_fake_sendmail && echo y | \ - GIT_EDITOR=$(pwd)/fake-editor \ GIT_SEND_EMAIL_NOTTY=1 \ git send-email \ --compose --subject foo \ @@@ -166,70 -167,4 +167,70 @@@ test_expect_success 'second message is grep "Subject:.*Second" msgtxt2 ' +cat >expected-show-all-headers <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:,, +From: Example +To: to@example.com +Cc: cc@example.com, A +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success 'sendemail.cc set' ' + git config sendemail.cc cc@example.com && + git send-email \ + --dry-run \ + --from="Example " \ + --to=to@example.com \ + --smtp-server relay.example.com \ + $patches | + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ + >actual-show-all-headers && + test_cmp expected-show-all-headers actual-show-all-headers +' + +cat >expected-show-all-headers <<\EOF +0001-Second.patch +(mbox) Adding cc: A from line 'From: A ' +Dry-OK. Log says: +Server: relay.example.com +MAIL FROM: +RCPT TO:, +From: Example +To: to@example.com +Cc: A +Subject: [PATCH 1/1] Second. +Date: DATE-STRING +Message-Id: MESSAGE-ID-STRING +X-Mailer: X-MAILER-STRING + +Result: OK +EOF + +test_expect_success 'sendemail.cc unset' ' + git config --unset sendemail.cc && + git send-email \ + --dry-run \ + --from="Example " \ + --to=to@example.com \ + --smtp-server relay.example.com \ + $patches | + sed -e "s/^\(Date:\).*/\1 DATE-STRING/" \ + -e "s/^\(Message-Id:\).*/\1 MESSAGE-ID-STRING/" \ + -e "s/^\(X-Mailer:\).*/\1 X-MAILER-STRING/" \ + >actual-show-all-headers && + test_cmp expected-show-all-headers actual-show-all-headers +' + test_done diff --combined t/t9115-git-svn-dcommit-funky-renames.sh index 4acbcb0acd,298445f7d9..f0fbd3aff7 --- a/t/t9115-git-svn-dcommit-funky-renames.sh +++ b/t/t9115-git-svn-dcommit-funky-renames.sh @@@ -7,16 -7,16 +7,16 @@@ test_description='git-svn dcommit can c . ./lib-git-svn.sh - test_expect_success 'load repository with strange names' " - svnadmin load -q $rawsvnrepo < ../t9115/funky-names.dump && + test_expect_success 'load repository with strange names' ' + svnadmin load -q "$rawsvnrepo" < ../t9115/funky-names.dump && - start_httpd + start_httpd gtk+ - " + ' - test_expect_success 'init and fetch repository' " - git svn init $svnrepo && + test_expect_success 'init and fetch repository' ' + git svn init "$svnrepo" && git svn fetch && git reset --hard git-svn - " + ' test_expect_success 'create file in existing ugly and empty dir' ' mkdir "#{bad_directory_name}" && @@@ -49,39 -49,6 +49,39 @@@ test_expect_success 'rename pretty fil git svn dcommit ' +test_expect_success 'add a file with plus signs' ' + echo .. > +_+ && + git update-index --add +_+ && + git commit -m plus && + mkdir gtk+ && + git mv +_+ gtk+/_+_ && + git commit -m plus_dir && + git svn dcommit + ' + - test_expect_success 'clone the repository to test rebase' " - git svn clone $svnrepo test-rebase && ++test_expect_success 'clone the repository to test rebase' ' ++ git svn clone "$svnrepo" test-rebase && + cd test-rebase && + echo test-rebase > test-rebase && + git add test-rebase && + git commit -m test-rebase && + cd .. - " ++ ' + - test_expect_success 'make a commit to test rebase' " ++test_expect_success 'make a commit to test rebase' ' + echo test-rebase-main > test-rebase-main && + git add test-rebase-main && + git commit -m test-rebase-main && + git svn dcommit - " ++ ' + - test_expect_success 'git-svn rebase works inside a fresh-cloned repository' " ++test_expect_success 'git-svn rebase works inside a fresh-cloned repository' ' + cd test-rebase && + git svn rebase && + test -e test-rebase-main && + test -e test-rebase - " ++ ' + stop_httpd test_done