git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGit PATCH 3/5] Make "stg push" subdirectory safe

From
Karl Hasselström <kha@treskal.com>
Date
Oct 7, 2007, 23:24 UTC
Message-ID
<20071007232453.13070.2930.stgit@yoghurt>
In-Reply-To
<20071007231949.13070.49517.stgit@yoghurt>

Make "stg push" subdirectory safe by letting it internally cd up to the top of the worktree. This is possibly not the best long-term fix; one could argue that the push subroutine should instead be safe to run from a subdirectory. However, pushing from a subdirectory currently erases the parts of a patch that doesn't touch that subdirectory, and that has to be fixed.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/commands/push.py |    2 +-
 t/t1205-push-subdir.sh |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/stgit/commands/push.py b/stgit/commands/push.py
index b91bc5e..4d5de26 100644
--- a/stgit/commands/push.py
+++ b/stgit/commands/push.py
@@ -39,7 +39,7 @@ command run.
 The command also notifies when the patch becomes empty (fully merged
 upstream) or is modified (three-way merged) by the 'push' operation."""
 
-directory = DirectoryHasRepository()
+directory = DirectoryGotoToplevel()
 options = [make_option('-a', '--all',
                        help = 'push all the unapplied patches',
                        action = 'store_true'),
diff --git a/t/t1205-push-subdir.sh b/t/t1205-push-subdir.sh
index 6502c20..f9a84f6 100755
--- a/t/t1205-push-subdir.sh
+++ b/t/t1205-push-subdir.sh
@@ -27,7 +27,7 @@ test_expect_success 'Fast-forward push from a subdir' '
     [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
 '
 
-test_expect_failure 'Modifying push from a subdir' '
+test_expect_success 'Modifying push from a subdir' '
     stg pop &&
     [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
     [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
@@ -42,7 +42,7 @@ test_expect_failure 'Modifying push from a subdir' '
     [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
 '
 
-test_expect_failure 'Conflicting push from subdir' '
+test_expect_success 'Conflicting push from subdir' '
     stg pop p1 p2 &&
     [ "$(echo $(cat x.txt))" = "x0" ] &&
     [ "$(echo $(cat foo/y.txt))" = "y0" ] &&
Previous: Karl HasselströmNext: Karl Hasselström
Message 4 of 6 in “Make push and refresh subdirectory safe”
  1. 0/5 Make push and refresh subdirectory safeKarl Hasselström, Oct 7, 2007
  2. 1/5 Infrastructure for current directory handlingKarl Hasselström, Oct 7, 2007
  3. 2/5 New test: Try "stg push" in a subdirectoryKarl Hasselström, Oct 7, 2007
  4. 3/5 Make "stg push" subdirectory safeKarl Hasselström, Oct 7, 2007
  5. 4/5 New test: try "stg refresh" in a subdirectoryKarl Hasselström, Oct 7, 2007
  6. 5/5 Make "stg refresh" subdirectory safeKarl Hasselström, Oct 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.