From 4201bb5f7e408143dc5bf35497cc82bc803fe9fb Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sat, 1 Mar 2008 11:32:14 +0100 Subject: git rebase --abort: always restore the right commit Previously, --abort would end by git resetting to ORIG_HEAD, but some commands, such as git reset --hard (which happened in git rebase --skip, but could just as well be typed by the user), would have already modified ORIG_HEAD. Just use the orig-head we store in $dotest instead. [jc: cherry-picked from 48411d and 4947cf9 on 'master'] Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano diff --git a/git-rebase.sh b/git-rebase.sh index bdcea0e..6b9af96 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -208,16 +208,15 @@ do if test -d "$dotest" then move_to_original_branch - rm -r "$dotest" elif test -d .dotest then dotest=.dotest move_to_original_branch - rm -r .dotest else die "No rebase in progress?" fi - git reset --hard ORIG_HEAD + git reset --hard $(cat $dotest/orig-head) + rm -r "$dotest" exit ;; --onto) diff --git a/t/t3407-rebase-abort.sh b/t/t3407-rebase-abort.sh new file mode 100755 index 0000000..37944c3 --- /dev/null +++ b/t/t3407-rebase-abort.sh @@ -0,0 +1,71 @@ +#!/bin/sh + +test_description='git rebase --abort tests' + +. ./test-lib.sh + +test_expect_success setup ' + echo a > a && + git add a && + git commit -m a && + git branch to-rebase && + + echo b > a && + git commit -a -m b && + echo c > a && + git commit -a -m c && + + git checkout to-rebase && + echo d > a && + git commit -a -m "merge should fail on this" && + echo e > a && + git commit -a -m "merge should fail on this, too" && + git branch pre-rebase +' + +testrebase() { + type=$1 + dotest=$2 + + test_expect_success "rebase$type --abort" ' + # Clean up the state from the previous one + git reset --hard pre-rebase + test_must_fail git rebase'"$type"' master && + test -d '$dotest' && + git rebase --abort && + test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test ! -d '$dotest' + ' + + test_expect_success "rebase$type --abort after --skip" ' + # Clean up the state from the previous one + git reset --hard pre-rebase + test_must_fail git rebase'"$type"' master && + test -d '$dotest' && + test_must_fail git rebase --skip && + test $(git rev-parse HEAD) = $(git rev-parse master) && + git-rebase --abort && + test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test ! -d '$dotest' + ' + + test_expect_success "rebase$type --abort after --continue" ' + # Clean up the state from the previous one + git reset --hard pre-rebase + test_must_fail git rebase'"$type"' master && + test -d '$dotest' && + echo c > a && + echo d >> a && + git add a && + test_must_fail git rebase --continue && + test $(git rev-parse HEAD) != $(git rev-parse master) && + git rebase --abort && + test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase) && + test ! -d '$dotest' + ' +} + +testrebase "" .dotest +testrebase " --merge" .git/.dotest-merge + +test_done -- cgit v0.10.2-6-g49f6 From fc99469a2b786676ffe48d5966d71cea3613b716 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 11 Mar 2008 10:56:30 +0100 Subject: launch_editor(): allow spaces in the filename The construct sh -c "$0 \"$@\"" does not pick up quotes in , so you cannot give path to the editor that has a shell IFS whitespace in it, and also give it initial set of parameters and flags. Replace $0 with to fix this issue. This fixes git config core.editor '"c:/Program Files/What/Ever.exe"' In other words, you can specify an editor with spaces in its path using a config containing something like this: [core] editor = \"c:/Program Files/Darn/Spaces.exe\" NOTE: we cannot just replace the $0 with \"$0\", because we still want this to work: [core] editor = emacs -nw Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano diff --git a/builtin-tag.c b/builtin-tag.c index 4a4a88c..9a59caf 100644 --- a/builtin-tag.c +++ b/builtin-tag.c @@ -50,12 +50,15 @@ void launch_editor(const char *path, struct strbuf *buffer, const char *const *e size_t len = strlen(editor); int i = 0; const char *args[6]; + struct strbuf arg0; + strbuf_init(&arg0, 0); if (strcspn(editor, "$ \t'") != len) { /* there are specials */ + strbuf_addf(&arg0, "%s \"$@\"", editor); args[i++] = "sh"; args[i++] = "-c"; - args[i++] = "$0 \"$@\""; + args[i++] = arg0.buf; } args[i++] = editor; args[i++] = path; @@ -63,6 +66,7 @@ void launch_editor(const char *path, struct strbuf *buffer, const char *const *e if (run_command_v_opt_cd_env(args, 0, NULL, env)) die("There was a problem with the editor %s.", editor); + strbuf_release(&arg0); } if (!buffer) diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh index c1cec55..6a74b3a 100755 --- a/t/t7005-editor.sh +++ b/t/t7005-editor.sh @@ -89,6 +89,33 @@ do ' done +test_expect_success 'editor with a space' ' + + if echo "echo space > \"\$1\"" > "e space.sh" + then + chmod a+x "e space.sh" && + GIT_EDITOR="./e\ space.sh" git commit --amend && + test space = "$(git show -s --pretty=format:%s)" + else + say "Skipping; FS does not support spaces in filenames" + fi + +' + +unset GIT_EDITOR +test_expect_success 'core.editor with a space' ' + + if test -f "e space.sh" + then + git config core.editor \"./e\ space.sh\" && + git commit --amend && + test space = "$(git show -s --pretty=format:%s)" + else + say "Skipping; FS does not support spaces in filenames" + fi + +' + TERM="$OLD_TERM" test_done -- cgit v0.10.2-6-g49f6 From 7339eb082343df556c27fb0df5dd36a21714284e Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 11 Mar 2008 13:40:45 -0400 Subject: t0021: tr portability fix for Solaris Solaris' /usr/bin/tr doesn't seem to like multiple character ranges in brackets (it simply prints "Bad string"). Instead, let's just enumerate the transformation we want. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh index cb86029..8fc39d7 100755 --- a/t/t0021-conversion.sh +++ b/t/t0021-conversion.sh @@ -5,7 +5,9 @@ test_description='blob conversion via gitattributes' . ./test-lib.sh cat <<\EOF >rot13.sh -tr '[a-zA-Z]' '[n-za-mN-ZA-M]' +tr \ + 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \ + 'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM' EOF chmod +x rot13.sh -- cgit v0.10.2-6-g49f6 From ea14e6c55427f50f78fe47187cd4edb9845943a1 Mon Sep 17 00:00:00 2001 From: Marc-Andre Lureau Date: Tue, 11 Mar 2008 10:00:45 +0200 Subject: git-svn: fix find-rev error message when missing arg Just let the user know that a revision argument is missing instead of a perl error. This error message mimic the "init" error message, but could be improved. Signed-off-by: Marc-Andre Lureau Acked-by: Eric Wong Signed-off-by: Junio C Hamano diff --git a/git-svn.perl b/git-svn.perl index 29f39c0..38e1d59 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -519,7 +519,8 @@ sub cmd_dcommit { } sub cmd_find_rev { - my $revision_or_hash = shift; + my $revision_or_hash = shift or die "SVN or git revision required ", + "as a command-line argument\n"; my $result; if ($revision_or_hash =~ /^r\d+$/) { my $head = shift; -- cgit v0.10.2-6-g49f6