Skip to content

Commit 20fc9bc

Browse files
Nick HengeveldJunio C Hamano
authored andcommitted
Set HTTP user agent to git/GIT_VERSION
Useful for diagnostics/troubleshooting to know which client versions are hitting your server. Signed-off-by: Nick Hengeveld <nickh@reactrix.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 7fa8ddd commit 20fc9bc

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ git$X git.spec \
510510
exec_cmd.o: exec_cmd.c
511511
$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
512512

513+
http.o: http.c
514+
$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
515+
513516
git-%$X: %.o $(GITLIBS)
514517
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
515518

http.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ static CURL* get_curl_handle(void)
195195
if (getenv("GIT_CURL_VERBOSE"))
196196
curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
197197

198+
curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);
199+
198200
return result;
199201
}
200202

0 commit comments

Comments
 (0)