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

[PATCH v6 2/6] Add git_env_ulong() to parse environment variable

From
Steffen Prohaska <prohaska@zib.de>
Date
Aug 26, 2014, 15:23 UTC
Message-ID
<1409066605-4851-3-git-send-email-prohaska@zib.de>
In-Reply-To
<1409066605-4851-1-git-send-email-prohaska@zib.de>

The new function will be used to parse GIT_MMAP_LIMIT and GIT_ALLOC_LIMIT.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
---
 cache.h  |  1 +
 config.c | 11 +++++++++++
 2 files changed, 12 insertions(+)
diff --git a/cache.h b/cache.h
index fcb511d..b820b6a 100644
--- a/cache.h
+++ b/cache.h
@@ -1318,6 +1318,7 @@ extern int git_config_rename_section_in_file(const char *, const char *, const c
 extern const char *git_etc_gitconfig(void);
 extern int check_repository_format_version(const char *var, const char *value, void *cb);
 extern int git_env_bool(const char *, int);
+extern unsigned long git_env_ulong(const char *, unsigned long);
 extern int git_config_system(void);
 extern int config_error_nonbool(const char *);
 #if defined(__GNUC__)
diff --git a/config.c b/config.c
index 058505c..178721f 100644
--- a/config.c
+++ b/config.c
@@ -1122,6 +1122,17 @@ int git_env_bool(const char *k, int def)
 	return v ? git_config_bool(k, v) : def;
 }
 
+/*
+ * Use default if environment variable is unset or empty string.
+ */
+unsigned long git_env_ulong(const char *k, unsigned long val)
+{
+	const char *v = getenv(k);
+	if (v && *v && !git_parse_ulong(v, &val))
+		die("failed to parse %s", k);
+	return val;
+}
+
 int git_config_system(void)
 {
 	return !git_env_bool("GIT_CONFIG_NOSYSTEM", 0);
-- 
2.1.0.8.gf3a29c8
Previous: Steffen ProhaskaNext: Jeff King
Message 3 of 19 in “Stream fd to clean filter; GIT_MMAP_LIMIT, GIT_ALLOC_LIMIT with git_env_ulong()”
  1. 0/6 Stream fd to clean filter; GIT_MMAP_LIMIT, GIT_ALLOC_LIMIT with git_env_ulong()Steffen Prohaska, Aug 26, 2014
  2. 1/6 convert: drop arguments other than 'path' from would_convert_to_git()Steffen Prohaska, Aug 26, 2014
  3. 2/6 Add git_env_ulong() to parse environment variableSteffen Prohaska, Aug 26, 2014
  4. Jeff KingAug 26, 2014
  5. Junio C HamanoAug 26, 2014
  6. Jeff KingAug 26, 2014
  7. Junio C HamanoAug 26, 2014
  8. Jeff KingAug 27, 2014
  9. Junio C HamanoAug 27, 2014
  10. Steffen ProhaskaAug 28, 2014
  11. Junio C HamanoAug 28, 2014
  12. 3/6 Change GIT_ALLOC_LIMIT check to use git_env_ulong()Steffen Prohaska, Aug 26, 2014
  13. 4/6 Introduce GIT_MMAP_LIMIT to allow testing expected mmap sizeSteffen Prohaska, Aug 26, 2014
  14. 5/6 Change copy_fd() to not close input fdSteffen Prohaska, Aug 26, 2014
  15. Junio C HamanoAug 26, 2014
  16. Jeff KingAug 26, 2014
  17. Steffen ProhaskaAug 28, 2014
  18. Junio C HamanoAug 28, 2014
  19. 6/6 convert: stream from fd to required clean filter to reduce used address spaceSteffen Prohaska, Aug 26, 2014

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.