From patchwork Tue Jun 30 15:15:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11634275 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94B8C161F for ; Tue, 30 Jun 2020 15:16:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C4D02074F for ; Tue, 30 Jun 2020 15:16:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tD9BqX7f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389342AbgF3PQ1 (ORCPT ); Tue, 30 Jun 2020 11:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389334AbgF3PQ0 (ORCPT ); Tue, 30 Jun 2020 11:16:26 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0B1EC061755 for ; Tue, 30 Jun 2020 08:16:26 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id q15so19179595wmj.2 for ; Tue, 30 Jun 2020 08:16:26 -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=hvdArNTuNFTGPsnaWFvZ5ZJQbVEjIqkdNyGC6HTg0OE=; b=tD9BqX7fQFIapTyCGMoEeAeiNj74IQz4FCOOa+5m+V1uwhMiwFpY8E9tVSRS/NYDML ZkFnRLfz8OkUxEpoDbKcaLj6rucetFjMt8KQN60EiAThizX3ENgOEF4JAVBiDHjox0d1 XTOz990hisM3eR/nSsAC0IOli1JqJUPePTZ7gB7v2sTc1cHMA2GKZx2ucPKCVmbuP88V 27GZ8Wzc+yyhVRayl8JmnNdXSh9CslTUPde+w7/HeaU1WyBf9ZFofWR3x3dYeODjgT2B zwmcV/29whXiqbsRyEw36NO9rC8ZnXZFatbgzEgw9Ip0oVg1PMCdIqMUykKPdV52JQhu /d2w== 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=hvdArNTuNFTGPsnaWFvZ5ZJQbVEjIqkdNyGC6HTg0OE=; b=k0UsqO3g9BFet7qw1HbE2K4beb7REv7aIwVplFkMsrWp7R6fgYzCurjXSi2EfyYggo UdHMebjDkql6GDxty0+qdZ9+EzJhog5Hir16K5MNFjEnkB29W+5uLUHG6N7zkmsVl+AB gHMpaTFdTJIAPt3S6GpRicJi0aqfekB3JKMzY7NDexGVArn9l2qBCy5tfXu0cMjpSs9c tE2ySSSmgcZbvDjzbompvSswick8WUPBtCcvZTEWh91MSY3yTgqujNN0mEe2r7fJ+Spu N5ItaFLIfwtnHbkaL/HEKFH9XIId5mZzrF3DrApVayQDyQfvJdq3WeMvqhzqmEauh9MQ SVhg== X-Gm-Message-State: AOAM531I+K2qg0B/lm0oK0jRiLhae2harfrlRoaxvSMtxZGdZoqKnFjR WG6cdB4l/INZgfUP60lPJYEAvI85 X-Google-Smtp-Source: ABdhPJwEOYfnBM0M9UbvrQ9ha/DrQK1jx2lzSLfFJ0fezfrIu/eV8snmObLTXT3/fE087pJXTj012Q== X-Received: by 2002:a05:600c:285:: with SMTP id 5mr22763254wmk.41.1593530185064; Tue, 30 Jun 2020 08:16:25 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-323-12.w86-199.abo.wanadoo.fr. [86.199.210.12]) by smtp.googlemail.com with ESMTPSA id 63sm4263911wra.86.2020.06.30.08.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:16:24 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Christian Couder , Thomas Gummerer , Junio C Hamano , Son Luong Ngoc , Alban Gruin Subject: [PATCH v2 1/6] stash: mark `i_tree' in reset_tree() const Date: Tue, 30 Jun 2020 17:15:53 +0200 Message-Id: <20200630151558.20975-2-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630151558.20975-1-alban.gruin@gmail.com> References: <20200505104849.13602-1-alban.gruin@gmail.com> <20200630151558.20975-1-alban.gruin@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In reset_tree(), the value pointed by `i_tree' is not modified. In a latter commit, it will be provided with `the_hash_algo->empty_tree', which is a constant. Hence, this changes `i_tree' to be a constant. Signed-off-by: Alban Gruin --- builtin/stash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/stash.c b/builtin/stash.c index 0c52a3b849..9baa8b379e 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -228,7 +228,7 @@ static int clear_stash(int argc, const char **argv, const char *prefix) return do_clear_stash(); } -static int reset_tree(struct object_id *i_tree, int update, int reset) +static int reset_tree(const struct object_id *i_tree, int update, int reset) { int nr_trees = 1; struct unpack_trees_options opts; From patchwork Tue Jun 30 15:15:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11634279 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A58F860D for ; Tue, 30 Jun 2020 15:16:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D7192073E for ; Tue, 30 Jun 2020 15:16:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zm/AEzO4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389346AbgF3PQb (ORCPT ); Tue, 30 Jun 2020 11:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389343AbgF3PQ1 (ORCPT ); Tue, 30 Jun 2020 11:16:27 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D63F6C061755 for ; Tue, 30 Jun 2020 08:16:27 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id j4so18141413wrp.10 for ; Tue, 30 Jun 2020 08:16:27 -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=WQ1wkzN9lR6tWZXEUOgKfa/3UH1sWqah3MpNf7gsGbg=; b=Zm/AEzO4ZGFutU9h1p5aZTDin3hjJZfh4i+W/taFuO81h3+9FbnFcdUdkNdE6uEvXV e3vMY9ezkLVHxNTxv18E4DTXY5s70giqJ41I1krcVY89fzh6NN3z4hXXap2I577Df2Cy hFXk8Qepb+ANMaiOyDnHsZAI++Xa1yj3dTixQtn87V4jgyRDlscfIuMpGg+hIVxFont2 sp4miyQMdWxhW+CDLYhv2IltagNaSVDi449HFrKdPwErcfcK79VY/JheCiB8tWgIUK66 WBhP8Yzc2PLN8Dey5e4XSsuWxXWeHWr94JKC7sRYWRjWfBH1q5Xx8jDgzzcl3WENhxzA Jm+w== 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=WQ1wkzN9lR6tWZXEUOgKfa/3UH1sWqah3MpNf7gsGbg=; b=ELs7+BThl0VTG7W5u5pk0UJ3lx/WrlVhnp3eDQ0hhXs8PXUIJauRgvUxEtbf4srXA5 Js+v7y99EDO2nyAyI97y56HdlFaU2B1qjD518nP9q+qAqYZVcIzitFup+kDUUs9Su6M3 pMvSyLgRSSKeN0PU88+y7WFU5pjAP3V+ndut+gbQJdbTaMf31mbxOe8CP2hdIdz2jcy8 tAJYbumflo5EJmmy5xezt9cjZRIzJ64M9g0x6fxPnSyjvRQusK/x1/pMX9aXLQ4EAj8h vDORzmXGFJwwQqQOSpRfibcEZgwHRS5ktN9ZIRfJthVC2FmMArgsTEFUKcP/88ps7Tf3 m17Q== X-Gm-Message-State: AOAM530FziEM5utTnQPzUsgqEbotlQvjrGBk6KScCMB0OBMx5takFvW/ 8TJysXmhR6sygMzdb6FTY8nHBCJz X-Google-Smtp-Source: ABdhPJw2TGuNTRY7x9oDm/NmIU+l7aKYAUUwys4rkJHav/WX3CZnl89gKosCETY7peLi7ZqGUPDu6Q== X-Received: by 2002:a05:6000:1107:: with SMTP id z7mr21877555wrw.355.1593530186306; Tue, 30 Jun 2020 08:16:26 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-323-12.w86-199.abo.wanadoo.fr. [86.199.210.12]) by smtp.googlemail.com with ESMTPSA id 63sm4263911wra.86.2020.06.30.08.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:16:25 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Christian Couder , Thomas Gummerer , Junio C Hamano , Son Luong Ngoc , Alban Gruin Subject: [PATCH v2 2/6] stash: remove the second index in stash_working_tree() Date: Tue, 30 Jun 2020 17:15:54 +0200 Message-Id: <20200630151558.20975-3-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630151558.20975-1-alban.gruin@gmail.com> References: <20200505104849.13602-1-alban.gruin@gmail.com> <20200630151558.20975-1-alban.gruin@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This removes the second index used in stash_working_tree() to simplify the code. The calls to set_alternative_index_output() are dropped to extract `i_tree' to the main index, and `GIT_INDEX_FILE' is no longer set before starting `update-index'. When it exits, the index has changed, and must be discarded. With this commit, reset_tree() does not need to be called at the beginning of stash_working_tree(), because it is only called by do_create_stash(), which sets the index at `i_tree', and save_untracked_files() does not change the main index. But it will become useful again in a later commit, when save_untracked_file() will be rewritten to use the "main" index, so I did not remove it. At the end of the function, the tree is reset to `i_tree'. Signed-off-by: Alban Gruin --- builtin/stash.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/builtin/stash.c b/builtin/stash.c index 9baa8b379e..2535335275 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1059,17 +1059,14 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps struct rev_info rev; struct child_process cp_upd_index = CHILD_PROCESS_INIT; struct strbuf diff_output = STRBUF_INIT; - struct index_state istate = { NULL }; init_revisions(&rev, NULL); copy_pathspec(&rev.prune_data, ps); - set_alternate_index_output(stash_index_path.buf); if (reset_tree(&info->i_tree, 0, 0)) { ret = -1; goto done; } - set_alternate_index_output(NULL); rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = add_diff_to_buf; @@ -1091,8 +1088,6 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps argv_array_pushl(&cp_upd_index.args, "update-index", "--ignore-skip-worktree-entries", "-z", "--add", "--remove", "--stdin", NULL); - argv_array_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); if (pipe_command(&cp_upd_index, diff_output.buf, diff_output.len, NULL, 0, NULL, 0)) { @@ -1100,19 +1095,16 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps goto done; } - if (write_index_as_tree(&info->w_tree, &istate, stash_index_path.buf, 0, - NULL)) { + discard_cache(); + if (write_cache_as_tree(&info->w_tree, 0, NULL) || + reset_tree(&info->i_tree, 0, 1)) ret = -1; - goto done; - } done: - discard_index(&istate); UNLEAK(rev); object_array_clear(&rev.pending); clear_pathspec(&rev.prune_data); strbuf_release(&diff_output); - remove_path(stash_index_path.buf); return ret; } From patchwork Tue Jun 30 15:15:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11634283 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFAC3161F for ; Tue, 30 Jun 2020 15:16:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B810D2073E for ; Tue, 30 Jun 2020 15:16:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E50T0OKz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389348AbgF3PQc (ORCPT ); Tue, 30 Jun 2020 11:16:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389334AbgF3PQ3 (ORCPT ); Tue, 30 Jun 2020 11:16:29 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 353DEC03E979 for ; Tue, 30 Jun 2020 08:16:29 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id 22so19190895wmg.1 for ; Tue, 30 Jun 2020 08:16:29 -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=UUA0POsVVJ22ojoGFsyScNlZG8/SiQ8wYyZG/EocrrU=; b=E50T0OKzVHViX2vsuv7pSBGs0xkUFQMq3Ry4AXkGAmRUy4ULNph4eFYPTLpMI1hXQS Lj5RJ+pVCs2EnN5tlpmDCR0VI5W8D+DAOAP+X8sgoGdmLf0ZZwuTMNUGS3QilyG2eFPL QUp4B2HUPKOcvtrLKERSy5m37F9Tm0mHlx/CSSGzVgCY+u2FvF65g0Td6C+y5T2kAbyU y6NLjiO6ApNSe/rXKo8pkzwNicfw1tFeDP9iakhwH4r/ygvbYpnpLoCaxvpy1oCc/BdF hdhLWL/flzu4WqnVY6r3zEXIBx21hALPH8dtf9bbCsRVYLz54Lf9ZxqFAz8ifwEy7nFQ YQ7w== 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=UUA0POsVVJ22ojoGFsyScNlZG8/SiQ8wYyZG/EocrrU=; b=YSCZ+H4uLuZ5wMs9ejYpi+mhLhzA9pAtfu0iYuhsDMSsuv6lRg8CNvLgbFNDKELQ3K cpORIWzQGk7++FlaodDBG9UgJzab3zy/ULQt133CzvGxTyUK3wbOdloyhubxRVjkhfzY c1TN0CA8fImQFI4ow29tponzvJP7mfhlxd1OqnF/bGrxo7e5k+1qINYRa+HG7HreTEdM 12moJFrEytVIunskXMEX2OiqHn2CMHAMVo0IOZTTkw+r6s3DMunCbSTjo194HcXTz1eV rVYRvfXK0cSLJKXAz1v0rYo7YhkVmalAwHnEnoM1sLhJLY4qA9T/RH4vhHFKTPBPIy5/ DBAA== X-Gm-Message-State: AOAM532S5NTd7frbaN5rIW6d1hyOdxEyZ/XY6+UFdrQx4saTBBYSUMyw 6KiIe+vInbw12pY8ROZBEEpY5C7P X-Google-Smtp-Source: ABdhPJx5dx7x8jImpjwMqs7O/2vg0//s0TmbfRGBMjyI25NnDXO/dUid3Eteil0TWht5DGvj1EsaaQ== X-Received: by 2002:a1c:7413:: with SMTP id p19mr21689743wmc.60.1593530187625; Tue, 30 Jun 2020 08:16:27 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-323-12.w86-199.abo.wanadoo.fr. [86.199.210.12]) by smtp.googlemail.com with ESMTPSA id 63sm4263911wra.86.2020.06.30.08.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:16:27 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Christian Couder , Thomas Gummerer , Junio C Hamano , Son Luong Ngoc , Alban Gruin Subject: [PATCH v2 3/6] stash: remove the second index in stash_patch() Date: Tue, 30 Jun 2020 17:15:55 +0200 Message-Id: <20200630151558.20975-4-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630151558.20975-1-alban.gruin@gmail.com> References: <20200505104849.13602-1-alban.gruin@gmail.com> <20200630151558.20975-1-alban.gruin@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This removes the second index used in stash_patch(). This function starts by resetting the index (which is set at `i_tree') to HEAD, which has been stored in `b_commit' by do_create_stash(), and the call to `read-tree' is replaced by reset_tree(). The index is discarded after run_add_interactive(), but not `diff-tree' as this command should not change it. Since the index has been changed, and subsequent code might be sensitive to this, it is reset to `i_tree' at the end of the function. Signed-off-by: Alban Gruin --- builtin/stash.c | 47 ++++++++++------------------------------------- 1 file changed, 10 insertions(+), 37 deletions(-) diff --git a/builtin/stash.c b/builtin/stash.c index 2535335275..eaeb7bc8c4 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -995,51 +995,24 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, struct strbuf *out_patch, int quiet) { int ret = 0; - struct child_process cp_read_tree = CHILD_PROCESS_INIT; struct child_process cp_diff_tree = CHILD_PROCESS_INIT; - struct index_state istate = { NULL }; - char *old_index_env = NULL, *old_repo_index_file; - remove_path(stash_index_path.buf); - - cp_read_tree.git_cmd = 1; - argv_array_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL); - argv_array_pushf(&cp_read_tree.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); - if (run_command(&cp_read_tree)) { - ret = -1; - goto done; - } + if (reset_tree(&info->b_commit, 0, 1)) + return -1; /* Find out what the user wants. */ - old_repo_index_file = the_repository->index_file; - the_repository->index_file = stash_index_path.buf; - old_index_env = xstrdup_or_null(getenv(INDEX_ENVIRONMENT)); - setenv(INDEX_ENVIRONMENT, the_repository->index_file, 1); - ret = run_add_interactive(NULL, "--patch=stash", ps); - the_repository->index_file = old_repo_index_file; - if (old_index_env && *old_index_env) - setenv(INDEX_ENVIRONMENT, old_index_env, 1); - else - unsetenv(INDEX_ENVIRONMENT); - FREE_AND_NULL(old_index_env); - /* State of the working tree. */ - if (write_index_as_tree(&info->w_tree, &istate, stash_index_path.buf, 0, - NULL)) { - ret = -1; - goto done; - } + discard_cache(); + if (write_cache_as_tree(&info->w_tree, 0, NULL)) + return -1; cp_diff_tree.git_cmd = 1; argv_array_pushl(&cp_diff_tree.args, "diff-tree", "-p", "-U1", "HEAD", oid_to_hex(&info->w_tree), "--", NULL); - if (pipe_command(&cp_diff_tree, NULL, 0, out_patch, 0, NULL, 0)) { - ret = -1; - goto done; - } + if (pipe_command(&cp_diff_tree, NULL, 0, out_patch, 0, NULL, 0)) + return -1; if (!out_patch->len) { if (!quiet) @@ -1047,9 +1020,9 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps, ret = 1; } -done: - discard_index(&istate); - remove_path(stash_index_path.buf); + if (reset_tree(&info->i_tree, 0, 1)) + return -1; + return ret; } From patchwork Tue Jun 30 15:15:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11634281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C1B0912 for ; Tue, 30 Jun 2020 15:16:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72A022074F for ; Tue, 30 Jun 2020 15:16:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WiNF9lIz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389351AbgF3PQd (ORCPT ); Tue, 30 Jun 2020 11:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389343AbgF3PQb (ORCPT ); Tue, 30 Jun 2020 11:16:31 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53541C061755 for ; Tue, 30 Jun 2020 08:16:31 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id f7so17584887wrw.1 for ; Tue, 30 Jun 2020 08:16:31 -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=UBVnXfBJF9lQX3a7Ibd8m+x5HaSMVcia4QtZlBo0xfA=; b=WiNF9lIzLsGzxuf8nmJ64vlJ04qzbRryuRomgJALy/zWxlyrHGCvkrAZ4ZwKvUE2Om FjRn+afpESGh04ppQ12ahfvyTUGkozxNsTPU0WZNA7/zlz2S4qDWNclT64PJqn/nCGJ0 4zz16GBchFYxSzKFPXUiEiAGr3rxDq4seRgpWQ0omWTYXnGmqyiEi0kcX3w7RdJGJFE8 hWkD06z0GxyB891AOW/06Pr2hU/WfMRA5vP7yWXPt+JNVGn63t8JJz3Kouu2RMa04p+H rhB4h+kFSig+aHG6Kpr0Q38xUNfDxztJWpC/WVw6QUfRKEtlVYeIuiC27WW+7NsdlDgE Z94w== 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=UBVnXfBJF9lQX3a7Ibd8m+x5HaSMVcia4QtZlBo0xfA=; b=nnuGDWaJ/cSlZZ9+1WXd/doymBQNw41nbe8jYnp+m6bcRYEbZgjLCXI4o9vDOmhJ5B FwexXdmWwl7ynz0pcgl1G29ib9SU2snGdk0C/i/wYShcGQlWEGvqd9O2DWvwF1i8/AqC pPHMWg0t2ZBOreET0pIlEmn8MPhB6+Prtk+fU2W69gDrpqj0hLhOk5ptANtwiqHYfiIp fsjVLdZjEoDjSZcvcn89VqACXUDSIcwEUWd61Vmz5EcB/cD9S4Xn63e0Ko/f0SDRzAmN cGtliT3CqUHh5sSJb22axx2/b6Hd03nkhW7D9l3PhPkTWz/4zOPK5Tci84iY6BQOqo9n EvXQ== X-Gm-Message-State: AOAM530J5cHHqcO6SNZU5MVjlk2q5bUTZW3f3ihMw07oj0r97yzhyqKY mQ9GftKo/XKh2idRrbdhgAiDzjww X-Google-Smtp-Source: ABdhPJx1u+19Q8UjVUQRJiqdBapF+ihNDUwccHtBsUYTZfU7ZrGgQeB54zjCExD+qriZWR58ibgFGA== X-Received: by 2002:adf:e50a:: with SMTP id j10mr23717435wrm.71.1593530189714; Tue, 30 Jun 2020 08:16:29 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-323-12.w86-199.abo.wanadoo.fr. [86.199.210.12]) by smtp.googlemail.com with ESMTPSA id 63sm4263911wra.86.2020.06.30.08.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:16:28 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Christian Couder , Thomas Gummerer , Junio C Hamano , Son Luong Ngoc , Alban Gruin Subject: [PATCH v2 4/6] stash: remove the second index in save_untracked_files() Date: Tue, 30 Jun 2020 17:15:56 +0200 Message-Id: <20200630151558.20975-5-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630151558.20975-1-alban.gruin@gmail.com> References: <20200505104849.13602-1-alban.gruin@gmail.com> <20200630151558.20975-1-alban.gruin@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This removes the second index used in save_untracked_files(). This functions creates a new commit with no parents, and a tree containing only untracked files, so the tree is reset to the empty tree at the beginning (hence the need for reset_tree() to accept constant trees). The environment of `update-index' is no longer updated, and the index is discarded after this command exits. As the only caller of this function is do_create_stash(), and the next user of the index is either save_untracked_files() or stash_patch(), which both want a different tree, the index is left as-is at the end. Signed-off-by: Alban Gruin --- builtin/stash.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/builtin/stash.c b/builtin/stash.c index eaeb7bc8c4..cbe37cd24b 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -954,41 +954,36 @@ static int check_changes(const struct pathspec *ps, int include_untracked, static int save_untracked_files(struct stash_info *info, struct strbuf *msg, struct strbuf files) { - int ret = 0; struct strbuf untracked_msg = STRBUF_INIT; struct child_process cp_upd_index = CHILD_PROCESS_INIT; - struct index_state istate = { NULL }; + + if (reset_tree(the_hash_algo->empty_tree, 0, 1)) + return -1; cp_upd_index.git_cmd = 1; argv_array_pushl(&cp_upd_index.args, "update-index", "-z", "--add", "--remove", "--stdin", NULL); - argv_array_pushf(&cp_upd_index.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); + + if (pipe_command(&cp_upd_index, files.buf, files.len, NULL, 0, + NULL, 0)) + return -1; + + discard_cache(); + if (write_cache_as_tree(&info->u_tree, 0, NULL)) + return -1; strbuf_addf(&untracked_msg, "untracked files on %s\n", msg->buf); - if (pipe_command(&cp_upd_index, files.buf, files.len, NULL, 0, - NULL, 0)) { - ret = -1; - goto done; - } - - if (write_index_as_tree(&info->u_tree, &istate, stash_index_path.buf, 0, - NULL)) { - ret = -1; - goto done; - } - if (commit_tree(untracked_msg.buf, untracked_msg.len, &info->u_tree, NULL, &info->u_commit, NULL, NULL)) { - ret = -1; - goto done; + strbuf_release(&untracked_msg); + return -1; } -done: - discard_index(&istate); + /* Do not reset the tree, as either stash_patch() or + * stash_working_tree() will do it. */ + strbuf_release(&untracked_msg); - remove_path(stash_index_path.buf); - return ret; + return 0; } static int stash_patch(struct stash_info *info, const struct pathspec *ps, From patchwork Tue Jun 30 15:15:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11634285 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A77DC60D for ; Tue, 30 Jun 2020 15:16:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F41B2074F for ; Tue, 30 Jun 2020 15:16:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DvoOuHD/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389353AbgF3PQg (ORCPT ); Tue, 30 Jun 2020 11:16:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389334AbgF3PQd (ORCPT ); Tue, 30 Jun 2020 11:16:33 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 167A5C03E979 for ; Tue, 30 Jun 2020 08:16:33 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id f7so17584980wrw.1 for ; Tue, 30 Jun 2020 08:16:33 -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=tzOgrjbRcUsF4xE9T76sH+yvBACK3WAB8A0dLrjlbU4=; b=DvoOuHD/C/ugXQFWw0dDcT3S9AI1puqdFdHtiYPCJkpXZ5ElL5hk5AC9LRZqc/qN3v zf50M95F5v4BYKc/gx2w4Yq4An+wSR4c4WPg49U4K2bSMprnEDjP8vnVZK54yaCKZU/6 4lF64Re3IzdIyPvEmzvPUAkLeGFBt5p0VoG92Ybsa2YgYoXSoi74yZBm8GVpAfgSPs4A bjYyp4atS1Lqs3qVRKxtLWbfhRA31oL25fUqNAV0Rdsowt1N/x2i1vCRbZqmMCcGqrS9 Z9MvUkXEX8Q2kAyMRXyZOndGqEhrqJe5AQLCY2SKxsC/uo2GACYeY21HnZb2XSzhrewC +//A== 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=tzOgrjbRcUsF4xE9T76sH+yvBACK3WAB8A0dLrjlbU4=; b=Ts/Jn0PQp891XwJRkNeoShGiQLJBr2Qye1+z6l44h81PkPmRQ4bB3hXHIZ0xZgJRPN NTLh5vbpeIyTM3vqUfVK2UCGvzzy1VIumkYz9PS+JcBtXIdPqxB5SCKlqdSJU1LU1uqp 6kLOpDG6z1EIdA4kwl7t4//t2QaRh6KGE87KFEUop6YY9QG+3SW65KlvL91OOiFWrZMu 5O3LJB0Jj1ypH6BMlzAWkTDeypQrAr6kdXW9PN89h9U9bD3b7rTr950tdBjJh7J5up1w dI1lblVK4EbLH29gMVMDGqVkMZ4dUuUP2y26F4ybzifSSWUcePYUf2LmmDdPtXjL5qWd ru1w== X-Gm-Message-State: AOAM530+J55eR8aWIk4LCdpOyEBjLaLq+KgGHO5/ZGHAHGrEQAoccMGo AIQ/hSDxSa5WuepshmIyyzIEd3ey X-Google-Smtp-Source: ABdhPJx7oUGDjeJ0f7rR7eXalYNd3qLO8WuCLxG+0mWjyiCQheFJ/L64StVWowYG68jiL4mGdEZxzg== X-Received: by 2002:a5d:6452:: with SMTP id d18mr22038146wrw.284.1593530190996; Tue, 30 Jun 2020 08:16:30 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-323-12.w86-199.abo.wanadoo.fr. [86.199.210.12]) by smtp.googlemail.com with ESMTPSA id 63sm4263911wra.86.2020.06.30.08.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:16:30 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Christian Couder , Thomas Gummerer , Junio C Hamano , Son Luong Ngoc , Alban Gruin Subject: [PATCH v2 5/6] stash: remove the second index in restore_untracked() Date: Tue, 30 Jun 2020 17:15:57 +0200 Message-Id: <20200630151558.20975-6-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630151558.20975-1-alban.gruin@gmail.com> References: <20200505104849.13602-1-alban.gruin@gmail.com> <20200630151558.20975-1-alban.gruin@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org This removes the second index used in restore_untracked(). The call to `read-tree' is replaced by reset_tree() with the appropriate parameters (no update, no reset). The environment of `checkout-index' is no longer modified, and the cache is discarded when it exists. In do_apply_stash(), the changes are a bit more involved: to avoid conflicts with the merged index, restore_untracked() is moved after merge_recursive_generic(). This introduces another problem: the files that were untracked once are now added to the index, and update_index() would add back those files in the index. To avoid this, get_newly_staged() is moved before restore_untracked(). Signed-off-by: Alban Gruin --- builtin/stash.c | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/builtin/stash.c b/builtin/stash.c index cbe37cd24b..d5077a27d9 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -359,29 +359,15 @@ static int restore_untracked(struct object_id *u_tree) int res; struct child_process cp = CHILD_PROCESS_INIT; - /* - * We need to run restore files from a given index, but without - * affecting the current index, so we use GIT_INDEX_FILE with - * run_command to fork processes that will not interfere. - */ - cp.git_cmd = 1; - argv_array_push(&cp.args, "read-tree"); - argv_array_push(&cp.args, oid_to_hex(u_tree)); - argv_array_pushf(&cp.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); - if (run_command(&cp)) { - remove_path(stash_index_path.buf); + if (reset_tree(u_tree, 0, 0)) return -1; - } - child_process_init(&cp); cp.git_cmd = 1; argv_array_pushl(&cp.args, "checkout-index", "--all", NULL); - argv_array_pushf(&cp.env_array, "GIT_INDEX_FILE=%s", - stash_index_path.buf); res = run_command(&cp); - remove_path(stash_index_path.buf); + discard_cache(); + return res; } @@ -395,6 +381,7 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, struct object_id index_tree; struct commit *result; const struct object_id *bases[1]; + struct strbuf newly_staged = STRBUF_INIT; read_cache_preload(NULL); if (refresh_and_write_cache(REFRESH_QUIET, 0, 0)) @@ -433,9 +420,6 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, } } - if (info->has_u && restore_untracked(&info->u_tree)) - return error(_("could not restore untracked files from stash")); - init_merge_options(&o, the_repository); o.branch1 = "Updated upstream"; @@ -463,24 +447,27 @@ static int do_apply_stash(const char *prefix, struct stash_info *info, return ret; } + if (!has_index && get_newly_staged(&newly_staged, &c_tree)) { + strbuf_release(&newly_staged); + return -1; + } + + if (info->has_u && restore_untracked(&info->u_tree)) { + strbuf_release(&newly_staged); + return error(_("could not restore untracked files from stash")); + } + if (has_index) { if (reset_tree(&index_tree, 0, 0)) return -1; } else { - struct strbuf out = STRBUF_INIT; - - if (get_newly_staged(&out, &c_tree)) { - strbuf_release(&out); - return -1; - } - if (reset_tree(&c_tree, 0, 1)) { - strbuf_release(&out); + strbuf_release(&newly_staged); return -1; } - ret = update_index(&out); - strbuf_release(&out); + ret = update_index(&newly_staged); + strbuf_release(&newly_staged); if (ret) return -1; From patchwork Tue Jun 30 15:15:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11634287 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4546F161F for ; Tue, 30 Jun 2020 15:16:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C3632073E for ; Tue, 30 Jun 2020 15:16:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u776vIAS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389355AbgF3PQh (ORCPT ); Tue, 30 Jun 2020 11:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388217AbgF3PQd (ORCPT ); Tue, 30 Jun 2020 11:16:33 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A949C061755 for ; Tue, 30 Jun 2020 08:16:34 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id 22so19191149wmg.1 for ; Tue, 30 Jun 2020 08:16:33 -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=F+KO+D5p3YOmib6IviJGmS4ctI5tZIQ6SxGpPeB4buk=; b=u776vIASLkcy5StlCWwRKEx9m9ydby1y0DGf4rZTKRzV96glZrhrHXw6rro0Ir5Ruy atR7tfk25bBtDPne+o+bBEqVfkgSmHINWdWMfy18fYyFdcNrfHa1Rj9Az6pEHvG5Kbjm ZZTSFXGYRu9LIuOKsPXVceWJd2V7lMgthbvrON/T57Amjj5h31NZ7RbTzAoyGdcKf9vu Mtmv79RQ0xUl/OlmXAX+v9TDXIS7Tgv22mwtkfDdf0MLuuy2KQNL/RvCqkZUB9GOqVch 1MooX+iPqYbR0ciCco4LTimiipI/IJaJ1DacEPSVHs8rQYLf6J9m0NIUyGfooZOdZoLZ qC/Q== 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=F+KO+D5p3YOmib6IviJGmS4ctI5tZIQ6SxGpPeB4buk=; b=eC8+yaBMQ6Y615v+lL7nIs2kU0urnIuyxyUaaZ2tRJvDnKwIVHAK167Ze6caEumFwP V4utwCFh5FDp6seTslaoEF/YS4Ul8Mwfez2y/44CQnOwq47LG0GcLwqz7PIe05fRYIiX L+mFJspvK1X+2vIWLdcgB0rxREUNVTCoOxLYYEGXQ7YvZJ9pAP5AoBlhPdDNeTZiYzb2 SroBaqYrsT7/94LHxE4MHuQsQBnv3iorLKJUdSohz5RkNbq6+jkonigQMt5HkKiF5s4z Z+hdeEXCKMyGfdirm30jma41MJeyE2otH2yh6eceOj4Xq5d21P7X6XYCZrbMiMwFDKXX oiUw== X-Gm-Message-State: AOAM531706VMcudEa1s2ynks0eupGw0IDLnOA8KlfAQGuLklm02p7/vU //03od1oLvzltlSIs/7WVocJM5fP X-Google-Smtp-Source: ABdhPJwvYLWf/btQ3PCXnQBJXYt2hZE42PlzDrJwp3JSYe2zj36KQmsOP1cFL8rPpmTWTpQqJZONyw== X-Received: by 2002:a05:600c:2182:: with SMTP id e2mr21646249wme.186.1593530192467; Tue, 30 Jun 2020 08:16:32 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-323-12.w86-199.abo.wanadoo.fr. [86.199.210.12]) by smtp.googlemail.com with ESMTPSA id 63sm4263911wra.86.2020.06.30.08.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:16:31 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Christian Couder , Thomas Gummerer , Junio C Hamano , Son Luong Ngoc , Alban Gruin Subject: [PATCH v2 6/6] stash: remove `stash_index_path' Date: Tue, 30 Jun 2020 17:15:58 +0200 Message-Id: <20200630151558.20975-7-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200630151558.20975-1-alban.gruin@gmail.com> References: <20200505104849.13602-1-alban.gruin@gmail.com> <20200630151558.20975-1-alban.gruin@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Since stash no longer uses a second index, `stash_index_path' is now unused, and can be dropped. Signed-off-by: Alban Gruin --- builtin/stash.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/builtin/stash.c b/builtin/stash.c index d5077a27d9..f1b3c0d2f8 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -88,7 +88,6 @@ static const char * const git_stash_save_usage[] = { }; static const char *ref_stash = "refs/stash"; -static struct strbuf stash_index_path = STRBUF_INIT; /* * w_commit is set to the commit containing the working tree @@ -1505,8 +1504,6 @@ static int save_stash(int argc, const char **argv, const char *prefix) int cmd_stash(int argc, const char **argv, const char *prefix) { - pid_t pid = getpid(); - const char *index_file; struct argv_array args = ARGV_ARRAY_INIT; struct option options[] = { @@ -1523,10 +1520,6 @@ int cmd_stash(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, git_stash_usage, PARSE_OPT_KEEP_UNKNOWN | PARSE_OPT_KEEP_DASHDASH); - index_file = get_index_file(); - strbuf_addf(&stash_index_path, "%s.stash.%" PRIuMAX, index_file, - (uintmax_t)pid); - if (!argc) return !!push_stash(0, NULL, prefix, 0); else if (!strcmp(argv[0], "apply"))