From patchwork Thu Nov 1 11:58:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slavica Djukic X-Patchwork-Id: 10663885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7CBB813B5 for ; Thu, 1 Nov 2018 11:59:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67E382B71F for ; Thu, 1 Nov 2018 11:59:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C2D42B72C; Thu, 1 Nov 2018 11:59:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 080202B724 for ; Thu, 1 Nov 2018 11:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728388AbeKAVBn (ORCPT ); Thu, 1 Nov 2018 17:01:43 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:33594 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728266AbeKAVBn (ORCPT ); Thu, 1 Nov 2018 17:01:43 -0400 Received: by mail-wm1-f68.google.com with SMTP id f19-v6so930691wmb.0 for ; Thu, 01 Nov 2018 04:59:03 -0700 (PDT) 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=z1dqqhFTY4KYnmDlx2os9wirfk6K1Q2g1wlrgfvE15Y=; b=NhwQ/JSJmN5QduugZsAwySpws1yADOoK7x/yj254i/3ZfIaEXzLjvesJU0kENUaUhl EJK/3uMy5lE8RaS0Bq+P8DXQP0gGlZPB2jFMBUzDIsoCVtDef4IeC5NxLyFqrAf1aMhT /csRI4W5GXEjqTfKnCDXQ/b7FZwkuy8LjQV3VLa+uat9mS4f5QWjYQs1U2CdbEO8U2tI C78XAMstk6MmQ5UMl6TIxhCX28ZInAn4LfHlBxdC9zu5+ERoDh+ci/2dwvCC3WFf9tXw KRWezH0TWkqVlKkuAKkDE+4meOPDYxYW7f7oXFLRkuFONLjO18msEQ/MJB2XVBrNM1Mz HbjQ== 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=z1dqqhFTY4KYnmDlx2os9wirfk6K1Q2g1wlrgfvE15Y=; b=hc5inCVukQwbOJA16Clb+JfynNxbqVYsPhDVuT/Q3WIzJnDoRy+k3yw6kQRcwsceSF r6wZ38K23pL/lnHsw4QKSrtSwJNiMtVs35iU9NB0DvSGDRrOqq/o0zvWtg8thVXSqeYD mepq2BaCZvhCJ6S5lNnZL2B78gteNXk2Epfi2xzR1KEJ3ZQ1AtcOYjzJwZC9jh+9Z7/4 jxkM+cEJj6Tz+LH47WUJI4im8ZGzXgbeuuq1rCKuarqY+cy0g4a9v9dO5gbz3/Sdv2RW 6/OuWrTs/l2qDD44Ffc4JJceTd6vkPBD9ESIsxAct4EA/ORDSXrNPEMnAhgRxhtMaRLD j7fg== X-Gm-Message-State: AGRZ1gLRavmczlIUWtyd8OIH9qPD3YYfJkRnKSc4Lg6yM9IDQR7AmMIx 0DzItLRbjnexVX6uUAVqj4c= X-Google-Smtp-Source: AJdET5cWatMskrgud3kEUrEuuLiTqm/+1WViXi5ajhu2rJkX/ppL4aaH5ioyUDFetXQwA6Z8StLZSw== X-Received: by 2002:a1c:9805:: with SMTP id a5-v6mr5313366wme.106.1541073543094; Thu, 01 Nov 2018 04:59:03 -0700 (PDT) Received: from localhost.localdomain ([31.223.156.57]) by smtp.gmail.com with ESMTPSA id n2-v6sm10232367wrm.36.2018.11.01.04.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 04:59:02 -0700 (PDT) From: Slavica Djukic X-Google-Original-From: Slavica Djukic To: slavicadj.ip2018@gmail.com Cc: Johannes.Schindelin@gmx.de, git@vger.kernel.org, slawica92@hotmail.com Subject: [PATCH 1/3][Outreachy] t3903-stash: test without configured user.name and user.email Date: Thu, 1 Nov 2018 12:58:34 +0100 Message-Id: <20181101115834.19044-1-slawica92@hotmail.com> X-Mailer: git-send-email 2.19.1.windows.1 In-Reply-To: <20181101115546.13516-1-slawica92@hotmail.com> References: <20181101115546.13516-1-slawica92@hotmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add test to assert that stash fails if user.name and user.email are not configured. In the final commit, test will be updated to expect success. Signed-off-by: Slavica Djukic --- t/t3903-stash.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index 9e06494ba0..aaff36978e 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -1156,4 +1156,19 @@ test_expect_success 'stash -- works with binary files' ' test_path_is_file subdir/untracked ' +test_expect_failure 'stash works when user.name and user.email are not set' ' + git reset && + >1 && + git add 1 && + test_config user.useconfigonly true && + test_config stash.usebuiltin true && + sane_unset GIT_AUTHOR_NAME && + sane_unset GIT_AUTHOR_EMAIL && + sane_unset GIT_COMMITTER_NAME && + sane_unset GIT_COMMITTER_EMAIL && + test_unconfig user.email && + test_unconfig user.name && + git stash +' + test_done From patchwork Thu Nov 1 12:00:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slavica Djukic X-Patchwork-Id: 10663887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D1CC13B5 for ; Thu, 1 Nov 2018 12:00:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE9422B760 for ; Thu, 1 Nov 2018 12:00:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E33662B73E; Thu, 1 Nov 2018 12:00:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C4052B766 for ; Thu, 1 Nov 2018 12:00:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728312AbeKAVDc (ORCPT ); Thu, 1 Nov 2018 17:03:32 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36122 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728199AbeKAVDc (ORCPT ); Thu, 1 Nov 2018 17:03:32 -0400 Received: by mail-wm1-f67.google.com with SMTP id a8-v6so1121477wmf.1 for ; Thu, 01 Nov 2018 05:00:51 -0700 (PDT) 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=gla8R/83fguG2iyJlz3txGL01tOW8s7yMXIdDFa7f+E=; b=jhHVhzyHqVP0Hl83hTFU20bd5kEKGqLy7Etz+2gZOk1zXUOXqcMKUSDpzahB000+yP 9LBQQKyU/IQRD2s7Xl7OSkqTNnpSWr+IOTRVrI9/quWbUlJ3RogLgD4oioq1NtdrOZGK q75mg+w57YhXz+v+a+5LHizHCJgY2JzEGjkoUW0C+o9w1xpgUKM6Ir+HGBUeexbmipoJ D+jammTrA8hB2REBfrBKsBzI0u6Aj6WoNHEJKAMwqdKmbxiXLvHXluBnUEcDYu0gz5/X ikQSWxBj/2DzallELZTaCptq6wxGvzmAb6lnSBMNVnWtqKMXpFMJ9kaA0pNW+oFWfbRG GBtw== 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=gla8R/83fguG2iyJlz3txGL01tOW8s7yMXIdDFa7f+E=; b=m/6tDBBXp0HDKLRCCrlCYAVNuzU92pfEdlTER8sz42n8s7MUNuzcafK/R8UaIeHKiD ltX4YA2Fu1KyEtOV9d9fMjRRuZwpDtpDcAObqSIWRgOxLS08EQTXSLLXwsELnt2yko25 8LOhr42ubTiUs0SeiwDaeX3ZXxOtu/DlmgET8GysTndGfTb2G2IEDlu4wvieCuH8iIrG NbmhOF7feLEiN/83QY8PVT63sWw+EIU9/T+PML+BRLmqolSd7rzLWY3UpCo0B3ukjCAN qEOjNgCfOxO20KFrRQhCldTrnnaaszANqZSwSlLrElZuZS2i/XvA3wLO1n9jsjpIQpHS k5ug== X-Gm-Message-State: AGRZ1gLP5mklWfApCozxo+WNeL5JDdcVpfdepmiTwvgGEdSR6fOu8Ll2 fNLLY0NivV+9yL9XOG8Bg3x+HrVM X-Google-Smtp-Source: AJdET5e3zIGgSycp7L0+o+KjT/rPrE5YdOWIWrMli60m8nX7yXAyvD7I14jL6cC9zLqurMGCUfp2Tg== X-Received: by 2002:a1c:650b:: with SMTP id z11-v6mr5417850wmb.28.1541073651227; Thu, 01 Nov 2018 05:00:51 -0700 (PDT) Received: from localhost.localdomain ([31.223.156.57]) by smtp.gmail.com with ESMTPSA id z12-v6sm14368239wrn.43.2018.11.01.05.00.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 05:00:50 -0700 (PDT) From: Slavica Djukic X-Google-Original-From: Slavica Djukic To: slavicadj.ip2018@gmail.com Cc: Johannes.Schindelin@gmx.de, git@vger.kernel.org, slawica92@hotmail.com Subject: [PATCH 2/3] [Outreachy] ident: introduce set_fallback_ident() function Date: Thu, 1 Nov 2018 13:00:29 +0100 Message-Id: <20181101120029.13992-1-slawica92@hotmail.com> X-Mailer: git-send-email 2.19.1.windows.1 In-Reply-To: <20181101115546.13516-1-slawica92@hotmail.com> References: <20181101115546.13516-1-slawica92@hotmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Usually, when creating a commit, ident is needed to record the author and commiter. But, when there is commit not intended to published, e.g. when stashing changes, valid ident is not necessary. To allow creating commits in such scenario, let's introduce helper function "set_fallback_ident(), which will pre-load the ident. In following commit, set_fallback_ident() function will be called in stash. Signed-off-by: Slavica Djukic --- cache.h | 1 + ident.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/cache.h b/cache.h index 681307f716..6b5b559a05 100644 --- a/cache.h +++ b/cache.h @@ -1470,6 +1470,7 @@ extern const char *git_sequence_editor(void); extern const char *git_pager(int stdout_is_tty); extern int is_terminal_dumb(void); extern int git_ident_config(const char *, const char *, void *); +void set_fallback_ident(const char *name, const char *email); extern void reset_ident_date(void); struct ident_split { diff --git a/ident.c b/ident.c index 33bcf40644..410bd495e9 100644 --- a/ident.c +++ b/ident.c @@ -505,6 +505,23 @@ int git_ident_config(const char *var, const char *value, void *data) return 0; } +void set_fallback_ident(const char *name, const char *email) +{ + if (!git_default_name.len) { + strbuf_addstr(&git_default_name, name); + committer_ident_explicitly_given |= IDENT_NAME_GIVEN; + author_ident_explicitly_given |= IDENT_NAME_GIVEN; + ident_config_given |= IDENT_NAME_GIVEN; + } + + if (!git_default_email.len) { + strbuf_addstr(&git_default_email, email); + committer_ident_explicitly_given |= IDENT_MAIL_GIVEN; + author_ident_explicitly_given |= IDENT_MAIL_GIVEN; + ident_config_given |= IDENT_MAIL_GIVEN; + } +} + static int buf_cmp(const char *a_begin, const char *a_end, const char *b_begin, const char *b_end) { From patchwork Thu Nov 1 12:02:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Slavica Djukic X-Patchwork-Id: 10663889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D5FB13B5 for ; Thu, 1 Nov 2018 12:03:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 112FD2B7EC for ; Thu, 1 Nov 2018 12:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2B872B832; Thu, 1 Nov 2018 12:03:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47E782B81B for ; Thu, 1 Nov 2018 12:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728302AbeKAVFn (ORCPT ); Thu, 1 Nov 2018 17:05:43 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51692 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728085AbeKAVFn (ORCPT ); Thu, 1 Nov 2018 17:05:43 -0400 Received: by mail-wm1-f66.google.com with SMTP id w7-v6so1164127wmc.1 for ; Thu, 01 Nov 2018 05:03:02 -0700 (PDT) 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=l/2Dlumwjj1Xe6rzOcO06HupXx209aDWI2zE44n3fDc=; b=iO9AH207bZa9Fi2YneOagU2MnCscyEtdsCp0cF8u+iQrL7+ObUcf4w8mWqYlJKZiGq X/EWQQ0ywK07il6u5LYNK935urPzq2mCfkZz8lRsm6INyfwUj8LK6gqaFWu4C24Qan17 XlS9Pzj7uCPXxpN9ZbKOEUeEt+XC8Ip3J5hRi8t/T3d88nU83Xt8BBIeuOpLun4YbsxU 26WNDFIyrE81aHcIVNdu+6d46JAUKvRYsctGO2fqKNXrWdI0t0MpY9e95x69mzsKtTCT jYalxzEestRVVQhX6kEAaBcUSBIZexvSm8tQ2u6cUT9qqNzBi3Vkez/wc1q2xupjha3G tojQ== 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=l/2Dlumwjj1Xe6rzOcO06HupXx209aDWI2zE44n3fDc=; b=X0S/iSQoRn5xaCfdP987tdZzxcD3juzMLUfP7PbozOPxNuzW0/AT0HEbykqR+v4kKK hdi2fuZNrodeCgpSO29NMk03xtljFNaaMU6/VBS6EI2dP/TF21Q1gwd86XnlefOBCFVr 8Sp6/kLgkEyhXqX6y/E3Qj+t8lhyGF4PHQcCbQgvMzjPn7wZ+PjBvuUXSAuY8icAxzpM 1V+01R73XuqDHJ/MsjkF7M/ypUDcTSMCP7cqBZPoS0bRFdvsnDThYAwa7buLa/cyotdZ Lkn+/WF+UJC2SHWNROl3ZNwr7o1PMI8DYoIR0yotAv4fpBohoeCRUD64ARpuzfP+RVkD XQ/Q== X-Gm-Message-State: AGRZ1gIBF0kYjwWWoim2RIeK3xB8GKJTrvH30UqSt4XU60wFT3j00dvu JzgY4KbYRq7BOurt0UwjvPc= X-Google-Smtp-Source: AJdET5cp5wiSICwQTmFDweSXqNFfDboVasKzquDZVe7uJIPn9Gy9eM3rLklMnanflMw74qIsOxfshQ== X-Received: by 2002:a1c:950f:: with SMTP id x15-v6mr5227885wmd.3.1541073781697; Thu, 01 Nov 2018 05:03:01 -0700 (PDT) Received: from localhost.localdomain ([31.223.156.57]) by smtp.gmail.com with ESMTPSA id o188-v6sm2666544wmg.9.2018.11.01.05.03.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 05:03:01 -0700 (PDT) From: Slavica Djukic X-Google-Original-From: Slavica Djukic To: slavicadj.ip2018@gmail.com Cc: Johannes.Schindelin@gmx.de, git@vger.kernel.org, slawica92@hotmail.com Subject: [PATCH 3/3] [Outreachy] stash: use set_fallback_ident() function Date: Thu, 1 Nov 2018 13:02:39 +0100 Message-Id: <20181101120239.15636-1-slawica92@hotmail.com> X-Mailer: git-send-email 2.19.1.windows.1 In-Reply-To: <20181101115546.13516-1-slawica92@hotmail.com> References: <20181101115546.13516-1-slawica92@hotmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Call set_fallback_ident() in cmd_stash() and update test from the first commit to expect success. Executing stash without user.name and user.email configured can be useful when bots or similar users use stash, without anyone specifing valid ident. Use case would be automated testing. There are also users who find this convinient. For example, in this thread: https://public-inbox.org/git/87o9debty4.fsf@evledraar.gmail.com/T/#ma4fb50903a54cbcdecd4ef05856bf8094bc3c323 user points out that he would find it useful if stash had --author option. Signed-off-by: Slavica Djukic --- builtin/stash.c | 1 + t/t3903-stash.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/stash.c b/builtin/stash.c index 965e938ebd..add30aae64 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1523,6 +1523,7 @@ int cmd_stash(int argc, const char **argv, const char *prefix) trace_repo_setup(prefix); setup_work_tree(); + set_fallback_ident("git stash", "stash@git.commands"); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, git_stash_usage, diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh index aaff36978e..06a2ffb398 100755 --- a/t/t3903-stash.sh +++ b/t/t3903-stash.sh @@ -1156,7 +1156,7 @@ test_expect_success 'stash -- works with binary files' ' test_path_is_file subdir/untracked ' -test_expect_failure 'stash works when user.name and user.email are not set' ' +test_expect_success 'stash works when user.name and user.email are not set' ' git reset && >1 && git add 1 &&