Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Thu, 21 May 2009 01:59:09 +0000 (18:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 May 2009 01:59:09 +0000 (18:59 -0700)
* maint:
grep: fix word-regexp colouring
completion: use git rev-parse to detect bare repos
Cope better with a _lot_ of packs
for-each-ref: fix segfault in copy_email

1  2 
contrib/completion/git-completion.bash
sha1_file.c
index ba13c4948cffe9df31d2d6d5a223a29e23b4817a,f44152c4331bb6a2de764e6dcc98c1ac39e517e5..0c8bb536c84f04627e78f251f51aea11b2048ce5
@@@ -132,7 -132,7 +132,7 @@@ __git_ps1 (
                local c
  
                if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
-                       if [ "true" = "$(git config --bool core.bare 2>/dev/null)" ]; then
+                       if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
                                c="BARE:"
                        else
                                b="GIT_DIR!"
@@@ -1334,35 -1334,6 +1334,35 @@@ _git_send_email (
        COMPREPLY=()
  }
  
 +__git_config_get_set_variables ()
 +{
 +      local prevword word config_file= c=$COMP_CWORD
 +      while [ $c -gt 1 ]; do
 +              word="${COMP_WORDS[c]}"
 +              case "$word" in
 +              --global|--system|--file=*)
 +                      config_file="$word"
 +                      break
 +                      ;;
 +              -f|--file)
 +                      config_file="$word $prevword"
 +                      break
 +                      ;;
 +              esac
 +              prevword=$word
 +              c=$((--c))
 +      done
 +
 +      for i in $(git --git-dir="$(__gitdir)" config $config_file --list \
 +                      2>/dev/null); do
 +              case "$i" in
 +              *.*)
 +                      echo "${i/=*/}"
 +                      ;;
 +              esac
 +      done
 +}
 +
  _git_config ()
  {
        local cur="${COMP_WORDS[COMP_CWORD]}"
                __gitcomp "$(__git_merge_strategies)"
                return
                ;;
 -      color.branch|color.diff|color.interactive|color.status|color.ui)
 +      color.branch|color.diff|color.interactive|\
 +      color.showbranch|color.status|color.ui)
                __gitcomp "always never auto"
                return
                ;;
                __gitcomp "$__git_send_email_suppresscc_options"
                return
                ;;
 +      --get|--get-all|--unset|--unset-all)
 +              __gitcomp "$(__git_config_get_set_variables)"
 +              return
 +              ;;
        *.*)
                COMPREPLY=()
                return
                color.interactive.help
                color.interactive.prompt
                color.pager
 +              color.showbranch
                color.status
                color.status.added
                color.status.changed
@@@ -1856,7 -1821,6 +1856,7 @@@ _git_show_branch (
                __gitcomp "
                        --all --remotes --topo-order --current --more=
                        --list --independent --merge-base --no-name
 +                      --color --no-color
                        --sha1-name --sparse --topics --reflog
                        "
                return
diff --combined sha1_file.c
index e5dec8d3c8d783a8f90b700e633fe07e818df1f7,bd5edd8e657536e60fcb68d427df134c84f816c5..e73cd4fc0ba2daac14f604f1973d1b0658212b26
@@@ -720,6 -720,8 +720,8 @@@ static int open_packed_git_1(struct pac
                return error("packfile %s index unavailable", p->pack_name);
  
        p->pack_fd = open(p->pack_name, O_RDONLY);
+       while (p->pack_fd < 0 && errno == EMFILE && unuse_one_window(p, -1))
+               p->pack_fd = open(p->pack_name, O_RDONLY);
        if (p->pack_fd < 0 || fstat(p->pack_fd, &st))
                return -1;
  
@@@ -937,6 -939,8 +939,8 @@@ static void prepare_packed_git_one(cha
        sprintf(path, "%s/pack", objdir);
        len = strlen(path);
        dir = opendir(path);
+       while (!dir && errno == EMFILE && unuse_one_window(packed_git, -1))
+               dir = opendir(path);
        if (!dir) {
                if (errno != ENOENT)
                        error("unable to open object pack directory: %s: %s",
@@@ -2247,7 -2251,7 +2251,7 @@@ int move_temp_to_file(const char *tmpfi
                        goto out;
                ret = errno;
        }
 -      unlink(tmpfile);
 +      unlink_or_warn(tmpfile);
        if (ret) {
                if (ret != EEXIST) {
                        return error("unable to write sha1 filename %s: %s\n", filename, strerror(ret));
@@@ -2339,6 -2343,8 +2343,8 @@@ static int write_loose_object(const uns
  
        filename = sha1_file_name(sha1);
        fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
+       while (fd < 0 && errno == EMFILE && unuse_one_window(packed_git, -1))
+               fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
        if (fd < 0) {
                if (errno == EACCES)
                        return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());