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

[StGit PATCH 5/5] Make "stg refresh" subdirectory safe

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

Make "stg refresh" 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 refresh subroutine should instead be safe to run from a subdirectory. However, refreshing from a subdirectory currently only refreshes changes that are in the index, and not changes in the working directory, and that has to be fixed.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/commands/refresh.py |    2 +-
 t/t2300-refresh-subdir.sh |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py
index b283892..f032375 100644
--- a/stgit/commands/refresh.py
+++ b/stgit/commands/refresh.py
@@ -37,7 +37,7 @@ options. The '--force' option is useful when a commit object was
 created with a different tool but the changes need to be included in
 the current patch."""
 
-directory = DirectoryHasRepository()
+directory = DirectoryGotoToplevel()
 options = [make_option('-f', '--force',
                        help = 'force the refresh even if HEAD and '\
                        'top differ',
diff --git a/t/t2300-refresh-subdir.sh b/t/t2300-refresh-subdir.sh
index d1c7168..bdd27c5 100755
--- a/t/t2300-refresh-subdir.sh
+++ b/t/t2300-refresh-subdir.sh
@@ -15,7 +15,7 @@ test_expect_success 'Refresh from a subdirectory' '
     [ "$(stg status)" = "" ]
 '
 
-test_expect_failure 'Refresh again' '
+test_expect_success 'Refresh again' '
     echo foo2 >> foo.txt &&
     echo bar2 >> bar/bar.txt &&
     cd bar &&
Previous: Karl Hasselström
Message 6 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.