summaryrefslogtreecommitdiff
path: root/apply.c
diff options
context:
space:
mode:
authorPrathamesh Chavan <pc44800@gmail.com>2017-06-08 18:08:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-12 20:26:55 (GMT)
commite0556a928fdba489307d13d8d4c4d2a461fbc3ad (patch)
treef460fa671a19aa903c800cc611b9e7ed5ba1f304 /apply.c
parentb06d3643105c8758ed019125a4399cb7efdcce2c (diff)
downloadgit-e0556a928fdba489307d13d8d4c4d2a461fbc3ad.zip
git-e0556a928fdba489307d13d8d4c4d2a461fbc3ad.tar.gz
git-e0556a928fdba489307d13d8d4c4d2a461fbc3ad.tar.bz2
dir: create function count_slashes()
Similar functions exist in apply.c and builtin/show-branch.c for counting the number of slashes in a string. Also in the later patches, we introduce a third caller for the same. Hence, we unify it now by cleaning the existing functions and declaring a common function count_slashes in dir.h and implementing it in dir.c to remove this code duplication. Mentored-by: Christian Couder <christian.couder@gmail.com> Mentored-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Prathamesh Chavan <pc44800@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'apply.c')
-rw-r--r--apply.c11
1 files changed, 0 insertions, 11 deletions
diff --git a/apply.c b/apply.c
index e6dbab2..27d5dc0 100644
--- a/apply.c
+++ b/apply.c
@@ -762,17 +762,6 @@ static char *find_name_traditional(struct apply_state *state,
return find_name_common(state, line, def, p_value, line + len, 0);
}
-static int count_slashes(const char *cp)
-{
- int cnt = 0;
- char ch;
-
- while ((ch = *cp++))
- if (ch == '/')
- cnt++;
- return cnt;
-}
-
/*
* Given the string after "--- " or "+++ ", guess the appropriate
* p_value for the given patch.