Skip to content

Commit

Permalink
pull: warn on --verify-signatures with --rebase
Browse files Browse the repository at this point in the history
git-pull silently ignores the --verify-signatures option when
running --rebase, potentially leaving users in the belief that
the rebase operation would check for valid GPG signatures.

Implementing --verify-signatures for git-rebase was talked about,
but doubts for a valid workflow rose up.  Since you usually merge
other's branches into your branch you might have an interest that
their side has a valid GPG signature.

Rebasing, on the other hand, is to rebuild your branch on top of
other's work, in order to push the result back, and it is too late
to reject their work even if you find their commits lack acceptable
signature.

Let's warn users that the --verify-signatures option is ignored
during "pull --rebase"; users do not wonder what would happen if
their commits lack acceptable signature that way.

Signed-off-by: Alexander Hirsch <1zeeky@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
z33ky authored and gitster committed May 20, 2016
1 parent 3916adf commit c57e501
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions builtin/pull.c
Expand Up @@ -815,6 +815,9 @@ static int run_rebase(const unsigned char *curr_head,
argv_array_push(&args, "--no-autostash");
else if (opt_autostash == 1)
argv_array_push(&args, "--autostash");
if (opt_verify_signatures &&
!strcmp(opt_verify_signatures, "--verify-signatures"))
warning(_("ignoring --verify-signatures for rebase"));

argv_array_push(&args, "--onto");
argv_array_push(&args, sha1_to_hex(merge_head));
Expand Down
16 changes: 16 additions & 0 deletions t/t5520-pull.sh
Expand Up @@ -341,6 +341,22 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
test new = "$(git show HEAD:file2)"
'

test_expect_success "pull --rebase warns on --verify-signatures" '
git reset --hard before-rebase &&
git pull --rebase --verify-signatures . copy 2>err &&
test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
test new = "$(git show HEAD:file2)" &&
test_i18ngrep "ignoring --verify-signatures for rebase" err
'

test_expect_success "pull --rebase does not warn on --no-verify-signatures" '
git reset --hard before-rebase &&
git pull --rebase --no-verify-signatures . copy 2>err &&
test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
test new = "$(git show HEAD:file2)" &&
test_i18ngrep ! "verify-signatures" err
'

# add a feature branch, keep-merge, that is merged into master, so the
# test can try preserving the merge commit (or not) with various
# --rebase flags/pull.rebase settings.
Expand Down

0 comments on commit c57e501

Please sign in to comment.