Code

Merge branch 'ks/blame-worktree-textconv-cached' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 28 Dec 2010 21:44:58 +0000 (13:44 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Dec 2010 21:44:58 +0000 (13:44 -0800)
* ks/blame-worktree-textconv-cached:
  fill_textconv(): Don't get/put cache if sha1 is not valid
  t/t8006: Demonstrate blame is broken when cachetextconv is on

git-am.sh
t/t0050-filesystem.sh
t/t3404-rebase-interactive.sh
t/t3419-rebase-patch-id.sh
t/t4151-am-abort.sh
t/t5407-post-rewrite-hook.sh
t/test-lib.sh
wt-status.c
xdiff-interface.c

index de116a29ef091a23f60603a28f1260ba60f054ac..f4db17d93424c18c1db53e9bf84cdeee8219fa10 100755 (executable)
--- a/git-am.sh
+++ b/git-am.sh
@@ -68,9 +68,31 @@ sq () {
 
 stop_here () {
     echo "$1" >"$dotest/next"
+    git rev-parse --verify -q HEAD >"$dotest/abort-safety"
     exit 1
 }
 
+safe_to_abort () {
+       if test -f "$dotest/dirtyindex"
+       then
+               return 1
+       fi
+
+       if ! test -s "$dotest/abort-safety"
+       then
+               return 0
+       fi
+
+       abort_safety=$(cat "$dotest/abort-safety")
+       if test "z$(git rev-parse --verify -q HEAD)" = "z$abort_safety"
+       then
+               return 0
+       fi
+       echo >&2 "You seem to have moved HEAD since the last 'am' failure."
+       echo >&2 "Not rewinding to ORIG_HEAD"
+       return 1
+}
+
 stop_here_user_resolve () {
     if [ -n "$resolvemsg" ]; then
            printf '%s\n' "$resolvemsg"
@@ -419,10 +441,11 @@ then
                        exec git rebase --abort
                fi
                git rerere clear
-               test -f "$dotest/dirtyindex" || {
+               if safe_to_abort
+               then
                        git read-tree --reset -u HEAD ORIG_HEAD
                        git reset ORIG_HEAD
-               }
+               fi
                rm -fr "$dotest"
                exit ;;
        esac
@@ -554,13 +577,6 @@ then
        resume=
 fi
 
-if test "$this" -gt "$last"
-then
-       say Nothing to do.
-       rm -fr "$dotest"
-       exit
-fi
-
 while test "$this" -le "$last"
 do
        msgnum=`printf "%0${prec}d" $this`
index 41df6bcf279a1abc4462e63866076094cfbdedd8..07357ee1fc2902d72cd4f524404862036d06f613 100755 (executable)
@@ -4,8 +4,8 @@ test_description='Various filesystem issues'
 
 . ./test-lib.sh
 
-auml=`printf '\xc3\xa4'`
-aumlcdiar=`printf '\x61\xcc\x88'`
+auml=$(printf '\303\244')
+aumlcdiar=$(printf '\141\314\210')
 
 case_insensitive=
 unibad=
index 7d20a74c5ca1331ff241d1596bcb114e48a5907d..9e9474e9447c8835eb4ef30714b577896a06924d 100755 (executable)
@@ -67,8 +67,9 @@ test_expect_success 'setup' '
 # "exec" commands are ran with the user shell by default, but this may
 # be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
 # to create a file. Unseting SHELL avoids such non-portable behavior
-# in tests.
+# in tests. It must be exported for it to take effect where needed.
 SHELL=
+export SHELL
 
 test_expect_success 'rebase -i with the exec command' '
        git checkout master &&
index 1aee4835105afa8658536120892b63580b36f462..bd8efaf005a9708f153ea873850acca994c64f29 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 test_description='git rebase - test patch id computation'
 
@@ -27,7 +27,7 @@ scramble()
                then
                        echo "$x"
                fi
-               i=$(((i+1) % 10))
+               i=$((($i+1) % 10))
        done < "$1" > "$1.new"
        mv -f "$1.new" "$1"
 }
index b55c4117884744db8eda17e42fe05e0e65216215..c95c4ccc393d0863ad53b6a2a684893282d7d9e6 100755 (executable)
@@ -62,4 +62,13 @@ do
 
 done
 
+test_expect_success 'am --abort will keep the local commits intact' '
+       test_must_fail git am 0004-*.patch &&
+       test_commit unrelated &&
+       git rev-parse HEAD >expect &&
+       git am --abort &&
+       git rev-parse HEAD >actual &&
+       test_cmp expect actual
+'
+
 test_done
index 552da65a61e8f78d40f8e19cfc5b73696ebcf283..baa670cea5d8a9d8b4b4578de69917fe76f71d46 100755 (executable)
@@ -10,7 +10,11 @@ test_expect_success 'setup' '
        test_commit A foo A &&
        test_commit B foo B &&
        test_commit C foo C &&
-       test_commit D foo D
+       test_commit D foo D &&
+       git checkout A^0 &&
+       test_commit E bar E &&
+       test_commit F foo F &&
+       git checkout master
 '
 
 mkdir .git/hooks
@@ -79,6 +83,18 @@ EOF
        verify_hook_input
 '
 
+test_expect_success 'git rebase --skip the last one' '
+       git reset --hard F &&
+       clear_hook_input &&
+       test_must_fail git rebase --onto D A &&
+       git rebase --skip &&
+       echo rebase >expected.args &&
+       cat >expected.data <<EOF &&
+$(git rev-parse E) $(git rev-parse HEAD)
+EOF
+       verify_hook_input
+'
+
 test_expect_success 'git rebase -m' '
        git reset --hard D &&
        clear_hook_input &&
index c6afebb00d02808f2a990347c8b0479d825cce5b..1fb76abd14e358afb42774f0ffe1d4e70b749074 100644 (file)
@@ -260,7 +260,7 @@ test_decode_color () {
                        if (n == 47) return "BWHITE";
                }
                {
-                       while (match($0, /\x1b\[[0-9;]*m/) != 0) {
+                       while (match($0, /\033\[[0-9;]*m/) != 0) {
                                printf "%s<", substr($0, 1, RSTART-1);
                                codes = substr($0, RSTART+2, RLENGTH-3);
                                if (length(codes) == 0)
index fc2438f60b0e0e87772db2a9f3e407f351bb03d0..9624865e21739139a9fef5ebc31196cbcd22011a 100644 (file)
@@ -744,10 +744,20 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
                const char *one;
                if (d->head_path) {
                        one = quote_path(d->head_path, -1, &onebuf, s->prefix);
+                       if (*one != '"' && strchr(one, ' ') != NULL) {
+                               putchar('"');
+                               strbuf_addch(&onebuf, '"');
+                               one = onebuf.buf;
+                       }
                        printf("%s -> ", one);
                        strbuf_release(&onebuf);
                }
                one = quote_path(it->string, -1, &onebuf, s->prefix);
+               if (*one != '"' && strchr(one, ' ') != NULL) {
+                       putchar('"');
+                       strbuf_addch(&onebuf, '"');
+                       one = onebuf.buf;
+               }
                printf("%s\n", one);
                strbuf_release(&onebuf);
        }
index e1e054e4d982de30d8a9c8c4109c6d62448f62a9..164581f87f49935f0d1b1885420960a4d11dea56 100644 (file)
@@ -212,8 +212,10 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
                return error("Could not open %s", filename);
        sz = xsize_t(st.st_size);
        ptr->ptr = xmalloc(sz ? sz : 1);
-       if (sz && fread(ptr->ptr, sz, 1, f) != 1)
+       if (sz && fread(ptr->ptr, sz, 1, f) != 1) {
+               fclose(f);
                return error("Could not read %s", filename);
+       }
        fclose(f);
        ptr->size = sz;
        return 0;