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

[PATCHv3 06/11] Makefile: split GIT_USER_AGENT from GIT-CFLAGS

From
Jeff King <peff@peff.net>
Date
Jun 20, 2012, 18:31 UTC
Message-ID
<20120620183151.GF30995@sigill.intra.peff.net>
In-Reply-To
<20120620182855.GA26948@sigill.intra.peff.net>

The default user-agent depends on the GIT_VERSION, which means that anytime you switch versions, it causes a full rebuild. Instead, let's split it out into its own file and restrict the dependency to version.o.

Signed-off-by: Jeff King <peff@peff.net>
---
 .gitignore |  1 +
 Makefile   | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/.gitignore b/.gitignore
index bf66648..7329cfe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 /GIT-CFLAGS
 /GIT-LDFLAGS
 /GIT-GUI-VARS
+/GIT-USER-AGENT
 /GIT-VERSION-FILE
 /bin-wrappers/
 /git
diff --git a/Makefile b/Makefile
index 336cfc4..7518ad7 100644
--- a/Makefile
+++ b/Makefile
@@ -1925,7 +1925,11 @@ endif
 GIT_USER_AGENT_SQ = $(subst ','\'',$(GIT_USER_AGENT))
 GIT_USER_AGENT_CQ = "$(subst ",\",$(subst \,\\,$(GIT_USER_AGENT)))"
 GIT_USER_AGENT_CQ_SQ = $(subst ','\'',$(GIT_USER_AGENT_CQ))
-BASIC_CFLAGS += -DGIT_USER_AGENT='$(GIT_USER_AGENT_CQ_SQ)'
+GIT-USER-AGENT: FORCE
+	@if test x'$(GIT_USER_AGENT_SQ)' != x"`cat GIT-USER-AGENT 2>/dev/null`"; then \
+		echo >&2 "    * new user-agent flag"; \
+		echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \
+	fi
 
 ALL_CFLAGS += $(BASIC_CFLAGS)
 ALL_LDFLAGS += $(BASIC_LDFLAGS)
@@ -1990,8 +1994,10 @@ builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
 	'-DGIT_MAN_PATH="$(mandir_SQ)"' \
 	'-DGIT_INFO_PATH="$(infodir_SQ)"'
 
+version.sp version.s version.o: GIT-USER-AGENT
 version.sp version.s version.o: EXTRA_CPPFLAGS = \
-	'-DGIT_VERSION="$(GIT_VERSION)"'
+	'-DGIT_VERSION="$(GIT_VERSION)"' \
+	'-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)'
 
 $(BUILT_INS): git$X
 	$(QUIET_BUILT_IN)$(RM) $@ && \
@@ -2722,6 +2728,7 @@ ifndef NO_TCLTK
 	$(MAKE) -C git-gui clean
 endif
 	$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
