Skip to content

Hard coded string length cleanup

Nguyễn Thái Ngọc Duy git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest12 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12Make starts_with() a wrapper of skip_prefix()git-compat-util.h strbuf.c+5 -102 replies
2/12Convert starts_with() to skip_prefix() for option parsingbuiltin/fetch-pack.c builtin/index-pack.c builtin/ls-remote.c +12 more+182 -1718 replies
3/12Add and use skip_prefix_defval()builtin/checkout.c builtin/fast-export.c builtin/merge.c +5 more+24 -332 replies
4/12Replace some use of starts_with() with skip_prefix()builtin/branch.c pretty.c setup.c +2 more+7 -120 replies
5/12Convert a lot of starts_with() to skip_prefix()builtin/for-each-ref.c builtin/mailinfo.c builtin/merge.c +14 more+64 -660 replies
6/12fetch.c: replace some use of starts_with() with skip_prefix()builtin/fetch.c+5 -110 replies
7/12connect.c: replace some use of starts_with() with skip_prefix()connect.c+3 -30 replies
8/12refs.c: replace some use of starts_with() with skip_prefix()refs.c+2 -30 replies
9/12diff.c: reduce code duplication in --stat-xxx parsingdiff.c+25 -420 replies
10/12environment.c: replace starts_with() in strip_namespace() with skip_prefix()environment.c+1 -30 replies
11/12diff.c: convert diff_scoreopt_parse to use skip_prefix()diff.c+14 -140 replies
12/12refs.c: use skip_prefix() in prune_ref()refs.c+2 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/12] Hard coded string length cleanup

I reimplemented skip_prefix() again just to realize this function already exists. Which reminds me there are a bunch of places that could benefit from this function, the same reason that I wanted to reimplement it.

So this is series to make it more popular (so hopefully I'll see it used somewhere and know that it exists) and the code cleaner. The pattern "compare a string, then skip the compared part by a hard coded string length" is almost killed. I left a few in places for those who want to contribute :)

Nguyễn Thái Ngọc Duy (12):
Make starts_with() a wrapper of skip_prefix()
Convert starts_with() to skip_prefix() for option parsing
Add and use skip_prefix_defval()
Replace some use of starts_with() with skip_prefix()
Convert a lot of starts_with() to skip_prefix()
fetch.c: replace some use of starts_with() with skip_prefix() connect.c: replace some use of starts_with() with skip_prefix() refs.c: replace some use of starts_with() with skip_prefix() diff.c: reduce code duplication in --stat-xxx parsing environment.c: replace starts_with() in strip_namespace() with skip_prefix() diff.c: convert diff_scoreopt_parse to use skip_prefix() refs.c: use skip_prefix() in prune_ref()

 builtin/branch.c         |   3 +-
 builtin/checkout.c       |   6 +-
 builtin/fast-export.c    |   3 +-
 builtin/fetch-pack.c     |  13 ++--
 builtin/fetch.c          |  16 ++---
 builtin/for-each-ref.c   |   9 +--
 builtin/index-pack.c     |  17 +++---
 builtin/ls-remote.c      |   9 +--
 builtin/mailinfo.c       |  11 ++--
 builtin/merge.c          |  12 ++--
 builtin/reflog.c         |   9 +--
 builtin/remote.c         |   3 +-
 builtin/rev-parse.c      |  41 ++++++-------
 builtin/send-pack.c      |  18 +++---
 builtin/show-branch.c    |  14 ++---
 builtin/unpack-objects.c |   5 +-
 builtin/update-ref.c     |  21 +++----
 commit.c                 |   5 +-
 connect.c                |   6 +-
 daemon.c                 |  75 +++++++++++------------
 diff.c                   | 153 +++++++++++++++++++++--------------------------
 environment.c            |   4 +-
 fetch-pack.c             |   9 +--
 git-compat-util.h        |  15 ++++-
 git.c                    |  16 ++---
 http-backend.c           |   5 +-
 http-push.c              |   6 +-
 http.c                   |   5 +-
 log-tree.c               |   5 +-
 merge-recursive.c        |  13 ++--
 notes.c                  |   6 +-
 pager.c                  |   2 +-
 pathspec.c               |   5 +-
 pretty.c                 |   3 +-
 refs.c                   |  20 ++++---
 revision.c               |  60 +++++++++----------
 setup.c                  |   3 +-
 sha1_name.c              |  12 +---
 strbuf.c                 |   9 ---
 tag.c                    |   7 +--
 transport-helper.c       |  15 +++--
 transport.c              |  14 +++--
 upload-pack.c            |   5 +-
 wt-status.c              |  15 ++---
 44 files changed, 334 insertions(+), 369 deletions(-)
Signature · 1 line
1.8.5.1.208.g019362e