From patchwork Fri Jul 31 16:51:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11695253 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 2B66E138C for ; Fri, 31 Jul 2020 16:52:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 137BE22B40 for ; Fri, 31 Jul 2020 16:52:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="koVOOX/J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733226AbgGaQwL (ORCPT ); Fri, 31 Jul 2020 12:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733019AbgGaQwK (ORCPT ); Fri, 31 Jul 2020 12:52:10 -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 7CFC5C061574 for ; Fri, 31 Jul 2020 09:52:10 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id r4so25629086wrx.9 for ; Fri, 31 Jul 2020 09:52:10 -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=koVOOX/JY1F84dPviYkiVt1fVlqOcyXZTuox7VXuLVWNYhLo4WVZS8AMTmCQjlQfwQ HT/kvD/Tca9S9IeHKdkMMEFdJon+FXELNbEXT/9aen5odjs8tIf9iUi+OytlCnUAMoxI +fRp/L3XKIO+4bOOAcfzA9FRanX2Wrm71ZPbjZUMKThiMik0D1MtPJZjUkXRmV5qX9Jd 8x7fOW/L1p8u9b4C4js0d2j6YCf4gZn0QHWR9M8tzFuSV1nRI0OGd/nWSi/Ua3pYUNwn 3cxtTyi0rEs1rev4o/RUbGfzQMDh14PTHrboOZUNREKNDyUzNVLrljKV3yTNmHCDiyhP +mGg== 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=c9LWVAFdUA79f+oqi5eIAf2TZblzj9EbmoSlrLQmRWq9LESU8OydJC+Cq3Z6nkGkPG wCWTY1L7/FR5Fcx4OlvhUGja/rgw25K3RGJimQFvQsERu43oMiKLtz2gMHEGFPuFLh2t FT33GNmtQnIklBi2vAbnrMtrVqZGguTqpRrd93OPNoSSYcsjpzXs0ft4QeSo/qK01Lz+ GRgLxuhqWcJ2G006uf408cW/hAhF3GR893hL/K01nex3PEnsJAV1w+kNkCESyT02Qt1K 6596+CrItC6wWAH8yQ6LI/fSpdyV90gRiIR+jwitc/0X3XQ6kfZikik/02+7Yq+YLHmv qKVA== X-Gm-Message-State: AOAM530tYU4ZgsHc35afoXFA6sK5OMHIF4CwbvFQqs8jeSKdY50581WW bmIt6xMYzj1oMc/YCQgJ9Aa4+p8X X-Google-Smtp-Source: ABdhPJwPnX/vnD7QLAKD1xbaGp6toGyueQVcd48BRGFOxXGzeahGrj4CAr0yC4rEe1J5nN8JzruEHA== X-Received: by 2002:a5d:40cf:: with SMTP id b15mr4189581wrq.319.1596214329016; Fri, 31 Jul 2020 09:52:09 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-421-163.w2-6.abo.wanadoo.fr. [2.6.84.163]) by smtp.googlemail.com with ESMTPSA id t14sm15169134wrg.38.2020.07.31.09.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:52:08 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org, Christian Couder , Junio C Hamano Cc: Thomas Gummerer , Son Luong Ngoc , Alban Gruin Subject: [PATCH v3 1/6] stash: mark `i_tree' in reset_tree() const Date: Fri, 31 Jul 2020 18:51:35 +0200 Message-Id: <20200731165140.29197-2-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731165140.29197-1-alban.gruin@gmail.com> References: <20200630151558.20975-1-alban.gruin@gmail.com> <20200731165140.29197-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 Fri Jul 31 16:51:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11695255 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 1FDFB138C for ; Fri, 31 Jul 2020 16:52:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0891422B40 for ; Fri, 31 Jul 2020 16:52:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bcBJDILy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733290AbgGaQwM (ORCPT ); Fri, 31 Jul 2020 12:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733019AbgGaQwL (ORCPT ); Fri, 31 Jul 2020 12:52:11 -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 9A37EC061574 for ; Fri, 31 Jul 2020 09:52:11 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id r4so25629136wrx.9 for ; Fri, 31 Jul 2020 09:52:11 -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=bcBJDILy8GMUKMc7SEdHjc1LB87LHkGkdE3JC4Ufy2h9+5brnmavmfVOsNPnF8P2IP TysNAKtmheFveUZMUXg1PeLEQkWMaw0cLROflbXmfC9b/WqjuRlAzNlTHJb3GNEkVHDr mTc7CsLxyIWZ5OSmdY5w7+YIe2yLgWDWFJ/tCn03NjEdq2v5NLqBV6CYVTdeq+gvUSAn ivNeD3X9ltUQ451UEqDD/zVKoLfbhqamUSx5Di+oAfwzhjenmydFBBpFfY9UfBzz5yzn jRVrcmvDhO9v5T57JCLwsgL7RUH78OphjnCbq8PM4vuCxog1Ql4jOOgRTj059x4GApQL rC2g== 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=Ief/YTjJcCgK/qyblHwWX5uRZwtriIhKN2BA2qY0ZSWxAGXusJ4inEfU1YJ2uc5vXF 3/LAJU5EVoZcBJv3soXAARWR+b9H6fdUqSzymsVGzbLykMubc/WiqmR+PvpKodqQrQDK ZxOV/DtoXtTgvqdTyaSY54FrKaHcrnMnpBt7rWZJO15CfoujwCFJqp49RWRIeNMOHTfG Q1OpZH1G1zwD34301CTjWvodu8jrYy9sVU6xmf6a/Uske1es5altmYnNGZGLgFkbTrhr XfuJICGN/LoX5T4x9cl61dvlfzQc7jJ3Z9P0ygN6lWzuMNBx8HjRy3QIJHdXmk5Ey4CA 2gpQ== X-Gm-Message-State: AOAM532AXJGJs0usVUs+8GMfS7dsD4aQOl4jYhOZ6oWTSCl4aMctDXIU tzEV3DpBFc9LZmkmTNEg1QYkBFg7 X-Google-Smtp-Source: ABdhPJzzM+ezV0i73pI+Az56/GLJwMPlXD0osHZGQR12C1GAVn0+hzYuWJNGv1dqkh0bFt6OcDynbg== X-Received: by 2002:a5d:5485:: with SMTP id h5mr4021109wrv.427.1596214330092; Fri, 31 Jul 2020 09:52:10 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-421-163.w2-6.abo.wanadoo.fr. [2.6.84.163]) by smtp.googlemail.com with ESMTPSA id t14sm15169134wrg.38.2020.07.31.09.52.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:52:09 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org, Christian Couder , Junio C Hamano Cc: Thomas Gummerer , Son Luong Ngoc , Alban Gruin Subject: [PATCH v3 2/6] stash: remove the second index in stash_working_tree() Date: Fri, 31 Jul 2020 18:51:36 +0200 Message-Id: <20200731165140.29197-3-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731165140.29197-1-alban.gruin@gmail.com> References: <20200630151558.20975-1-alban.gruin@gmail.com> <20200731165140.29197-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 Fri Jul 31 16:51:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11695263 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 AF8DC6C1 for ; Fri, 31 Jul 2020 16:52:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97E5422B40 for ; Fri, 31 Jul 2020 16:52:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="grwcUo2P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733270AbgGaQwR (ORCPT ); Fri, 31 Jul 2020 12:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733184AbgGaQwO (ORCPT ); Fri, 31 Jul 2020 12:52:14 -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 AB250C061574 for ; Fri, 31 Jul 2020 09:52:13 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id f1so28041352wro.2 for ; Fri, 31 Jul 2020 09:52:13 -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=grwcUo2PlerU5iQobSJUdrV/3QezcSUPWQ1go85eAWDamctKphNxzaiqNDscN6ewFg HOLvaFFhERK4V1a9QoNl5ISMZOHBSMb/1v7JsKPU05gS8iL9IiObyKhZ5ESdaa+fDhsn /g9RnqoNt6izFH2ODgLKRZdyRfpjNDyDO+rlGrsY5w57FZnhsCTwNdrhmt1d3exbwxro eBQLAe+2T+FBuixSmr/B8Iqi002OSR6WtUtUetwSndW8sjrzsogOdCMrt55ti3wRBByp tD2yZCnGIXBgQ8f1n46oR0fh+7dbndM4QqUkHVvLZODMppod5iNHrjgNFx9bZCwthBh6 aeKw== 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=KiV3BulMYxEdmOlSxh1VNqEo1a7G0IY3i52SzRE6W8ihoKTiQml1IVgD1nhyRlLLqk oxLRGQWHbo015znqBTYUi9OVWUm4GA4GB6CIECZdyWuFYXzWRquq0mOxP4iChBkRwHbv Fxkz97wUUgu2e9vkcg4aEEV+8SClcFkTRaBGoQftMgLFKsPWSbv9Yf0xuQJiZz8bgODh KqPL7flIaBZH5e6RQe0MXWq2tLUVqerSlIB4cv/b0OZi1GXjw1HRRqITU08+03iaKahw rHL68+6RbSGM7hPEe7nn5Sv1bbiJd9jWEW39hHcC4h7KPV/j00TWskS74Sp59FsKPRaO YHmg== X-Gm-Message-State: AOAM531QMPV0gw/fa4w1D9eJPKKjIP/tDeUoybYQSzQqYMVu/S2mqAYB MPJ8+6y3IOzhYbgRvobzOJfFbfss X-Google-Smtp-Source: ABdhPJwlojeq3hGY8KB3nglbK5xzJgZTpC6zDi81UFpolGsSVKKbaX+Njnn1RAqdp/k2c+1aS27ynQ== X-Received: by 2002:a5d:6aca:: with SMTP id u10mr2605858wrw.365.1596214332135; Fri, 31 Jul 2020 09:52:12 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-421-163.w2-6.abo.wanadoo.fr. [2.6.84.163]) by smtp.googlemail.com with ESMTPSA id t14sm15169134wrg.38.2020.07.31.09.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:52:11 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org, Christian Couder , Junio C Hamano Cc: Thomas Gummerer , Son Luong Ngoc , Alban Gruin Subject: [PATCH v3 3/6] stash: remove the second index in stash_patch() Date: Fri, 31 Jul 2020 18:51:37 +0200 Message-Id: <20200731165140.29197-4-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731165140.29197-1-alban.gruin@gmail.com> References: <20200630151558.20975-1-alban.gruin@gmail.com> <20200731165140.29197-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 Fri Jul 31 16:51:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11695259 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 74232138C for ; Fri, 31 Jul 2020 16:52:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B01E2245C for ; Fri, 31 Jul 2020 16:52:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OopArYK4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733302AbgGaQwR (ORCPT ); Fri, 31 Jul 2020 12:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732474AbgGaQwP (ORCPT ); Fri, 31 Jul 2020 12:52:15 -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 4B842C06174A for ; Fri, 31 Jul 2020 09:52:15 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id t14so4640230wmi.3 for ; Fri, 31 Jul 2020 09:52:15 -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=OopArYK4B5KnDRQ3PCgrdu8FtlvtxlG9W3zZIWkRxFotcm5aMGZUzpm0IY/S7o/cql 6rJwQusP8WYyxucWNElBfErpuGnDc4eMDRNFRpVYei7RgppvoLuM8jseq0Uips0KpCJD AJuk6kM4/heciDL4rg1ZV9M4rortiS8Uwb/jFrYMGZnYYIw90eRVTOVInSjoCwguaBoj 3jF5kW/zMdwSLGItCGcX8nQU6bHAlI7xcdDxBcQJhTQw4WmaT5LA2IliO/R5a7gOFMLL SNmSjDqiEoLF+NAWL56uI/GgZujSoc5AK6HHaPIPFDHB8WnXp8t7bXPSlM013zCxqA28 g36w== 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=HQyCNtObz/CHES/izu3WVW9+3N8D8WjoiNW6uwgUcpdHJie4fik0hXfW+i2PkBcjmk 2TzfiTLUZ2Y6tilyCZt1NqjNyrjRDwmfGKkfSJO3iYNgtiPiI3D8yqBv1VkxCDuNZM9k Ln378KHPkrxoU5U9BlpbzfVaYpwM6Qk9QYo3sc8+/9RqrYj13Wa0So7dXajvGQc6107Z lPhQvwMK+aW16+cirVb8PrQZ/xSmJX3WUqmX6ICKehoYbQjPwHkbmYoBdzJTKr+V8P3v GLMKm0ox9spmnbI15x8z/dUQHsrvBCfmX0HwoPFlTPBaZYSOUMEEF8Mfj7RJDnXWkerk dYsg== X-Gm-Message-State: AOAM532YTsTJQvaF7+PNPaNz/1GsuRsIpQjppv9YVYyKVNjSkRxYAKHh 2U8lY3FgKCZSIyZc4wCTiZzGtO4b X-Google-Smtp-Source: ABdhPJz6BGKC+aduAM16A2OzBUJ3F55tetCpqZWImgd9HSK+tnuub34KKSyiwHWRG80aU/TXm7mFnQ== X-Received: by 2002:a1c:2dcb:: with SMTP id t194mr4485530wmt.94.1596214333744; Fri, 31 Jul 2020 09:52:13 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-421-163.w2-6.abo.wanadoo.fr. [2.6.84.163]) by smtp.googlemail.com with ESMTPSA id t14sm15169134wrg.38.2020.07.31.09.52.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:52:13 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org, Christian Couder , Junio C Hamano Cc: Thomas Gummerer , Son Luong Ngoc , Alban Gruin Subject: [PATCH v3 4/6] stash: remove the second index in save_untracked_files() Date: Fri, 31 Jul 2020 18:51:38 +0200 Message-Id: <20200731165140.29197-5-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731165140.29197-1-alban.gruin@gmail.com> References: <20200630151558.20975-1-alban.gruin@gmail.com> <20200731165140.29197-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 Fri Jul 31 16:51:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11695261 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 1A0BB138C for ; Fri, 31 Jul 2020 16:52:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1B13206D8 for ; Fri, 31 Jul 2020 16:52:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BA9J6wTC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387426AbgGaQwS (ORCPT ); Fri, 31 Jul 2020 12:52:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732474AbgGaQwR (ORCPT ); Fri, 31 Jul 2020 12:52:17 -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 8710DC061574 for ; Fri, 31 Jul 2020 09:52:17 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id r12so28543488wrj.13 for ; Fri, 31 Jul 2020 09:52:17 -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=Nmk/a46wDPiuPdytJXRv0WBj/NMxzrSWV7Y0q1I+K3Q=; b=BA9J6wTCqymiAF3jFZfJdOsaOsHf0Cvp8EdZ5p7lQVezEKP31Chkz7IzVcpuM9Ta59 ffr4QiQT06X9UebYct/5Xt6ArVI5enbLWMTyS0D1fZfNMbatdpDBn+moCjcIqzQjYRFO LEoEBWkKHqwb98EgjkE8ciLzuqgiYuM8ITCKZFoX9elQ+y7ajUR7Yk1Kp8srdAMsLGOb ElxlrIu2DJp2lqFgT/ametR98/5vgf1rY6trhY8odVtfXehZBdXGPLiiqGIjoUZurOI2 XTXMhkaDtZ40fz/OSvlOTOjAN3pEeP0F1x+PYXMXQ/DVd0i+gNR3oMAEKjnG88v77BqN KH6g== 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=Nmk/a46wDPiuPdytJXRv0WBj/NMxzrSWV7Y0q1I+K3Q=; b=Attw6D0bUYD3Ho7e2av1yvIoe3Tfwjmc0EqYcm24BTOCZW2jweVPFq4LiM6sfszXsg YwKRD5avb2PjP2x0Vu6iriiGiqO7K2isZtRxnEwHAk5F57E9it3G/nRyts+NwsM9/RKW xRA13ueEHNBuiuWwic76Qk6LyDYU2WCNlVbhVYXiLTQ/9H36q4A55k0lC+X+PTKUOVBq qYzpThkCyFUtqO5p4hfcQbVGlstEJ2QQmkI9uPisM7MsFFoeaOVMxH4DBGguwvK9bv1W D6z603MTeexgEir13VqwUEsZrfeWf2/nPrQ15HlZaaHaqoF+MZswqc++m0QH0g5PMCA5 RxlQ== X-Gm-Message-State: AOAM531ps21+Upz1hD9rVh5gVgro8tS6MlJ3c0Y+1EglwGUu7lLj3aCL Hmx4p3E6GPK7PLu1Zfu0LLR+W9lb X-Google-Smtp-Source: ABdhPJygSFIfvzVAPJVNjrkj3EUGD5SEXgPAK0/DBHYFMT9I0WzOWKytKNCb7qDCqNYljleYSaD+ww== X-Received: by 2002:adf:df06:: with SMTP id y6mr4113292wrl.89.1596214335983; Fri, 31 Jul 2020 09:52:15 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-421-163.w2-6.abo.wanadoo.fr. [2.6.84.163]) by smtp.googlemail.com with ESMTPSA id t14sm15169134wrg.38.2020.07.31.09.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:52:15 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org, Christian Couder , Junio C Hamano Cc: Thomas Gummerer , Son Luong Ngoc , Alban Gruin Subject: [PATCH v3 5/6] stash: remove the second index in restore_untracked() Date: Fri, 31 Jul 2020 18:51:39 +0200 Message-Id: <20200731165140.29197-6-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731165140.29197-1-alban.gruin@gmail.com> References: <20200630151558.20975-1-alban.gruin@gmail.com> <20200731165140.29197-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 exits. 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 Fri Jul 31 16:51:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban Gruin X-Patchwork-Id: 11695265 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 1B2B0138C for ; Fri, 31 Jul 2020 16:52:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 034A92245C for ; Fri, 31 Jul 2020 16:52:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pAr+No3S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387541AbgGaQwU (ORCPT ); Fri, 31 Jul 2020 12:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387455AbgGaQwT (ORCPT ); Fri, 31 Jul 2020 12:52:19 -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 4670EC061574 for ; Fri, 31 Jul 2020 09:52:19 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id 3so9841544wmi.1 for ; Fri, 31 Jul 2020 09:52:19 -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=pAr+No3SLxUxFtxeQuYhFQ0iyZRfEhO9j0Jidrmwkkd1iTekIvhFNZ2lK4hrHnTTo3 0P5fyrPFbB+u9HAD2UR6ianWEUrdpzA2VyL3M7qKQf2lIXS1hnznWpL9nqqlAOkJq0xq u5+5OIPgndubGG3RpT2s4pI9vnnlGa/Kg67xiptiuiTEpZET5oTcvgiPzp+GeSg1MYi7 erszyKVXMaQELjCGTFd0v++wqq+0U+IqsDGyR95ymly4PDxrDpxiACVHsdjZlbW08oxz fxyZwDJGf59g7hF0ABwU9/sqSSipPMuqoH9/fBcAkzwOPR+rB2zJq2i6C6LDOElnxtbQ UX9Q== 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=nUENf/+zqHW2YyvJotOaklsmsToH1RkpTzQ8xtXv1glH47bqoCRl5yDaEdwXypZbcm q0+dpzZPZeDx9Z0t+quVX5a+BumqFpdOdDy2+iwsqpRiIDs7ae/Ug8r35Wz3Kby+x6D/ XrPnN3NylNGiLUqXEBDqbOnwW+mvGLhXQnj4oYZZlIuIJPDbGes16Gh1ZnX5djOx5Wmv zQj+wkWal922FVP+RmUEAWfn6dMiyhdyZHM0r7KOeYj67YIL80hTEBmJt+lnvHt++s92 zTeLPD+sJ4UbEti1Z3axW+8bYhmNGq/8ZxU7NbPiU/LcrCYoRcag2zkBeVYLytsvc/9R 7Dgg== X-Gm-Message-State: AOAM530twLVK6wUmFkL77wfSghUusp58tc3ArYompP9N+9+/wZj78+xG ugX+BJ+pOJVR/VIsZLmf1WNzGfYd X-Google-Smtp-Source: ABdhPJxKkez2HTYFzCXGI98ufhvRXd/sNBA9fetpmAk7/1XQuTa9hBGfGi0N+t+PFKmtdNhCm3+F9Q== X-Received: by 2002:a1c:7306:: with SMTP id d6mr4354029wmb.113.1596214337810; Fri, 31 Jul 2020 09:52:17 -0700 (PDT) Received: from ylate.lan (atoulouse-654-1-421-163.w2-6.abo.wanadoo.fr. [2.6.84.163]) by smtp.googlemail.com with ESMTPSA id t14sm15169134wrg.38.2020.07.31.09.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:52:17 -0700 (PDT) From: Alban Gruin To: git@vger.kernel.org, Christian Couder , Junio C Hamano Cc: Thomas Gummerer , Son Luong Ngoc , Alban Gruin Subject: [PATCH v3 6/6] stash: remove `stash_index_path' Date: Fri, 31 Jul 2020 18:51:40 +0200 Message-Id: <20200731165140.29197-7-alban.gruin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200731165140.29197-1-alban.gruin@gmail.com> References: <20200630151558.20975-1-alban.gruin@gmail.com> <20200731165140.29197-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"))