From patchwork Tue May 5 10:48:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11528769 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 777B592A for ; Tue, 5 May 2020 10:53:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EC64206A5 for ; Tue, 5 May 2020 10:53:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JqCY3lBQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728769AbgEEKxf (ORCPT ); Tue, 5 May 2020 06:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725766AbgEEKxd (ORCPT ); Tue, 5 May 2020 06:53:33 -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 342FEC061A0F for ; Tue, 5 May 2020 03:53:32 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id e16so2175072wra.7 for ; Tue, 05 May 2020 03:53:32 -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=5VMak9HU9yaUDZPpEf5F3+82C/SCraCowaObu4kwKV4=; b=JqCY3lBQnCxk3px+urHzVmnVdLhLJGe8eDH3HX7TI1oGFMmCdX7+XaFAyYA8ou6kgL Yf5fLV1Xp+Gb4N5TbAhffSDUt1u+RvTzjBr1Iz6irWqKd8M7Sn/EM2b8C//zueG/IkNJ hcyfUbSjvDY8P7XLcfivcIkcVkLVPHC5Ufg6Voj5wEuSs4MIrMSpQJNNOqJcguV2Is+b OdKriT5iPfjM95J2rf4Aehz+VklGtbxlvSeqYS10aAgwysO2HXWJ3mgXkdSt4i0795OU /Iulr9c5IOBrl++z2zKV6roNOeItPXmqVVZJtQGbzaKeqqgeYsXwMkbX8mj/65OAMd+L vdbw== 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=5VMak9HU9yaUDZPpEf5F3+82C/SCraCowaObu4kwKV4=; b=K6M0l3mgxQEpL+J3XqjCTgqoRMpV6M+DJaOHEczll1+6Ve/7nbtgzRnwQqnQCWfWsp R62o+c+XwpUmx482rv0HFCU9FRnkBpa2hTo2jbsCOlVKG41lPIDeaNVLH2srvQnDvhZU ilYBDY/YhwDi1aB9rase9Y+lxgimrd35iAfDjuMyuCelfyTpG/R7afs060e83rGmsqMo 1Vx8QZ+GPyDm9WXl3/Ogp4mx5qakMthvUewqHRSBtOWjZoghSTmHq3YYwAeBnkU3HMW+ 78oHccl88wT8HXTGlnCpxwBAu+Pz7vc3BeOcrWFulvJqYuD0La+yaqAHkGBaJCVHTWfU rcbQ== X-Gm-Message-State: AGi0PubFYhJibhGhuuI0hlb5wtOUHlWF4g+SZD0d1FVnELiFCxFfeFeb 8aYvEX/cMYD3tPjBLu+4CfvUYg52 X-Google-Smtp-Source: APiQypKvQxqpihUrDRhm08zQSrAHkre/UNS1MVPK0JdK1a5hRjFhko8ChdDCoieLHmzwL9vfxp0B7g== X-Received: by 2002:a5d:4443:: with SMTP id x3mr2986551wrr.162.1588676010730; Tue, 05 May 2020 03:53:30 -0700 (PDT) Received: from localhost.localdomain (atoulouse-654-1-289-61.w86-199.abo.wanadoo.fr. [86.199.72.61]) by smtp.googlemail.com with ESMTPSA id b85sm3170326wmb.21.2020.05.05.03.53.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 03:53:30 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Thomas Gummerer , Johannes Schindelin , Junio C Hamano , Alban Gruin Subject: [RFC PATCH v1 1/6] stash: mark `i_tree' in reset_tree() const Date: Tue, 5 May 2020 12:48:44 +0200 Message-Id: <20200505104849.13602-2-alban.gruin@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200505104849.13602-1-alban.gruin@gmail.com> References: <20200505104849.13602-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 As reset_tree() does not change the value pointed by `i_tree', and that it will be provided with `the_hash_algo->empty_tree' which is a constant, it is changed to be a pointer to 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 May 5 10:48:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11528767 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 E7F2592A for ; Tue, 5 May 2020 10:53:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFB30206A5 for ; Tue, 5 May 2020 10:53:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W2hiJzLr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728796AbgEEKxg (ORCPT ); Tue, 5 May 2020 06:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728726AbgEEKxe (ORCPT ); Tue, 5 May 2020 06:53:34 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E8E0C061A10 for ; Tue, 5 May 2020 03:53:33 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id 188so1773722wmc.2 for ; Tue, 05 May 2020 03:53: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=fSN7mYoft9OAeOp4Ef6yNbBYnwPx3kW783N6g+E/bKM=; b=W2hiJzLr8HyBvsFLGdcN8fDgMhRx0MeGc38sL+arJ2Ka53vTaNX44yxevA4b/trC1I wMUx+p2/h1Ale/apn7FOibXRcu1H2VMOtQeVoVfw8kHd9kg6qkmZOqBpPv0VBB8yZFJf LTVDeahPz3xd9J4s9vOktUk4SYETPSRERsJ1z5rQBCAeoGaQ1T6G/5WesOWba6WnoEve Ad7H0u66sXI1S0Wstx7KaPnFLnuHOojOALYvOAl51gqsC7RVixmaeCaJrkuMwnVU1Gjh jmIKZZmeH2VT/mrP754nVOOhPADb+1rQloJBHXhtY6/RoCxr9zoYnzsZ3N1p9NZKn4vs wsgA== 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=fSN7mYoft9OAeOp4Ef6yNbBYnwPx3kW783N6g+E/bKM=; b=bDigFVJS6B65GPxusoTA5d3k1YzncPg5mA3uyMFyvstE2mJSMtTTfQv0iCh5BaTT3C t+q1a4EEReoyjWvnXK5717KphyBpFBZRZQU3hUdgi/SJqMzlj7X+JW+BE1/PTvgq6gib TX1jZ8iq28qxkjU6GnPdFf070uU2KZs3rVbq9njwPq4VVV1Wm30LEzOYoGAXf7AXlGbk 4zuyrdf4PtAN4jP+nyJYlXR+nFpYB1/U8BZNd1Q2A3z16g5V3sLu1WLZb0RXpKX9RnyD rDIVZmHIkRldzz6dywVoi8bNWZN/AWeYa3RGR4r1uJFdJaSLYvdI6QcrBzY9BpZBhiSQ 4NYA== X-Gm-Message-State: AGi0PuZRDDmqoT6OGOix2kJCYAo90Kg4zVwK2yc2xMxfeeI6y1hwAeOT WPPWcn67Uv7Uuk2QBeafXWiY5TW5 X-Google-Smtp-Source: APiQypIEmXFMpkVwybP8ZXvj4L69jise7VPHO4by0GWAu64IlX+XyFT4za5GSKQFpBRCPOqo0uAcBA== X-Received: by 2002:a1c:f606:: with SMTP id w6mr2773329wmc.59.1588676011977; Tue, 05 May 2020 03:53:31 -0700 (PDT) Received: from localhost.localdomain (atoulouse-654-1-289-61.w86-199.abo.wanadoo.fr. [86.199.72.61]) by smtp.googlemail.com with ESMTPSA id b85sm3170326wmb.21.2020.05.05.03.53.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 03:53:31 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Thomas Gummerer , Johannes Schindelin , Junio C Hamano , Alban Gruin Subject: [RFC PATCH v1 2/6] stash: remove the second index in stash_working_tree() Date: Tue, 5 May 2020 12:48:45 +0200 Message-Id: <20200505104849.13602-3-alban.gruin@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200505104849.13602-1-alban.gruin@gmail.com> References: <20200505104849.13602-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. It also help to avoid issues with the split-index: when stash_working_tree() is called, the index is at `i_tree', and this tree is extracted in a second index for use in a subcommand. This is not a problem in the non-split-index case, but in the split-index case, if the shared index file has expired and is removed by a subcommand, the main index contains a reference to a file that no longer exists. 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. The call to reset_tree() becomes useless: the only caller of stash_working_tree() is do_create_stash(), which creates `i_tree' from its index, calls save_untracked_files() if requested (but as it also works on a second index, it is unaffected), then calls stash_working_tree(). But when save_untracked_files() will be modified to stop using another index, it won't reset the tree, because stash_patch() wants to work on a different tree (`b_tree') than stash_working_tree(). 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 May 5 10:48:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11528775 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 2013092A for ; Tue, 5 May 2020 10:53:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 083AD20735 for ; Tue, 5 May 2020 10:53:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EyA34GCj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728807AbgEEKxk (ORCPT ); Tue, 5 May 2020 06:53:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728762AbgEEKxf (ORCPT ); Tue, 5 May 2020 06:53:35 -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 A3B12C061A0F for ; Tue, 5 May 2020 03:53:34 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id g12so1800429wmh.3 for ; Tue, 05 May 2020 03:53:34 -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=8XpY9fXIlhN+Z+9PBUOVMB/cMosT7z9DzR4FqM2yEDY=; b=EyA34GCj93Dym0w7ADgh/DEc9qsokjE+jlaTw68BsgQoCTQQZz1pYsm1xX0Q/zjqht /1ZgVUaM6inZpiLvH3+hmXEXORw0v0wXa2MPQAqPpKV69NFghcaJeeYrIRCStllm2w0F 8p0p3VKQZ7L7vNZvls88R2uPHKoPzXMqY6q4Lt6GqpKif0PDKg+mXc3gRl5bW9zHBDqH MMTxz8T3DIqCl2BTgjt/oIGPba2Tsf8rXR3zJMGx+W98B/52dhGNPSg1WIARG83dWB3X SpPzHX/J4T86JJaR5jF9x47FKwD602QqZTODyj9tIIGQZV4meMJ5HYVTYgwN0RvgEUW2 T6kw== 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=8XpY9fXIlhN+Z+9PBUOVMB/cMosT7z9DzR4FqM2yEDY=; b=NGPgwc7hUicpxHFVjrByBs2zI0B4bdFqCe/6w4bT2O0okF5EtVrf6qFk+NnMF7tpSJ O9yFYMmLl6/PRrRlOFjd+LWp/Fds5Kej28aGQMUBsTaipf3LjHd8/w+iIloYPHCDqDo3 KKrChgibXujS5aunEEyIEklF774onIq6wtjAVnhDMVo58NAYDxx9piXirD4grSbPMxSx 26YRJmy/owh2bBGEBXzG49C0AzfDPjXW6L9/lkbs+PVMI6/lThRqS6ajs9eN7gtXBseK AkzSLbCNQ7VYeHRezgz8eyALixmxKQBSgdmetqDclVD6kddfsOK0Tnx0Xasn615ZpnBj RpZA== X-Gm-Message-State: AGi0PubDOevZ/HeCoauEhMlEMnYiKuO0t+kALy0lgvRwA4l3kipaZGv4 ZiYvU+Thl4MEuil7/tZXqbVgdwHN X-Google-Smtp-Source: APiQypIQnbkfQ6mtrwGKY/663eDKFU68pJA1zQOSOIu8KN8vND9CsYqcJAPYq5WwfxWAHeq2PQHJ1A== X-Received: by 2002:a1c:1d4b:: with SMTP id d72mr2709583wmd.19.1588676013121; Tue, 05 May 2020 03:53:33 -0700 (PDT) Received: from localhost.localdomain (atoulouse-654-1-289-61.w86-199.abo.wanadoo.fr. [86.199.72.61]) by smtp.googlemail.com with ESMTPSA id b85sm3170326wmb.21.2020.05.05.03.53.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 03:53:32 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Thomas Gummerer , Johannes Schindelin , Junio C Hamano , Alban Gruin Subject: [RFC PATCH v1 3/6] stash: remove the second index in stash_patch() Date: Tue, 5 May 2020 12:48:46 +0200 Message-Id: <20200505104849.13602-4-alban.gruin@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200505104849.13602-1-alban.gruin@gmail.com> References: <20200505104849.13602-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 May 5 10:48:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11528771 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 2014117E8 for ; Tue, 5 May 2020 10:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0854B2073B for ; Tue, 5 May 2020 10:53:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i5ePsGX4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728804AbgEEKxk (ORCPT ); Tue, 5 May 2020 06:53:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725766AbgEEKxg (ORCPT ); Tue, 5 May 2020 06:53:36 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B032DC061A10 for ; Tue, 5 May 2020 03:53:35 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id l18so2158840wrn.6 for ; Tue, 05 May 2020 03:53:35 -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=KM117VLDCfXLrGZJrTHWfpfhH0YbT1LqQuHLCBOUJ6c=; b=i5ePsGX4rKoLBSMv5LVjZRufQjvvLPDpcdT/Xefx/a4lFronwd+ilEULSUduyy0uAs nNovi9gxuGeEGJkYSydCM8llXYbtP+iC7qZZ4Eqer21iIbAOYmddSZF1z2q29H/JKYgt kcFroESZW7+JTHwYqI5pg4IBAswhQc/nJ5rEKGvZatKvrgBhb5y5WgIpWvRJJkGlpogi mduXfdjpKMypAQ/9V0Lhzanm9SrawOAlQtHE0fvwE8fjcLgAUWQfz80VC57nnp6Z2eKB RqCOGIsuyQs4l1zJoGSFLHMoa5y50Oy5w4D4v1FO0ymn2oJvZYYiHRpyCr8fEcY19yz9 gKDA== 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=KM117VLDCfXLrGZJrTHWfpfhH0YbT1LqQuHLCBOUJ6c=; b=Av18DQXM2SPXeuKabqFkrUvxGXMEaR8XN0WXqwX3UH6rzeAATGMCM4OXdDLvIgLxiL WvvL9HCQnFcupZOLA7Sduz9aKNf3l+FklAepvm+mXN1An1TUPXJzv6EVeZlKiERvL47Z Vyvndscr8vUvrDgW0haLd+ywuc3AoSErB5sFQdJeY9Eq8GnzBxKxhQPHubwC7udWA7KK J9JI9jNPWOuSTvx3o39CEliM2BQWnuCPlDSnnGQzT6gpJFmtMLsIJc76XiRNIR9UuV6Q 6B8fgEzAl4CdINFfHDFe8S4Ww6Gbu7Ado7UnPvsDdaawSBvcg728BhN0as2aYyVJwbtt mmdA== X-Gm-Message-State: AGi0PuaJkGNK/yssiuywYweUX2QZrBI9XWKoLmtazcRKkmknqHcndXo3 q22u2/UPyEaDY1QtSW88sIntrFDV X-Google-Smtp-Source: APiQypKyc0yQLCG+eCB3wkjSASuDncQb4/YWjKdUTIXhrNxQXtXghSO7D5Ez3V18R1tYko/XAuFPkQ== X-Received: by 2002:adf:ab57:: with SMTP id r23mr3325554wrc.180.1588676014210; Tue, 05 May 2020 03:53:34 -0700 (PDT) Received: from localhost.localdomain (atoulouse-654-1-289-61.w86-199.abo.wanadoo.fr. [86.199.72.61]) by smtp.googlemail.com with ESMTPSA id b85sm3170326wmb.21.2020.05.05.03.53.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 03:53:33 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Thomas Gummerer , Johannes Schindelin , Junio C Hamano , Alban Gruin Subject: [RFC PATCH v1 4/6] stash: remove the second index in save_untracked_files() Date: Tue, 5 May 2020 12:48:47 +0200 Message-Id: <20200505104849.13602-5-alban.gruin@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200505104849.13602-1-alban.gruin@gmail.com> References: <20200505104849.13602-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 exited. 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 | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 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); - 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; - } + NULL, 0)) + return -1; - if (write_index_as_tree(&info->u_tree, &istate, stash_index_path.buf, 0, - NULL)) { - ret = -1; - goto done; - } + 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 (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 May 5 10:48:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11528773 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 5BDF992A for ; Tue, 5 May 2020 10:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4206820658 for ; Tue, 5 May 2020 10:53:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a7cteGlW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728812AbgEEKxl (ORCPT ); Tue, 5 May 2020 06:53:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728726AbgEEKxh (ORCPT ); Tue, 5 May 2020 06:53:37 -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 0808DC061A0F for ; Tue, 5 May 2020 03:53:37 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id u16so1794746wmc.5 for ; Tue, 05 May 2020 03:53:36 -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=RH8qv6j34E5vdC+HweW68ColNcj5rnJOIlhX4BQ62P4=; b=a7cteGlWj2LF5ru3vJPxM6rQibBw87iw96Ve2Zx7OJJbTUmEmvYMtLiJx28xv5ChtU Hvkj1hrfyHqJsKW5b8QoX5XGkL9+3WPpr3nJAg5FnKg4o1sd+tM0+EijZVUbFcOFchCq MTlZ8swlGKV3LKSks0CSpiz4JLDgdxh/dktiB33YYwVBjtyE0n7kr5CdKJMiloTT+6jK FW8DHOQ3JoNw+tX0A1P62XK+roD0+fnvMC0Sjv3Q8YTuSjGkXi8tD/FbOtFdzhyCjmZU PhPj7kRqFCALaKcetCI3iq8CgDGrZGhc6QIMLrFZrNh3LQu2k82O599fQ4stcczrcang g6Bg== 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=RH8qv6j34E5vdC+HweW68ColNcj5rnJOIlhX4BQ62P4=; b=h9NHC6jEaqCLECmBmltBlxr9dDwLhtuAink+D9o6kHV8ti7a9XGaZ7rHoOhFg7dDBc Z6x9leWnUXesqUeQT4mob34awjUMNIAq5k8IZIugn5Azl1fIz/DIJ8LxcvfCFg4n9Od9 DztRS2iTKuj69tgC/cy35lYBALw4ZLdbJoDvHp56BKUalk8SghFnI9zvKjIqXzF3+hzJ kbQ1veR40BSwQfkRf7HvY7erZwWj2aOKoyKrUNLe4oxBO+EQhy7GiAfh+KKnBdo36wje zM4kBuF14eFb3SZx7agR8W9YugfauOaEYgSGpZNfy4wNz1xArafxHvoGbUJ4jp4utTGk QMYA== X-Gm-Message-State: AGi0PuZlvXiY6LPb+z7uGQyARM99ge+HQ3Tw6NxkemQ+HJcb1b2cn/Cz +MmoW0EswClHK38EGa5cMopoIvdY X-Google-Smtp-Source: APiQypJN4bB8+pH0cr0RJNebPSSv6eommwCHMMgCGRKTlrecnDIv4tRZc+VWjkEd+aLCiqRHoaeVAA== X-Received: by 2002:a1c:9d8c:: with SMTP id g134mr2917676wme.79.1588676015513; Tue, 05 May 2020 03:53:35 -0700 (PDT) Received: from localhost.localdomain (atoulouse-654-1-289-61.w86-199.abo.wanadoo.fr. [86.199.72.61]) by smtp.googlemail.com with ESMTPSA id b85sm3170326wmb.21.2020.05.05.03.53.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 03:53:35 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Thomas Gummerer , Johannes Schindelin , Junio C Hamano , Alban Gruin Subject: [RFC PATCH v1 5/6] stash: remove the second index in restore_untracked() Date: Tue, 5 May 2020 12:48:48 +0200 Message-Id: <20200505104849.13602-6-alban.gruin@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200505104849.13602-1-alban.gruin@gmail.com> References: <20200505104849.13602-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 | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/builtin/stash.c b/builtin/stash.c index cbe37cd24b..1eafc1fe8d 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -359,29 +359,16 @@ 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 +382,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 +421,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 +448,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 May 5 10:48:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11528777 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 587B01668 for ; Tue, 5 May 2020 10:53:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FE57206A5 for ; Tue, 5 May 2020 10:53:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WmJFTHVW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728801AbgEEKxn (ORCPT ); Tue, 5 May 2020 06:53:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728802AbgEEKxi (ORCPT ); Tue, 5 May 2020 06:53:38 -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 10158C061A41 for ; Tue, 5 May 2020 03:53:38 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id z8so1253268wrw.3 for ; Tue, 05 May 2020 03:53:37 -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=alFiRVZxX+n6jVXTeeoJZLpH7aeQCl4VkSj9GFGZ5AE=; b=WmJFTHVWyJ2G6FpzdrN58r+tW9w2XMeOfqAayAMSVtvGXzAfCjh6J4jQ7gpVykKWBu ISowRtutOGezFaaabYY5Pr0TOyp+PQ4TqdSNrAYDyOdhs7lYneffeKQjLsL8OjUHfc2N 2zprlGucerdgDUySUpox+ztkeQYUfIQLDoha2KCXQaxHf+A6aHmkO7js3CtsLKb9XxkA eLUy48DZGMZfVL6ASWFKngKde0f7Zdmjk7qc85Vgq6FZ9ATgsBdQqfLmQDdQbrAHE5Gg 6YFtOHhSasA7XVw8BxYRiJUVt/HwLtcQIVI6ff0pTokWyRQ8m0bTYipo63nHN4beAB49 S2RQ== 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=alFiRVZxX+n6jVXTeeoJZLpH7aeQCl4VkSj9GFGZ5AE=; b=ctKYstQcZ3NtlGHbmX3CodBBb7BJpq9WvRErAnixCDnz9idcoouc/RyMhknSNIFeUv DKF5LrBVbaSk0hihu2mi4Mah3VGQvLa3M2ZFQGm5gxeds1slNy/pukiojX9TwDPHV9bh oxU+RTv3DCUqlPuxg4nuQgsxY6Yx3R1+35+ACgsX/GR5wsc2IsUIImesH4kALT9PUvxa sqyGThZKL8d2eilq7SjEUsXvYx1Q8szqZrBLzYWrBNGbYQTxfrvA+c5Gk5Et2WZNDY8T WcgjlAgWSZczD9r0eL+G0UGL7GWUI+aFCL2fUohWbaasdx8IMRtdBJY3luOIHShRueMJ eUiQ== X-Gm-Message-State: AGi0PuZLtZiWH1Gi7VeGkQ+gXEzcwOFcy+hYl/7lY00a0cCtOXBZg0pu 8kx/TjXSjcr4Q7gAx6ocbM1JpJns X-Google-Smtp-Source: APiQypLwbXjkv7NdyYO7zxIXsWQt/B7j6e67eInJBpvj0npAVl/TabBW+eGvzCQQ9F/usK3tPSi+6w== X-Received: by 2002:adf:d0ce:: with SMTP id z14mr3296622wrh.179.1588676016560; Tue, 05 May 2020 03:53:36 -0700 (PDT) Received: from localhost.localdomain (atoulouse-654-1-289-61.w86-199.abo.wanadoo.fr. [86.199.72.61]) by smtp.googlemail.com with ESMTPSA id b85sm3170326wmb.21.2020.05.05.03.53.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 03:53:36 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org Cc: Thomas Gummerer , Johannes Schindelin , Junio C Hamano , Alban Gruin Subject: [RFC PATCH v1 6/6] stash: remove `stash_index_path' Date: Tue, 5 May 2020 12:48:49 +0200 Message-Id: <20200505104849.13602-7-alban.gruin@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200505104849.13602-1-alban.gruin@gmail.com> References: <20200505104849.13602-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 1eafc1fe8d..709fd5ca34 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 @@ -1506,8 +1505,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[] = { @@ -1524,10 +1521,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"))