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

[PATCH] checkout: don't check worktrees when not necessary

From
SBSpencer Baugh <sbaugh@catern.com>
Date
May 31, 2015, 23:16 UTC
Message-ID
<1433114189-9779-1-git-send-email-sbaugh@catern.com>

When --patch or pathspecs are passed to git checkout, the working tree will not be switching branch, so there's no need to check if the branch that we are running checkout on is already checked out.

Signed-off-by: Spencer Baugh <sbaugh@catern.com>
---
 builtin/checkout.c | 1 +
 1 file changed, 1 insertion(+)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2f92328..7039c5c 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1237,6 +1237,7 @@ static int parse_branchname_arg(int argc, const char **argv,
 		char *head_ref = resolve_refdup("HEAD", 0, sha1, &flag);
 		if (head_ref &&
 		    (!(flag & REF_ISSYMREF) || strcmp(head_ref, new->path)) &&
+		    !(opts->patch_mode || opts->pathspec.nr) &&
 		    !opts->ignore_other_worktrees)
 			check_linked_checkouts(new);
 		free(head_ref);
-- 
2.4.2.339.g77bd3ea
Next: Duy Nguyen
Message 1 of 5 in “checkout: don't check worktrees when not necessary”
  1. checkout: don't check worktrees when not necessarySpencer Baugh, May 31, 2015
  2. Duy NguyenJun 1, 2015
  3. Spencer BaughJun 10, 2015
  4. checkout: don't check worktrees when not necessaryNguyễn Thái Ngọc Duy, Jun 12, 2015
  5. Junio C HamanoJun 12, 2015

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.