From: Karl Hasselström Date: Sun, 7 Oct 2007 22:14:11 +0000 (+0200) Subject: Make "stg refresh" subdirectory safe X-Git-Tag: v0.14~48 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/2299c463794f214b750ecc33e24779243ddc5aff?ds=inline Make "stg refresh" subdirectory safe 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 --- 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 &&