From patchwork Thu Nov 26 00:16:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11932397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85958C6379D for ; Thu, 26 Nov 2020 00:16:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 283A22168B for ; Thu, 26 Nov 2020 00:16:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i1naS74b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727666AbgKZAQW (ORCPT ); Wed, 25 Nov 2020 19:16:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbgKZAQW (ORCPT ); Wed, 25 Nov 2020 19:16:22 -0500 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB406C0613D4 for ; Wed, 25 Nov 2020 16:16:20 -0800 (PST) Received: by mail-oi1-x244.google.com with SMTP id v202so319652oia.9 for ; Wed, 25 Nov 2020 16:16:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UaWiBJWw3BtW9QlipAAIVNtGE1BGaUW+gGrYJEvz0J0=; b=i1naS74blYKCMAAftAJ1m86T06oLR3N0BdNZ0yOl51jEUC69Zo9ETMtgOUbj+IZT+b siI+5v4VcFW/W1Zc1gRLOEhx58Awqdv9v64bGKtlO+wy6RHZDXTbILUGvXpZnQL4ngyc eKc2W/LTpCMCMC4dQOVtV4mwIi9utQBX2I8ZgIVj7fLEpJ0BRZcuYW0rZVstys+twxI3 +cB9sgeI6jc2xNi2oA2cQsRYvzxOfQrB5Y2bQJiMgruuJ9jEDcuR2l/rliOg3YX1nviq YCuIguOv/juipPR0Cwsn2DIllkxhU5/T2vAHQ3PyUuK+MTunF5e20H8TVMTLwORHVI0Z NxCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UaWiBJWw3BtW9QlipAAIVNtGE1BGaUW+gGrYJEvz0J0=; b=V+3s8OZDU6pYQeHc9N4f4hXa0oehohIKUd9UCxiY6ZviBwLHf6/uZPwtoeaTlCk3Mf QZcWtQ2ETOJnoUpIbZoSoXTRkA7ygW9pPMIgizseqcKa9VqjFcw4Xzzs6/xWtO2qfTTy R/jihGn0G36ZGWRzrXecu4IlRDGYoljM981uvc330jVRyw+brWjRJBgcxeJ0ozaSkRts 1qiP2dp4UsyqFocqGyLdvjYV4A6FOMRh2YZUhgHp8fBV4cJBs9Q8kWt61DQxcZhZP43X sRemWZAAkrqA4p5N0OGPWR7hTEu7GrsR4Irm39ZkJLYkdEgfjdIBHhrdk2S+mLt/WPAg LboQ== X-Gm-Message-State: AOAM533zWJvY9Y0ovzZjLKND+nUuvoNMH+LdA6/LdMoj2B7qymAWCvPv sHzQjL/DkMIEPOlj7R0ZNcpsDFiKSMkZ9Q== X-Google-Smtp-Source: ABdhPJw9SeVrAHQQ1ofI7XdGh0OzVSiSblTMB9dkTARn0QjwfIJh+MjxH6lpQY9toJaFd0duvOILKw== X-Received: by 2002:aca:c416:: with SMTP id u22mr446686oif.12.1606349780057; Wed, 25 Nov 2020 16:16:20 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id m2sm2036749ots.11.2020.11.25.16.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 16:16:19 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jacob Keller , Tomo Krajina , Felipe Contreras Subject: [PATCH v4 1/3] tests: push: improve cleanup of HEAD tests Date: Wed, 25 Nov 2020 18:16:14 -0600 Message-Id: <20201126001616.663910-2-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201126001616.663910-1-felipe.contreras@gmail.com> References: <20201126001616.663910-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org So that we are not left in an inconsistent state between them. Signed-off-by: Felipe Contreras --- t/t5516-fetch-push.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index d11382f769..4077471937 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -449,6 +449,7 @@ test_expect_success 'push with HEAD nonexisting at remote' ' mk_test testrepo heads/master && git checkout -b local master && + test_when_finished "git checkout master; git branch -D local" && git push testrepo HEAD && check_push_result testrepo $the_commit heads/local ' @@ -457,8 +458,8 @@ test_expect_success 'push with +HEAD' ' mk_test testrepo heads/master && git checkout master && - git branch -D local && git checkout -b local && + test_when_finished "git checkout master; git branch -D local" && git push testrepo master local && check_push_result testrepo $the_commit heads/master && check_push_result testrepo $the_commit heads/local && @@ -488,6 +489,7 @@ test_expect_success 'push with config remote.*.push = HEAD' ' mk_test testrepo heads/local && git checkout master && git branch -f local $the_commit && + test_when_finished "git branch -D local" && ( cd testrepo && git checkout local && From patchwork Thu Nov 26 00:16:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11932395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50E9CC56201 for ; Thu, 26 Nov 2020 00:16:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED34920B1F for ; Thu, 26 Nov 2020 00:16:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rgaZek4g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728099AbgKZAQW (ORCPT ); Wed, 25 Nov 2020 19:16:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbgKZAQW (ORCPT ); Wed, 25 Nov 2020 19:16:22 -0500 Received: from mail-oi1-x244.google.com (mail-oi1-x244.google.com [IPv6:2607:f8b0:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B311C061A4F for ; Wed, 25 Nov 2020 16:16:22 -0800 (PST) Received: by mail-oi1-x244.google.com with SMTP id l206so301916oif.12 for ; Wed, 25 Nov 2020 16:16:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+rhFx8cgz7NLXK+mcDt67MnwPgOaJv95HxU0iA1BqIo=; b=rgaZek4goRH58c/lK+c5vK9RGbM8bBENy3hzFNt24hyFIzt7DmW9EAippptsDD+AVd wU5z2uf9E0BYU/jVcNGNJya14pbf49aacMHJoq4DUFDWgLWa5EHlUcx3Ll4vczgwEPo/ 5ejwCL6ERfpmiKVET1IvLFj9zYNKP02AD0RTbxvtJhV5GVFnlsQANmR9rwaALqv8Gkz1 kkYdgTz1c1jjxPwWwXSOsKW0WMEN5+dHOxXuoyJm6CWcJ1dmdBrBGk6OSCc9zvSsnjQJ P0uKUkk+aILVBfEjn1stohpNvAmToXq994ZHWkLhcL4bs4Cf4E8MUpR9vAUOiPbLZ52c IM1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+rhFx8cgz7NLXK+mcDt67MnwPgOaJv95HxU0iA1BqIo=; b=fwpbCCReE9Vi4v4rOhlyHwUAHpLxUUFiPMRa4hJZYosSztjGBL7l0W8MrWKqC1e/SP YOEM2NFcTOWRJ0g+vk4UeIN+mfCDyigQeDGd2rvfI7R3oaQxUDIwo0nEDMSrQ1zwGo0M Jhvh/ibd/CebBWLG3gtPgIb7Amor5yYeW7pjptbvgab1Aj0XylnXrgoMTvZ8TlhxRan+ h1wbi0FA+nB12djhRwC1rFdIiaIUjYFA1tLrDPhfHghlDeppNuVDScQFIkUFm4gi6jaN /gj24nDYfTbvGaqauzp6DREypMn3OsO4dov5ZZaiGF/l1NclXz1lDcxJlfgXmzjHFpf0 yOaA== X-Gm-Message-State: AOAM531cYNkRQ6sNUFv1Dp1C3vY7HeS3eHX6UQwC6GrTmMPlmDH+fKeM m9VRA0PnKYxrUXNbk5J2ZESSw5637s6iRQ== X-Google-Smtp-Source: ABdhPJxySVNDRJrqWhSBWZPNVazIJAJ6kj4axRcfKelPEO1U+bObxNBdfTFcinGMJ7jVnRpkVJpktw== X-Received: by 2002:aca:b887:: with SMTP id i129mr434316oif.25.1606349781588; Wed, 25 Nov 2020 16:16:21 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id j8sm2225507oif.55.2020.11.25.16.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 16:16:21 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jacob Keller , Tomo Krajina , Felipe Contreras Subject: [PATCH v4 2/3] tests: push: trivial cleanup Date: Wed, 25 Nov 2020 18:16:15 -0600 Message-Id: <20201126001616.663910-3-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201126001616.663910-1-felipe.contreras@gmail.com> References: <20201126001616.663910-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org No need to do two checkouts. Signed-off-by: Felipe Contreras --- t/t5516-fetch-push.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 4077471937..245eafb170 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -457,8 +457,7 @@ test_expect_success 'push with HEAD nonexisting at remote' ' test_expect_success 'push with +HEAD' ' mk_test testrepo heads/master && - git checkout master && - git checkout -b local && + git checkout -b local master && test_when_finished "git checkout master; git branch -D local" && git push testrepo master local && check_push_result testrepo $the_commit heads/master && From patchwork Thu Nov 26 00:16:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Contreras X-Patchwork-Id: 11932399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B153C64E75 for ; Thu, 26 Nov 2020 00:16:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 562FB216C4 for ; Thu, 26 Nov 2020 00:16:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g5rIop3j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728249AbgKZAQY (ORCPT ); Wed, 25 Nov 2020 19:16:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbgKZAQY (ORCPT ); Wed, 25 Nov 2020 19:16:24 -0500 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1EA2C0613D4 for ; Wed, 25 Nov 2020 16:16:23 -0800 (PST) Received: by mail-oi1-x243.google.com with SMTP id j15so352120oih.4 for ; Wed, 25 Nov 2020 16:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OAJMuKgCy6nbY0KmtKo+zoasNRSlQO+lk5gK1k6xRd8=; b=g5rIop3j85wuUkeYWxrdxZMangcfwqUU+3uETby8cpMfKKHtdT85QBkGih8dnYXi4d /+TrOeTOG1HodZdDUj1VuF9aq9GZQ03agNyUMeit2DZF3x0mURl0v4ZeS/Q70h70icZy SUB5fhqUnpY4jRuLU0CpAm3ETitXE0u2VyxCy+Dfeph9/tZSKl9ueFszWLn7uvxIfz+l +yGzPiaQjANJSPUaEYt6Odm3xTvSFAg5E4btWALZlQYJ2mbxuU5gCxwwMS116+a6hdZ1 X5m70lkQuOlCJ+lHPS5BCjVGM87Fk9tR+FfvPmoniDubqpIdMJ1jPibhq6FIZqwZefBe G36A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OAJMuKgCy6nbY0KmtKo+zoasNRSlQO+lk5gK1k6xRd8=; b=V4QP10TCjOnxizof+Cuo0BHP+N/K5EqYAh0X9e9XcEnAndqFP8e84OWyxWjgtnWU4X 5n3J5DUgst9Z4SpO2H9qkDPesDmbflnVmk8Y8IhhtMEtMLpHDxU/1E9YBhNuKproCufy sku3sLnDQ18u9VdOo339ORCDLJRu9CI5dlWxVFrrsIDeKexSwjyoWqCHWsunLRNy5don hjkC32MuiO1pFNoiieJZzLtspjkJmhVloodQU33VR20/1HMP7f0UH1HQYJ9SlWYVekQL DxCSQu7Gl5S6VNG/jFR7AQ61SWk+KtSW7hZP6iHAuvze7+4MAqaIk2fNCLm7l1KRiLAw n6Ug== X-Gm-Message-State: AOAM532TqEVy61WjQrW9bbiWC6yGnuYVGCCzByBQG04lAfvN66UF+Rwp oxqd+gHfPEDc1KU7hGJuN/UMw+VpeogvNQ== X-Google-Smtp-Source: ABdhPJwkACeFvPYDw2E6arpX0hV1Ft0Z50zmqS0bU2sgfCohVj2E65JInEzRIxqh7uSA+NgqlHDPmw== X-Received: by 2002:aca:af57:: with SMTP id y84mr459323oie.122.1606349783054; Wed, 25 Nov 2020 16:16:23 -0800 (PST) Received: from localhost (189-209-26-110.static.axtel.net. [189.209.26.110]) by smtp.gmail.com with ESMTPSA id y18sm2343619ooj.20.2020.11.25.16.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Nov 2020 16:16:22 -0800 (PST) From: Felipe Contreras To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Brandon Williams , Jacob Keller , Tomo Krajina , Felipe Contreras Subject: [PATCH v4 3/3] refspec: make @ a synonym of HEAD Date: Wed, 25 Nov 2020 18:16:16 -0600 Message-Id: <20201126001616.663910-4-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201126001616.663910-1-felipe.contreras@gmail.com> References: <20201126001616.663910-1-felipe.contreras@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since commit 9ba89f484e git learned how to push to a remote branch using the source @, for example: git push origin @:master However, if the right-hand side is missing, the push fails: git push origin @ It is obvious what is the desired behavior, and allowing the push makes things more consistent. Additionally, @:master now has the same semantics as HEAD:master. Signed-off-by: Felipe Contreras --- refspec.c | 5 +- t/t5511-refspec.sh | 2 + t/t5516-fetch-push.sh | 107 ++++++++++++++++++++++-------------------- 3 files changed, 62 insertions(+), 52 deletions(-) diff --git a/refspec.c b/refspec.c index c49347c2d7..adbfb3283a 100644 --- a/refspec.c +++ b/refspec.c @@ -71,7 +71,10 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet } item->pattern = is_glob; - item->src = xstrndup(lhs, llen); + if (llen == 1 && *lhs == '@') + item->src = xstrdup("HEAD"); + else + item->src = xstrndup(lhs, llen); flags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0); if (item->negative) { diff --git a/t/t5511-refspec.sh b/t/t5511-refspec.sh index f541f30bc2..f808649de4 100755 --- a/t/t5511-refspec.sh +++ b/t/t5511-refspec.sh @@ -58,6 +58,8 @@ test_refspec fetch 'HEAD~4:refs/remotes/frotz/new' invalid test_refspec push 'HEAD' test_refspec fetch 'HEAD' +test_refspec push '@' +test_refspec fetch '@' test_refspec push 'refs/heads/ nitfol' invalid test_refspec fetch 'refs/heads/ nitfol' invalid diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index 245eafb170..01004ff680 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -436,71 +436,76 @@ test_expect_success 'push ref expression with non-existent, incomplete dest' ' ' -test_expect_success 'push with HEAD' ' +for head in HEAD @ +do - mk_test testrepo heads/master && - git checkout master && - git push testrepo HEAD && - check_push_result testrepo $the_commit heads/master + test_expect_success "push with $head" ' -' + mk_test testrepo heads/master && + git checkout master && + git push testrepo $head && + check_push_result testrepo $the_commit heads/master -test_expect_success 'push with HEAD nonexisting at remote' ' + ' - mk_test testrepo heads/master && - git checkout -b local master && - test_when_finished "git checkout master; git branch -D local" && - git push testrepo HEAD && - check_push_result testrepo $the_commit heads/local -' + test_expect_success "push with $head nonexisting at remote" ' -test_expect_success 'push with +HEAD' ' + mk_test testrepo heads/master && + git checkout -b local master && + test_when_finished "git checkout master; git branch -D local" && + git push testrepo $head && + check_push_result testrepo $the_commit heads/local + ' - mk_test testrepo heads/master && - git checkout -b local master && - test_when_finished "git checkout master; git branch -D local" && - git push testrepo master local && - check_push_result testrepo $the_commit heads/master && - check_push_result testrepo $the_commit heads/local && + test_expect_success "push with +$head" ' - # Without force rewinding should fail - git reset --hard HEAD^ && - test_must_fail git push testrepo HEAD && - check_push_result testrepo $the_commit heads/local && + mk_test testrepo heads/master && + git checkout -b local master && + test_when_finished "git checkout master; git branch -D local" && + git push testrepo master local && + check_push_result testrepo $the_commit heads/master && + check_push_result testrepo $the_commit heads/local && - # With force rewinding should succeed - git push testrepo +HEAD && - check_push_result testrepo $the_first_commit heads/local + # Without force rewinding should fail + git reset --hard $head^ && + test_must_fail git push testrepo $head && + check_push_result testrepo $the_commit heads/local && -' + # With force rewinding should succeed + git push testrepo +$head && + check_push_result testrepo $the_first_commit heads/local -test_expect_success 'push HEAD with non-existent, incomplete dest' ' + ' - mk_test testrepo && - git checkout master && - git push testrepo HEAD:branch && - check_push_result testrepo $the_commit heads/branch + test_expect_success "push $head with non-existent, incomplete dest" ' -' + mk_test testrepo && + git checkout master && + git push testrepo $head:branch && + check_push_result testrepo $the_commit heads/branch -test_expect_success 'push with config remote.*.push = HEAD' ' + ' - mk_test testrepo heads/local && - git checkout master && - git branch -f local $the_commit && - test_when_finished "git branch -D local" && - ( - cd testrepo && - git checkout local && - git reset --hard $the_first_commit - ) && - test_config remote.there.url testrepo && - test_config remote.there.push HEAD && - test_config branch.master.remote there && - git push && - check_push_result testrepo $the_commit heads/master && - check_push_result testrepo $the_first_commit heads/local -' + test_expect_success "push with config remote.*.push = $head" ' + + mk_test testrepo heads/local && + git checkout master && + git branch -f local $the_commit && + test_when_finished "git branch -D local" && + ( + cd testrepo && + git checkout local && + git reset --hard $the_first_commit + ) && + test_config remote.there.url testrepo && + test_config remote.there.push $head && + test_config branch.master.remote there && + git push && + check_push_result testrepo $the_commit heads/master && + check_push_result testrepo $the_first_commit heads/local + ' + +done test_expect_success 'push with remote.pushdefault' ' mk_test up_repo heads/master &&