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

[StGit PATCH 6/6] Let some commands work with detached HEAD

From
Karl Hasselström <kha@treskal.com>
Date
Oct 8, 2007, 08:55 UTC
Message-ID
<20071008085540.9734.60137.stgit@yoghurt>
In-Reply-To
<20071008085430.9734.75797.stgit@yoghurt>

add, diff, resolved, and status didn't use the crt_series that was initialized for them. So don't initialize it, since that means (1) less work and (2) they won't fail when HEAD is detached.

Note that this doesn't completely fix the problem with detached HEAD: a number of other commands (e.g. branch) don't always need to refer to a current series, but currently fails on a detached HEAD even in those situations.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/commands/add.py      |    2 +-
 stgit/commands/diff.py     |    2 +-
 stgit/commands/resolved.py |    2 +-
 stgit/commands/status.py   |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/stgit/commands/add.py b/stgit/commands/add.py
index 264ab9f..ceea188 100644
--- a/stgit/commands/add.py
+++ b/stgit/commands/add.py
@@ -31,7 +31,7 @@ Add the files or directories passed as arguments to the
 repository. When a directory name is given, all the files and
 subdirectories are recursively added."""
 
-directory = DirectoryHasRepository()
+directory = DirectoryHasRepository(needs_current_series = False)
 options = []
 
 
diff --git a/stgit/commands/diff.py b/stgit/commands/diff.py
index 42e8367..9ffbb4a 100644
--- a/stgit/commands/diff.py
+++ b/stgit/commands/diff.py
@@ -42,7 +42,7 @@ rev = '([patch][//[bottom | top]]) | <tree-ish> | base'
 If neither bottom nor top are given but a '//' is present, the command
 shows the specified patch (defaulting to the current one)."""
 
-directory = DirectoryHasRepository()
+directory = DirectoryHasRepository(needs_current_series = False)
 options = [make_option('-r', '--range',
                        metavar = 'rev1[..[rev2]]', dest = 'revs',
                        help = 'show the diff between revisions'),
diff --git a/stgit/commands/resolved.py b/stgit/commands/resolved.py
index c2ef678..8b2aba2 100644
--- a/stgit/commands/resolved.py
+++ b/stgit/commands/resolved.py
@@ -34,7 +34,7 @@ Mark a merge conflict as resolved. The conflicts can be seen with the
 'C'. This command also removes any <file>.{ancestor,current,patched}
 files."""
 
-directory = DirectoryHasRepository()
+directory = DirectoryHasRepository(needs_current_series = False)
 options = [make_option('-a', '--all',
                        help = 'mark all conflicts as solved',
                        action = 'store_true'),
diff --git a/stgit/commands/status.py b/stgit/commands/status.py
index a688f7e..360fabf 100644
--- a/stgit/commands/status.py
+++ b/stgit/commands/status.py
@@ -40,7 +40,7 @@ under revision control. The files are prefixed as follows:
 A 'refresh' command clears the status of the modified, new and deleted
 files."""
 
-directory = DirectoryHasRepository()
+directory = DirectoryHasRepository(needs_current_series = False)
 options = [make_option('-m', '--modified',
                        help = 'show modified files only',
                        action = 'store_true'),
Previous: Karl HasselströmNext: Karl Hasselström
Message 7 of 12 in “Survive capital punishment”
  1. 0/6 Survive capital punishmentKarl Hasselström, Oct 8, 2007
  2. 1/6 Allow caller to customize title of error/warning messageKarl Hasselström, Oct 8, 2007
  3. 2/6 Use our nice message printout wrapping systemKarl Hasselström, Oct 8, 2007
  4. 3/6 Properly detect that HEAD is detachedKarl Hasselström, Oct 8, 2007
  5. 4/6 Refactor crt_series creationKarl Hasselström, Oct 8, 2007
  6. 5/6 Don't have a global crt_series in stgit.commans.commonKarl Hasselström, Oct 8, 2007
  7. 6/6 Let some commands work with detached HEADKarl Hasselström, Oct 8, 2007
  8. Karl HasselströmOct 8, 2007
  9. New test: "stg diff"Karl Hasselström, Oct 9, 2007
  10. Karl HasselströmOct 9, 2007
  11. Karl HasselströmOct 8, 2007
  12. Karl HasselströmOct 8, 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.