diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2016-04-07 15:02:56 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-10 11:35:15 -0700 |
commit | 37da4227b27771cd9947b7393851975a311e6eb9 (patch) | |
tree | 3ba5b26c2cd3c37fe71c02f317602d979bba053e /refs | |
parent | 419c6f4c76c5950a33ed2cedbce9c6f7d66773f6 (diff) | |
download | git-37da4227b27771cd9947b7393851975a311e6eb9.tar.gz |
resolve_ref_unsafe(): use for loop to count up to MAXDEPTH
The loop's there anyway; we might as well use it.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs')
-rw-r--r-- | refs/files-backend.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index c0cf6fd6c0..101abba8d1 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1400,8 +1400,8 @@ static const char *resolve_ref_1(const char *refname, struct strbuf *sb_path, struct strbuf *sb_contents) { - int depth = MAXDEPTH; int bad_name = 0; + int symref_count; if (flags) *flags = 0; @@ -1425,17 +1425,13 @@ static const char *resolve_ref_1(const char *refname, */ bad_name = 1; } - for (;;) { + + for (symref_count = 0; symref_count < MAXDEPTH; symref_count++) { const char *path; struct stat st; char *buf; int fd; - if (--depth < 0) { - errno = ELOOP; - return NULL; - } - strbuf_reset(sb_path); strbuf_git_path(sb_path, "%s", refname); path = sb_path->buf; @@ -1566,6 +1562,9 @@ static const char *resolve_ref_1(const char *refname, bad_name = 1; } } + + errno = ELOOP; + return NULL; } const char *resolve_ref_unsafe(const char *refname, int resolve_flags, |