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

[PATCH] worktree: initialize return value for submodule_uses_worktrees

From
Stefan Beller <sbeller@google.com>
Date
Dec 27, 2016, 17:50 UTC
Message-ID
<20161227175013.12747-1-sbeller@google.com>
In-Reply-To
<7E1C7387-4F37-423F-803D-3B5690B49D40@gmail.com>

When the worktrees directory is empty, the `ret` will be returned uninitialized. Fix it by initializing the value.

Signed-off-by: Stefan Beller <sbeller@google.com>
---

This goes on top of 1a248cf (origin/sb/submodule-embed-gitdir); ideally to be squashed, but as it is in next already, as a separate patch.

Thanks, Stefan

 worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/worktree.c b/worktree.c
index d4606aa8cd..828fd7a0ad 100644
--- a/worktree.c
+++ b/worktree.c
@@ -387,7 +387,7 @@ int submodule_uses_worktrees(const char *path)
 	struct strbuf sb = STRBUF_INIT;
 	DIR *dir;
 	struct dirent *d;
-	int ret;
+	int ret = 0;
 	struct repository_format format;
 
 	submodule_gitdir = git_pathdup_submodule(path, "%s", "");
-- 
2.11.0.rc2.50.g8bda6b2.dirty
Previous: Stefan BellerNext: Junio C Hamano
Message 7 of 10 in “What's cooking in git.git (Dec 2016, #07; Thu, 22)”
  1. Junio C HamanoDec 22, 2016
  2. Duy NguyenDec 23, 2016
  3. Junio C HamanoDec 23, 2016
  4. Duy NguyenDec 24, 2016
  5. Lars SchneiderDec 23, 2016
  6. Stefan BellerDec 26, 2016
  7. worktree: initialize return value for submodule_uses_worktreesStefan Beller, Dec 27, 2016
  8. Junio C HamanoDec 27, 2016
  9. Stefan BellerDec 27, 2016
  10. Junio C HamanoDec 27, 2016

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.