+	$(RM) GIT-USER-AGENT
 
 .PHONY: all install profile-clean clean strip
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
-- 
1.7.11.5.gc0eeaa8
Previous: Jeff KingNext: Jonathan Nieder
Message 51 of 84 in “git version statistics”
  1. Jeff KingMay 31, 2012
  2. Jeff KingMay 31, 2012
  3. Junio C HamanoMay 31, 2012
  4. Jeff KingJun 1, 2012
  5. Junio C HamanoJun 1, 2012
  6. Jeff KingJun 2, 2012
  7. Tomas CarneckyJun 2, 2012
  8. Jeff KingJun 2, 2012
  9. 1/4 move git_version_string into version.cJeff King, Jun 2, 2012
  10. 2/4 version: add git_user_agent functionJeff King, Jun 2, 2012
  11. Thomas RastJun 19, 2012
  12. Jeff KingJun 19, 2012
  13. Jeff KingJun 19, 2012
  14. 1/3 Makefile: apply dependencies consistently to sparse/asm targetsJeff King, Jun 19, 2012
  15. Junio C HamanoJun 19, 2012
  16. 2/3 Makefile: split GIT_USER_AGENT from GIT-CFLAGSJeff King, Jun 19, 2012
  17. Junio C HamanoJun 19, 2012
  18. 3/3 Makefile: split prefix flags from GIT-CFLAGSJeff King, Jun 19, 2012
  19. Junio C HamanoJun 19, 2012
  20. Jeff KingJun 19, 2012
  21. Junio C HamanoJun 19, 2012
  22. Jeff KingJun 19, 2012
  23. Junio C HamanoJun 19, 2012
  24. Jeff KingJun 19, 2012
  25. 0/8 makefile cleanupsJeff King, Jun 19, 2012
  26. 1/8 Makefile: apply dependencies consistently to sparse/asm targetsJeff King, Jun 19, 2012
  27. Jonathan NiederJun 20, 2012
  28. Jeff KingJun 20, 2012
  29. Jonathan NiederJun 20, 2012
  30. Jeff KingJun 20, 2012
  31. Jeff KingJun 20, 2012
  32. 01/11 Makefile: sort LIB_H listJeff King, Jun 20, 2012
  33. Junio C HamanoJun 20, 2012
  34. Jeff KingJun 20, 2012
  35. 02/11 Makefile: fold MISC_H into LIB_HJeff King, Jun 20, 2012
  36. Junio C HamanoJun 20, 2012
  37. Jonathan NiederJun 20, 2012
  38. Jeff KingJun 20, 2012
  39. 5/11 Makefile: fold XDIFF_H and VCSSVN_H into LIB_HJonathan Nieder, Jul 7, 2012
  40. Junio C HamanoJul 9, 2012
  41. Jonathan NiederJul 6, 2012
  42. 03/11 Makefile: do not have git.o depend on common-cmds.hJeff King, Jun 20, 2012
  43. Jonathan NiederJun 20, 2012
  44. 04/11 Makefile: apply dependencies consistently to sparse/asm targetsJeff King, Jun 20, 2012
  45. Jonathan NiederJun 20, 2012
  46. Jeff KingJun 20, 2012
  47. Makefile: document ground rules for target-specific dependenciesJonathan Nieder, Jul 7, 2012
  48. 05/11 Makefile: do not replace @@GIT_USER_AGENT@@ in scriptsJeff King, Jun 20, 2012
  49. Junio C HamanoJun 20, 2012
  50. Jeff KingJun 20, 2012
  51. 06/11 Makefile: split GIT_USER_AGENT from GIT-CFLAGSJeff King, Jun 20, 2012
  52. Jonathan NiederJun 20, 2012
  53. Jeff KingJun 20, 2012
  54. Jonathan NiederJun 20, 2012
  55. 06/11 Makefile: split GIT_USER_AGENT from GIT-CFLAGSJonathan Nieder, Jul 7, 2012
  56. 07/11 Makefile: split prefix flags from GIT-CFLAGSJeff King, Jun 20, 2012
  57. Jonathan NiederJun 20, 2012
  58. Jeff KingJun 20, 2012
  59. 08/11 Makefile: do not replace @@GIT_VERSION@@ in shell scriptsJeff King, Jun 20, 2012
  60. 09/11 Makefile: update scripts when build-time parameters changeJeff King, Jun 20, 2012
  61. 10/11 Makefile: build instaweb similar to other scriptsJeff King, Jun 20, 2012
  62. 11/11 Makefile: move GIT-VERSION-FILE dependencies closer to useJeff King, Jun 20, 2012
  63. Jonathan NiederJun 20, 2012
  64. Jonathan NiederJun 20, 2012
  65. Jeff KingJun 20, 2012
  66. Jonathan NiederJun 20, 2012
  67. Jeff KingJun 20, 2012
  68. Jonathan NiederJun 20, 2012
  69. Automatic dependency tracking in the Git build system (was: Re: [PATCHv2 1/8] Makefile: apply dependencies consistently to sparse/asm targets)Stefano Lattarini, Jun 21, 2012
  70. Junio C HamanoJun 20, 2012
  71. Thomas RastJun 20, 2012
  72. Jeff KingJun 21, 2012
  73. Junio C HamanoJun 21, 2012
  74. 2/8 Makefile: do not replace @@GIT_USER_AGENT@@ in scriptsJeff King, Jun 19, 2012
  75. 3/8 Makefile: split GIT_USER_AGENT from GIT-CFLAGSJeff King, Jun 19, 2012
  76. 4/8 Makefile: split prefix flags from GIT-CFLAGSJeff King, Jun 19, 2012
  77. 5/8 Makefile: do not replace @@GIT_VERSION@@ in shell scriptsJeff King, Jun 19, 2012
  78. 6/8 Makefile: update scripts when build-time parameters changeJeff King, Jun 19, 2012
  79. 7/8 Makefile: build instaweb similar to other scriptsJeff King, Jun 19, 2012
  80. 8/8 Makefile: move GIT-VERSION-FILE dependencies closer to useJeff King, Jun 19, 2012
  81. 3/4 http: get default user-agent from git_user_agentJeff King, Jun 2, 2012
  82. 4/4 include agent identifier in capability stringJeff King, Jun 2, 2012
  83. Stephen BashMay 31, 2012
  84. Jeff KingJun 1, 2012

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.