From: Catalin Marinas <catalin.marinas@gmail.com>
To: git@vger.kernel.org
Cc: "Karl Hasselström" <kha@treskal.com>,
"Jeenu Viswambharan" <Jeenu.Viswambharan@arm.com>
Subject: [StGit PATCH] Restore the original applied patches during 'commit'
Date: Sat, 15 May 2010 12:03:05 +0100 [thread overview]
Message-ID: <20100515110305.12922.25133.stgit@toshiba-laptop> (raw)
If committing a patch in the middle of a series, the resulting stack
doesn't have any patches applied. The trans.pop_patches() function only
returns the additional patches that had to be popped rather than all
popped patches. The patch also adds some tests for the 'commit' command.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
Reported-by: Jeenu Viswambharan <Jeenu.Viswambharan@arm.com>
Cc: Karl Hasselström <kha@treskal.com>
---
stgit/commands/commit.py | 8 ++++++--
t/t1303-commit.sh | 21 +++++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/stgit/commands/commit.py b/stgit/commands/commit.py
index 7bdd8c6..b21c85f 100644
--- a/stgit/commands/commit.py
+++ b/stgit/commands/commit.py
@@ -87,9 +87,13 @@ def func(parser, options, args):
for i in xrange(min(len(stack.patchorder.applied), len(patches))):
if stack.patchorder.applied[i] == patches[i]:
common_prefix += 1
+ else:
+ break
if common_prefix < len(patches):
- to_push = trans.pop_patches(
- lambda pn: pn in stack.patchorder.applied[common_prefix:])
+ to_push = [pn for pn in stack.patchorder.applied[common_prefix:]
+ if pn not in patches[common_prefix:]]
+ # this pops all the applied patches from common_prefix
+ trans.pop_patches(lambda pn: pn in to_push)
for pn in patches[common_prefix:]:
trans.push_patch(pn, iw)
else:
diff --git a/t/t1303-commit.sh b/t/t1303-commit.sh
index d53b9f2..2d85078 100755
--- a/t/t1303-commit.sh
+++ b/t/t1303-commit.sh
@@ -6,6 +6,27 @@ test_expect_success 'Initialize the StGIT repository' '
stg init
'
+test_expect_success 'Commit middle patch' '
+ stg new -m p1 &&
+ stg new -m p2 &&
+ stg new -m p3 &&
+ stg new -m p4 &&
+ stg pop &&
+ stg commit p2 &&
+ test "$(echo $(stg series))" = "+ p1 > p3 - p4"
+'
+
+test_expect_success 'Commit first patch' '
+ stg commit &&
+ test "$(echo $(stg series))" = "> p3 - p4"
+'
+
+test_expect_success 'Commit all patches' '
+ stg push &&
+ stg commit -a &&
+ test "$(echo $(stg series))" = ""
+'
+
# stg commit with top != head should not succeed, since the committed
# patches are poptentially lost.
test_expect_success 'Commit when top != head (should fail)' '
reply other threads:[~2010-05-15 11:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100515110305.12922.25133.stgit@toshiba-laptop \
--to=catalin.marinas@gmail.com \
--cc=Jeenu.Viswambharan@arm.com \
--cc=git@vger.kernel.org \
--cc=kha@treskal.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).