From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1504236829D for ; Fri, 25 Sep 2026 04:12:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790309575; cv=none; b=Bzw4Uh6yN20bLRoxaW14KpzYkXUBDPnbWfqam9LX1Bh4gabx9zlEgv7mgP3i1YSfjUGXoOPsCQRQDOh5UDlCU1hnGG/NL9Vce5EZscTDC00G9EtM5CA1QbrZ0Rhfe5013ydc5W2Sgl1j+VmhhwmRkU+ivyy+Rdgwz6ysT/N2l24= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790309575; c=relaxed/simple; bh=z0I61EQ8TAxkAS4sEF3vtAvrfYPHyRq+b1FPf4T+MtY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=OkI2XqkLnYAFxNF20086fpXOU+rX9DaxYJBjVbnH+CpTMJ901c9jfRE/LlWkg2iF7tFDpxGUdd5q06WoQkUwt+jE6n+z4Vr9HP7GFLKw/RLvHn9ZHRgx6h/cdPk0OMRIp1Wn3LGJNgTuQyVTdOFEbzjxNxq1bnEzvx3sHOFCFWQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=bUdwQjWJ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=LkFQf4nP; arc=none smtp.client-ip=202.12.124.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="bUdwQjWJ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="LkFQf4nP" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.stl.internal (Postfix) with ESMTP id 04D907A0068; Fri, 25 Sep 2026 00:12:51 -0400 (EDT) Received: from phl-frontend-02 ([10.202.2.161]) by phl-compute-09.internal (MEProxy); Fri, 25 Sep 2026 00:12:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1790309571; x=1790395971; bh=6cwnmQnbLr a4inAtUBS9uVHYUPOZ/maIkWPfHyyRyrQ=; b=bUdwQjWJa+aDm2kQsHzHi//VoR 8HH4dEEghDtKCrJsXDq3XF/E+P0ZrIokFHk7ra1sJdJSZCepmU4irApezDoSPKJL QPMc/FlB9BAr03EPFG2nVo5DUzggkwf9dLX+aFrBjVGZ3bfGrolO+HuiaPTiJ4Oa 0RQioeMvnL/6S35Z1v1/i8RRvhNCerl2wVuScXNzLhI8EfC3HhQlRbywQtImV3BB 0J4ds4hQIEzawlQXO4sRO3LlGo3uabepY2tnRus9Xgmysk59j+ZOy5sz1VwhmKUh KVl+LgYujYSXul2mpd2OyM64LsdhUC4zHz/5v5V2gVZ6m3QAZtiIJgn1VJ+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1790309571; x=1790395971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x2ldviYq1LOPp7xB7CWA/nIJocG4qWhwfVJ3EoxYHdr5MnQkThcs0xwNuQ X-ME-Proxy: Feedback-ID: if26b431b:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Sep 2026 00:12:50 -0400 (EDT) From: Junio C Hamano To: "D. Ben Knoble" Cc: git@vger.kernel.org, Eli Barzilay , Phillip Wood , Johannes Schindelin , Patrick Steinhardt , Elijah Newren , Adam Johnson , Victoria Dye , Jeff King , Derrick Stolee , =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Subject: Re: [PATCH v2 4/4] builtin/stash: merge index in-core In-Reply-To: (Junio C. Hamano's message of "Thu, 24 Sep 2026 14:59:15 -0700") References: Date: Thu, 24 Sep 2026 21:12:49 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Junio C Hamano writes: > The new test in the attached patch will fail with this step but if > we revert the changes to builtin/stash.c in this step, it passes. Oh, and with the change to the code, it passes again. diff --git i/builtin/stash.c w/builtin/stash.c index 219ca457be..44d962cc5d 100644 --- i/builtin/stash.c +++ w/builtin/stash.c @@ -639,7 +639,7 @@ static enum stash_apply_result do_apply_stash(const char *prefix, merge = lookup_tree(o.repo, &info->i_tree); merge_base = lookup_tree(o.repo, &info->b_tree); - merge_incore_nonrecursive(&o, head, merge, merge_base, + merge_incore_nonrecursive(&o, merge_base, merge, head, &result); if (!result.clean) diff --git i/t/t3903-stash.sh w/t/t3903-stash.sh index 3958ab3c8d..0a87e62b11 100755 --- i/t/t3903-stash.sh +++ w/t/t3903-stash.sh @@ -374,6 +374,38 @@ test_expect_success 'stash apply -q --index refreshes the index' ' test_cmp expect actual ' + +test_expect_success 'stash apply --index does not revert unrelated upstream index changes' ' + test_when_finished "rm -fr playpen" && + mkdir playpen && + ( + cd playpen && + git init && + echo "base1" >file1 && + echo "base2" >file2 && + git add file1 file2 && + git commit -m "initial base" && + + # Make a staged change to file1 and stash it + echo "staged1" >file1 && + git add file1 && + git stash && + + # Upstream advances by modifying unrelated file2 + echo "upstream2" >file2 && + git add file2 && + git commit -m "upstream change to file2" && + + # Apply the stash with --index + git stash apply --index && + + # Verify working tree and index state + test "$(git show :file1)" = "staged1" && + test "$(git show :file2)" = "upstream2" && + test "$(git show HEAD:file2)" = "upstream2" + ) +' + test_expect_success 'stash apply --index leaves everything untouched on failure' ' git reset --hard && echo test >other-file &&