Merge branch 'jc/subdir'
authorJunio C Hamano <junkio@cox.net>
Wed, 30 Nov 2005 19:09:33 +0000 (11:09 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 30 Nov 2005 19:09:33 +0000 (11:09 -0800)
1  2 
git-diff.sh
http-push.c
setup.c
diff --combined git-diff.sh
index 7baf7044e440e6d052f5e92e1008f710dd319c67,e45f50ec224d2b0ee23780a00dd351746665a9a2..b62e58341cd9d11fc893613949426126871531e2
@@@ -7,6 -7,13 +7,11 @@@ rev=$(git-rev-parse --revs-only --no-fl
  flags=$(git-rev-parse --no-revs --flags --sq "$@")
  files=$(git-rev-parse --no-revs --no-flags --sq "$@")
  
 -: ${flags:="'-M' '-p'"}
 -
+ die () {
+     echo >&2 "$*"
+     exit 1
+ }
  # I often say 'git diff --cached -p' and get scolded by git-diff-files, but
  # obviously I mean 'git diff --cached -p HEAD' in that case.
  case "$rev" in
        esac
  esac
  
 +# If we do not have --name-status, --name-only nor -r, default to -p.
 +# If we do not have -B nor -C, default to -M.
 +case " $flags " in
 +*" '--name-status' "* | *" '--name-only' "* | *" '-r' "* )
 +      ;;
 +*)
 +      flags="$flags'-p' " ;;
 +esac
 +case " $flags " in
 +*" '-"[BCM]* | *" '--find-copies-harder' "*)
 +      ;; # something like -M50.
 +*)
 +      flags="$flags'-M' " ;;
 +esac
 +
  case "$rev" in
  ?*' '?*' '?*)
        echo >&2 "I don't understand"
diff --combined http-push.c
index fc013ec139bd066a4d32357d7508d10c82b6f873,c6e782cbed88edd68a764eac2f86887758dbec00..fe925609b4024119c6171dd32350a6570bea8516
@@@ -1008,7 -1008,9 +1008,7 @@@ static int unlock_remote(struct active_
        if (lock->owner != NULL)
                free(lock->owner);
        free(lock->url);
 -/* Freeing the token causes a segfault...
        free(lock->token);
 -*/
        free(lock);
  
        return rc;
@@@ -1237,6 -1239,7 +1237,7 @@@ int main(int argc, char **argv
        int rc = 0;
        int i;
  
+       setup_git_directory();
        setup_ident();
  
        remote = xmalloc(sizeof(*remote));
                break;
        }
  
 +      if (!remote->url)
 +              usage(http_push_usage);
 +
        memset(remote_dir_exists, 0, 256);
  
        http_init();
diff --combined setup.c
index 3286a568ed4c7d4c82bb18d779f05518fe05c9b3,bde590f7cc8ce3a6b218d22c81497da1159ac825..d3556edf121ba78b0b83d20fdbd9cb397e79eb2b
+++ b/setup.c
@@@ -47,6 -47,21 +47,21 @@@ const char *prefix_path(const char *pre
        return path;
  }
  
+ /* 
+  * 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];
+       if (!pfx || !*pfx || arg[0] == '/')
+               return arg;
+       memcpy(path, pfx, pfx_len);
+       strcpy(path + pfx_len, arg);
+       return path;
+ }
  const char **get_pathspec(const char *prefix, const char **pathspec)
  {
        const char *entry = *pathspec;
@@@ -92,7 -107,7 +107,7 @@@ static int is_toplevel_directory(void
        return 1;
  }
  
static const char *setup_git_directory_1(void)
const char *setup_git_directory_gently(int *nongit_ok)
  {
        static char cwd[PATH_MAX+1];
        int len, offset;
                if (validate_symref(path))
                        goto bad_dir_environ;
                if (getenv(DB_ENVIRONMENT)) {
 -                      if (access(DB_ENVIRONMENT, X_OK))
 +                      if (access(getenv(DB_ENVIRONMENT), X_OK))
                                goto bad_dir_environ;
                }
                else {
                        break;
                chdir("..");
                do {
-                       if (!offset)
+                       if (!offset) {
+                               if (nongit_ok) {
+                                       if (chdir(cwd))
+                                               die("Cannot come back to cwd");
+                                       *nongit_ok = 1;
+                                       return NULL;
+                               }
                                die("Not a git repository");
+                       }
                } while (cwd[--offset] != '/');
        }
  
@@@ -172,7 -194,7 +194,7 @@@ int check_repository_format(void
  
  const char *setup_git_directory(void)
  {
-       const char *retval = setup_git_directory_1();
+       const char *retval = setup_git_directory_gently(NULL);
        check_repository_format();
        return retval;
  }