]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jk/sequencer-missing-author-name-check'
authorJunio C Hamano <gitster@pobox.com>
Tue, 11 Oct 2022 17:36:12 +0000 (10:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Oct 2022 17:36:12 +0000 (10:36 -0700)
Typofix in code.

* jk/sequencer-missing-author-name-check:
  sequencer: detect author name errors in read_author_script()

sequencer.c
t/t3438-rebase-broken-files.sh [new file with mode: 0755]

index a4d85f1fbdd4cbd12f590a1b400cb9939c903da0..debb2ecbafe2efdff334042b00c85badf7b88dfe 100644 (file)
@@ -915,7 +915,7 @@ int read_author_script(const char *path, char **name, char **email, char **date,
                error(_("missing 'GIT_AUTHOR_EMAIL'"));
        if (date_i == -2)
                error(_("missing 'GIT_AUTHOR_DATE'"));
-       if (date_i < 0 || email_i < 0 || date_i < 0 || err)
+       if (name_i < 0 || email_i < 0 || date_i < 0 || err)
                goto finish;
        *name = kv.items[name_i].util;
        *email = kv.items[email_i].util;
diff --git a/t/t3438-rebase-broken-files.sh b/t/t3438-rebase-broken-files.sh
new file mode 100755 (executable)
index 0000000..b92a3ce
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+test_description='rebase behavior when on-disk files are broken'
+. ./test-lib.sh
+
+test_expect_success 'set up conflicting branches' '
+       test_commit base file &&
+       git checkout -b branch1 &&
+       test_commit one file &&
+       git checkout -b branch2 HEAD^ &&
+       test_commit two file
+'
+
+create_conflict () {
+       test_when_finished "git rebase --abort" &&
+       git checkout -B tmp branch2 &&
+       test_must_fail git rebase branch1
+}
+
+check_resolve_fails () {
+       echo resolved >file &&
+       git add file &&
+       test_must_fail git rebase --continue
+}
+
+for item in NAME EMAIL DATE
+do
+       test_expect_success "detect missing GIT_AUTHOR_$item" '
+               create_conflict &&
+
+               grep -v $item .git/rebase-merge/author-script >tmp &&
+               mv tmp .git/rebase-merge/author-script &&
+
+               check_resolve_fails
+       '
+done
+
+for item in NAME EMAIL DATE
+do
+       test_expect_success "detect duplicate GIT_AUTHOR_$item" '
+               create_conflict &&
+
+               grep -i $item .git/rebase-merge/author-script >tmp &&
+               cat tmp >>.git/rebase-merge/author-script &&
+
+               check_resolve_fails
+       '
+done
+
+test_expect_success 'unknown key in author-script' '
+       create_conflict &&
+
+       echo "GIT_AUTHOR_BOGUS=${SQ}whatever${SQ}" \
+               >>.git/rebase-merge/author-script &&
+
+       check_resolve_fails
+'
+
+test_done