Merge branch 'di/parse-options-split'
authorJunio C Hamano <gitster@pobox.com>
Thu, 25 Aug 2011 23:00:20 +0000 (16:00 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 25 Aug 2011 23:00:20 +0000 (16:00 -0700)
* di/parse-options-split:
Reduce parse-options.o dependencies
parse-options: export opterr, optbug

1  2 
Makefile
setup.c
diff --combined Makefile
index 89cc6245a721a1cb807e197fb3346cec02367a51,7d47bdba96c726fb8a38fe28476a41d6c190d0ae..7149d46e9cd3922b3912f6df82cacb67e2d9358e
+++ b/Makefile
@@@ -30,15 -30,15 +30,15 @@@ all:
  # Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
  #
 -# Define NO_CURL if you do not have libcurl installed.  git-http-pull and
 +# Define NO_CURL if you do not have libcurl installed.  git-http-fetch and
  # git-http-push are not built, and you cannot use http:// and https://
 -# transports.
 +# transports (neither smart nor dumb).
  #
  # Define CURLDIR=/foo/bar if your curl header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
  #
  # Define NO_EXPAT if you do not have expat installed.  git-http-push is
 -# not built, and you cannot push using http:// and https:// transports.
 +# not built, and you cannot push using http:// and https:// transports (dumb).
  #
  # Define EXPATDIR=/foo/bar if your expat header and library files are in
  # /foo/bar/include and /foo/bar/lib directories.
@@@ -642,6 -642,7 +642,7 @@@ LIB_OBJS += pack-revindex.
  LIB_OBJS += pack-write.o
  LIB_OBJS += pager.o
  LIB_OBJS += parse-options.o
+ LIB_OBJS += parse-options-cb.o
  LIB_OBJS += patch-delta.o
  LIB_OBJS += patch-ids.o
  LIB_OBJS += path.o
@@@ -1876,7 -1877,7 +1877,7 @@@ ifndef NO_CUR
        GIT_OBJS += http.o http-walker.o remote-curl.o
  endif
  XDIFF_OBJS = xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
 -      xdiff/xmerge.o xdiff/xpatience.o
 +      xdiff/xmerge.o xdiff/xpatience.o xdiff/xhistogram.o
  VCSSVN_OBJS = vcs-svn/string_pool.o vcs-svn/line_buffer.o \
        vcs-svn/repo_tree.o vcs-svn/fast_export.o vcs-svn/svndump.o
  VCSSVN_TEST_OBJS = test-obj-pool.o test-string-pool.o \
@@@ -2204,7 -2205,7 +2205,7 @@@ test-delta$X: diff-delta.o patch-delta.
  
  test-line-buffer$X: vcs-svn/lib.a
  
- test-parse-options$X: parse-options.o
+ test-parse-options$X: parse-options.o parse-options-cb.o
  
  test-string-pool$X: vcs-svn/lib.a
  
diff --combined setup.c
index 2c51a9a4c7665ce786e58e312c55f9f8b4bca6ae,3463819b161028e221837c193036d920b77d5847..ca7ee496e59580487043344eb9907528ef33aa5c
+++ b/setup.c
@@@ -40,34 -40,6 +40,6 @@@ char *prefix_path(const char *prefix, i
        return sanitized;
  }
  
- /*
-  * Unlike prefix_path, this should be used if the named file does
-  * not have to interact with index entry; i.e. name of a random file
-  * on the filesystem.
-  */
- const char *prefix_filename(const char *pfx, int pfx_len, const char *arg)
- {
-       static char path[PATH_MAX];
- #ifndef WIN32
-       if (!pfx_len || is_absolute_path(arg))
-               return arg;
-       memcpy(path, pfx, pfx_len);
-       strcpy(path + pfx_len, arg);
- #else
-       char *p;
-       /* don't add prefix to absolute paths, but still replace '\' by '/' */
-       if (is_absolute_path(arg))
-               pfx_len = 0;
-       else if (pfx_len)
-               memcpy(path, pfx, pfx_len);
-       strcpy(path + pfx_len, arg);
-       for (p = path + pfx_len; *p; p++)
-               if (*p == '\\')
-                       *p = '/';
- #endif
-       return path;
- }
  int check_filename(const char *prefix, const char *arg)
  {
        const char *name;
@@@ -264,38 -236,6 +236,38 @@@ const char **get_pathspec(const char *p
        return pathspec;
  }
  
 +const char *pathspec_prefix(const char *prefix, const char **pathspec)
 +{
 +      const char **p, *n, *prev;
 +      unsigned long max;
 +
 +      if (!pathspec)
 +              return prefix ? xmemdupz(prefix, strlen(prefix)) : NULL;
 +
 +      prev = NULL;
 +      max = PATH_MAX;
 +      for (p = pathspec; (n = *p) != NULL; p++) {
 +              int i, len = 0;
 +              for (i = 0; i < max; i++) {
 +                      char c = n[i];
 +                      if (prev && prev[i] != c)
 +                              break;
 +                      if (!c || c == '*' || c == '?')
 +                              break;
 +                      if (c == '/')
 +                              len = i+1;
 +              }
 +              prev = n;
 +              if (len < max) {
 +                      max = len;
 +                      if (!max)
 +                              break;
 +              }
 +      }
 +
 +      return max ? xmemdupz(prev, max) : NULL;
 +}
 +
  /*
   * Test if it looks like we're at a git directory.
   * We want to see: