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

[PATCH v2 1/5] core.aheadbehind: add new config setting

From
JHJeff Hostetler <git@jeffhostetler.com>
Date
Dec 21, 2017, 19:09 UTC
Message-ID
<20171221190909.62995-2-git@jeffhostetler.com>
In-Reply-To
<20171221190909.62995-1-git@jeffhostetler.com>
From: Jeff Hostetler <jeffhost@microsoft.com>

Created core.aheadbehind config setting and core_ahead_behind global variable. This value defaults to true.

This value will be used in the next few commits as the default value for the --ahead-behind parameter.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
---
 Documentation/config.txt | 8 ++++++++
 cache.h                  | 1 +
 config.c                 | 5 +++++
 environment.c            | 1 +
 4 files changed, 15 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 9593bfa..c78d6be 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -895,6 +895,14 @@ core.abbrev::
 	abbreviated object names to stay unique for some time.
 	The minimum length is 4.
 
+core.aheadbehind::
+	If true, tells commands like status and branch to print ahead and
+	behind counts for the branch relative to its upstream branch.
+	This computation may be very expensive when there is a great
+	distance between the two branches.  If false, these commands
+	only print that the two branches refer to different commits.
+	Defaults to true.
+
 add.ignoreErrors::
 add.ignore-errors (deprecated)::
 	Tells 'git add' to continue adding files when some files cannot be
diff --git a/cache.h b/cache.h
index 6440e2b..5757d8f 100644
--- a/cache.h
+++ b/cache.h
@@ -735,6 +735,7 @@ extern int assume_unchanged;
 extern int prefer_symlink_refs;
 extern int warn_ambiguous_refs;
 extern int warn_on_object_refname_ambiguity;
+extern int core_ahead_behind;
 extern const char *apply_default_whitespace;
 extern const char *apply_default_ignorewhitespace;
 extern const char *git_attributes_file;
diff --git a/config.c b/config.c
index c38401a..6a4b49c 100644
--- a/config.c
+++ b/config.c
@@ -1241,6 +1241,11 @@ static int git_default_core_config(const char *var, const char *value)
 		return 0;
 	}
 
+	if (!strcmp(var, "core.aheadbehind")) {
+		core_ahead_behind = git_config_bool(var, value);
+		return 0;
+	}
+
 	/* Add other config variables here and to Documentation/config.txt. */
 	return 0;
 }
diff --git a/environment.c b/environment.c
index 8289c25..5822c15 100644
--- a/environment.c
+++ b/environment.c
@@ -25,6 +25,7 @@ int prefer_symlink_refs;
 int is_bare_repository_cfg = -1; /* unspecified */
 int warn_ambiguous_refs = 1;
 int warn_on_object_refname_ambiguity = 1;
+int core_ahead_behind = 1;
 int ref_paranoia = -1;
 int repository_format_precious_objects;
 const char *git_commit_encoding;
-- 
2.9.3
Previous: Jeff HostetlerNext: Igor Djordjevic
Message 2 of 20 in “Add --no-ahead-behind to status”
  1. 0/5 Add --no-ahead-behind to statusJeff Hostetler, Dec 21, 2017
  2. 1/5 core.aheadbehind: add new config settingJeff Hostetler, Dec 21, 2017
  3. Igor DjordjevicDec 21, 2017
  4. Jonathan NiederDec 21, 2017
  5. Junio C HamanoDec 22, 2017
  6. Jeff KingDec 24, 2017
  7. Junio C HamanoDec 27, 2017
  8. Jeff KingJan 4, 2018
  9. Lars SchneiderApr 3, 2018
  10. Ævar Arnfjörð BjarmasonApr 3, 2018
  11. Derrick StoleeApr 3, 2018
  12. Jeff HostetlerApr 3, 2018
  13. Jeff HostetlerJan 2, 2018
  14. Jonathan NiederJan 2, 2018
  15. 3/5 status: add --[no-]ahead-behind to porcelain V2 outputJeff Hostetler, Dec 21, 2017
  16. Jonathan NiederDec 21, 2017
  17. 4/5 status: update short status to use --no-ahead-behindJeff Hostetler, Dec 21, 2017
  18. 5/5 status: support --no-ahead-behind in long formatJeff Hostetler, Dec 21, 2017
  19. 2/5 stat_tracking_info: return +1 when branches are not equalJeff Hostetler, Dec 21, 2017
  20. Jonathan NiederDec 21, 2017

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.