νλ‘μ νΈκ° ν¬λ μλ ν¨μμ μ μλ ν¨μκ° νΈμΆλλ κ³³μ κ²μν΄μΌ νλ κ²½μ°κ° λ§λ€. ν¨μμ νμ€ν 리λ₯Ό μ°Ύμ보기λ νλ€. Gitμ λ°μ΄ν°λ² μ΄μ€μ μ μ₯λ μ½λλ 컀λ°μμ μνλ λΆλΆμ λΉ λ₯΄κ³ μ½κ² κ²μνλ λκ΅¬κ° μ¬λ¬ κ°μ§ μμΌλ©° μμΌλ‘ ν¨κ» μ΄ν΄λ³΄μ.
Gitμ grep λͺ
λ Ήμ μ΄μ©νλ©΄ μ»€λ° νΈλ¦¬μ λ΄μ©μ΄λ μνΉ λλ ν 리μ λ΄μ©μ λ¬Έμμ΄μ΄λ μ κ·ννμμ μ΄μ©ν΄ μ½κ² μ°Ύμ μ μλ€.
Git μμ€λ₯Ό μλ‘ λ€μ΄ λͺ
λ Ήμ μ΄λ»κ² μ¬μ©νλμ§ μμ보μ.
κΈ°λ³Έμ μΌλ‘ λμμ μ§μ νμ§ μμΌλ©΄ μνΉ λλ ν 리μ νμΌμμ μ°Ύλλ€.
λͺ
λ Ήμ μ€νν λ -n λλ --line-number μ΅μ
μ μΆκ°νλ©΄ μ°Ύμ λ¬Έμμ΄μ΄ μμΉν λΌμΈ λ²νΈλ κ°μ΄ μΆλ ₯νλ€.
$ git grep -n gmtime_r
compat/gmtime.c:3:#undef gmtime_r
compat/gmtime.c:8: return git_gmtime_r(timep, &result);
compat/gmtime.c:11:struct tm *git_gmtime_r(const time_t *timep, struct tm *result)
compat/gmtime.c:16: ret = gmtime_r(timep, result);
compat/mingw.c:826:struct tm *gmtime_r(const time_t *timep, struct tm *result)
compat/mingw.h:206:struct tm *gmtime_r(const time_t *timep, struct tm *result);
date.c:482: if (gmtime_r(&now, &now_tm))
date.c:545: if (gmtime_r(&time, tm)) {
date.c:758: /* gmtime_r() in match_digit() may have clobbered it */
git-compat-util.h:1138:struct tm *git_gmtime_r(const time_t *, struct tm *);
git-compat-util.h:1140:#define gmtime_r git_gmtime_rgit grep λͺ
λ Ήμμ μΈλ§ν λͺ κ°μ§ μ΅μ
μ μ’ λ μ΄ν΄λ³΄μ.
μλ₯Ό λ€μ΄ μμ κ²°κ³Ό λμ μ΄λ€ νμΌμμ λͺ κ°λ μ°Ύμλμ§λ§ μκ³ μΆλ€λ©΄ -c λλ --count μ΅μ
μ μ΄μ©νλ€.
$ git grep --count gmtime_r
compat/gmtime.c:4
compat/mingw.c:1
compat/mingw.h:1
date.c:3
git-compat-util.h:2λ§€μΉλλ λΌμΈμ΄ μλ ν¨μλ λ©μλλ₯Ό μ°Ύκ³ μΆλ€λ©΄ -p λλ --show-function μ΅μ
μ μ€λ€.
$ git grep -p gmtime_r *.c
date.c=static int match_multi_number(timestamp_t num, char c, const char *date,
date.c: if (gmtime_r(&now, &now_tm))
date.c=static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt)
date.c: if (gmtime_r(&time, tm)) {
date.c=int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset)
date.c: /* gmtime_r() in match_digit() may have clobbered it */gmtime_r ν¨μλ₯Ό date.c νμΌμμ match_multi_number, match_digit ν¨μμμ νΈμΆνκ³ μλ€λ κ±Έ νμΈν μ μλ€(μΈ λ²μ§Έλ‘ νΈμΆνλ κ²°κ³Όλ μ£Όμ μμ μλ κ²μ νμΈν μ μλ€).
--and μ΅μ
μ μ΄μ©ν΄μ μ¬λ¬ λ¨μ΄κ° ν λΌμΈμ λμμ λνλλ μ€ μ°ΎκΈ° κ°μ 볡μ‘ν μ‘°ν©μΌλ‘ κ²μν μ μλ€.
μλ₯Ό λ€μ΄ βLINKβ λ βBUF_MAXβ λ μ€ νλλ₯Ό ν¬ν¨ν μμ μ μλ₯Ό 1.8.0 μ΄μ λ²μ μ Git μμ€ μ½λμμ κ²μνλ κ²μ ν μ μλ€(--break μ --heading μ΅μ
μ λΆμ¬ λ μ½κΈ° μ¬μ΄ ννλ‘ μλΌμ μΆλ ₯ν μλ μλ€).
$ git grep --break --heading \
-n -e '#define' --and \( -e LINK -e BUF_MAX \) v1.8.0
v1.8.0:builtin/index-pack.c
62:#define FLAG_LINK (1u<<20)
v1.8.0:cache.h
73:#define S_IFGITLINK 0160000
74:#define S_ISGITLINK(m) (((m) & S_IFMT) == S_IFGITLINK)
v1.8.0:environment.c
54:#define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS
v1.8.0:strbuf.c
326:#define STRBUF_MAXLINK (2*PATH_MAX)
v1.8.0:symlinks.c
53:#define FL_SYMLINK (1 << 2)
v1.8.0:zlib.c
30:/* #define ZLIB_BUF_MAX ((uInt)-1) */
31:#define ZLIB_BUF_MAX ((uInt) 1024 * 1024 * 1024) /* 1GB */git grep λͺ
λ Ήμ grep μ΄λ ack κ°μ μΌλ°μ μΈ κ²μ λκ΅¬λ³΄λ€ λͺ κ°μ§ μ’μ μ μ΄ μλ€.
μ°μ λ§€μ° λΉ λ₯΄λ€. λν, μνΉ λλ ν 리λ§μ΄ μλλΌ Git νμ€ν 리 λ΄μ μ΄λ ν μ 보λΌλ μ°ΎμλΌ μ μλ€.
μμ μμ μμ μ΄μ λ²μ μ μμ€μμλ νΉμ λ¨μ΄λ₯Ό μ°ΎμλΈ κ²μ λ³Ό μ μλ€.
μ΄λ€ λ³μκ° μ΄λμ μλμ§λ₯Ό μ°Ύμ보λ κ² μλλΌ, νμ€ν 리μμ μΈμ μΆκ°λκ±°λ λ³κ²½λλμ§ μ°Ύμλ³Ό μλ μλ€.
git log λͺ
λ Ήμ μ΄μ©νλ©΄ Diff λ΄μ©λ κ²μνμ¬ μ΄λ€ 컀λ°μμ μ°Ύκ³ μ νλ λ΄μ©μ μΆκ°νλμ§ μ°Ύμ μ μλ€.
ZLIB_BUF_MAX λΌλ μμκ° κ°μ₯ μ²μ λνλ λλ₯Ό μ°Ύλ λ¬Έμ λΌλ©΄ -S μ΅μ
(βpickaxe(곑κ΄μ΄)β μ΅μ
μ΄λΌ νλ€)μ μ΄μ©ν΄ ν΄λΉ λ¬Έμμ΄μ΄ μΆκ°λ 컀λ°κ³Ό μμ΄μ§ 컀λ°λ§ κ²μν μ μλ€.
$ git log -S ZLIB_BUF_MAX --oneline
e01503b zlib: allow feeding more than 4GB in one go
ef49a7a zlib: zlib can only process 4GB at a timeμ λ 컀λ°μ λ³κ²½ μ¬νμ μ΄ν΄λ³΄λ©΄ ef49a7a μμ ZLIB_BUF_MAX μμκ° μ²μ λμ€κ³ e01503b μμλ λ³κ²½λ κ²μ μ μ μλ€.
λ μΈμΈν 쑰건μ κ±Έμ΄ μ°Ύκ³ μΆλ€λ©΄ λ‘κ·Έλ₯Ό κ²μν λ -G μ΅μ
μΌλ‘ μ κ·ννμμ μ¨μ κ²μνλ©΄ λλ€.
μ§μ§ λ―ΈμΉ λ―μ΄ μ’μ λ‘κ·Έ κ²μ λκ΅¬κ° λ μλ€. λΌμΈ νμ€ν 리 κ²μμ΄λ€.
git log λ₯Ό μΈ λ -L μ΅μ
μ λΆμ΄λ©΄ μ΄λ€ ν¨μλ ν λΌμΈμ νμ€ν 리λ₯Ό λ³Ό μ μλ€.
μλ₯Ό λ€μ΄, zlib.c νμΌμ μλ git_deflate_bound ν¨μμ λͺ¨λ λ³κ²½ μ¬νλ€μ 보길 μνλ€κ³ μκ°ν΄λ³΄μ. git log -L :git_deflate_bound:zlib.c λΌκ³ λͺ
λ Ή μ€ννλ©΄ λλ€.
μ΄ λͺ
λ Ήμ μ€ννλ©΄ ν¨μμ μμκ³Ό λμ μΈμν΄μ ν¨μμμ μΌμ΄λ λͺ¨λ νμ€ν 리λ₯Ό ν¨μκ° μ²μ λ§λ€μ΄μ§ λλΆν° Patchλ₯Ό λμ΄νμ¬ λ³΄μ¬μ€λ€.
$ git log -L :git_deflate_bound:zlib.c
commit ef49a7a0126d64359c974b4b3b71d7ad42ee3bca
Author: Junio C Hamano <gitster@pobox.com>
Date: Fri Jun 10 11:52:15 2011 -0700
zlib: zlib can only process 4GB at a time
diff --git a/zlib.c b/zlib.c
--- a/zlib.c
+++ b/zlib.c
@@ -85,5 +130,5 @@
-unsigned long git_deflate_bound(z_streamp strm, unsigned long size)
+unsigned long git_deflate_bound(git_zstream *strm, unsigned long size)
{
- return deflateBound(strm, size);
+ return deflateBound(&strm->z, size);
}
commit 225a6f1068f71723a910e8565db4e252b3ca21fa
Author: Junio C Hamano <gitster@pobox.com>
Date: Fri Jun 10 11:18:17 2011 -0700
zlib: wrap deflateBound() too
diff --git a/zlib.c b/zlib.c
--- a/zlib.c
+++ b/zlib.c
@@ -81,0 +85,5 @@
+unsigned long git_deflate_bound(z_streamp strm, unsigned long size)
+{
+ return deflateBound(strm, size);
+}
+Gitμ΄ ν¨μμ μ²μκ³Ό λμ μΈμνμ§ λͺ»ν λλ μ κ·ννμμΌλ‘ μΈμνκ² ν μλ μλ€.
git log -L '/unsigned long git_deflate_bound/',/^}/:zlib.c λͺ
λ ΉμΌλ‘ μμ κ°μ κ²°κ³Όλ₯Ό λ³Ό μ μλ€.
ν λΌμΈμ νμ€ν λ¦¬λ§ κ²μν μλ μκ³ μ¬λ¬ λΌμΈμ κ±ΈμΉ νμ€ν 리λ₯Ό κ²μν μλ μλ€.