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>
This commit is contained in:
Prathamesh Chavan
2017-06-08 23:38:12 +05:30
committed by Junio C Hamano
parent b06d364310
commit e0556a928f
4 changed files with 15 additions and 21 deletions

3
dir.h
View File

@ -196,6 +196,9 @@ struct dir_struct {
unsigned unmanaged_exclude_files;
};
/*Count the number of slashes for string s*/
extern int count_slashes(const char *s);
/*
* The ordering of these constants is significant, with
* higher-numbered match types signifying "closer" (i.e. more