]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/branch-track'
authorJunio C Hamano <gitster@pobox.com>
Wed, 27 Feb 2008 21:02:57 +0000 (13:02 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Feb 2008 21:02:57 +0000 (13:02 -0800)
* js/branch-track:
  doc: documentation update for the branch track changes
  branch: optionally setup branch.*.merge from upstream local branches

Conflicts:

Documentation/config.txt
Documentation/git-branch.txt
Documentation/git-checkout.txt
builtin-branch.c
cache.h
t/t7201-co.sh

1  2 
Documentation/config.txt
builtin-branch.c
builtin-checkout.c
cache.h
config.c
environment.c
t/t3200-branch.sh
t/t7201-co.sh

Simple merge
index 7e991030ca4def9e2be2f595809529e13a898c24,32eaf0d1e4e9fd8e5ca720852e9ae5ca122bdd44..a7844454a291d4ea1c126302d1f499497f35929a
@@@ -30,9 -30,7 +30,7 @@@ static const char * const builtin_branc
  static const char *head;
  static unsigned char head_sha1[20];
  
- static int branch_track = 1;
 -static int branch_use_color;
 +static int branch_use_color = -1;
  static char branch_colors[][COLOR_MAXLEN] = {
        "\033[m",       /* reset */
        "",             /* PLAIN (normal) */
@@@ -76,11 -72,7 +74,7 @@@ static int git_branch_config(const cha
                color_parse(value, var, branch_colors[slot]);
                return 0;
        }
-       if (!strcmp(var, "branch.autosetupmerge")) {
-               branch_track = git_config_bool(var, value);
-               return 0;
-       }
 -      return git_default_config(var, value);
 +      return git_color_default_config(var, value);
  }
  
  static const char *branch_get_color(enum color_branch ix)
@@@ -454,11 -448,7 +450,11 @@@ int cmd_branch(int argc, const char **a
        };
  
        git_config(git_branch_config);
-       track = branch_track;
 +
 +      if (branch_use_color == -1)
 +              branch_use_color = git_use_color_default;
 +
+       track = git_branch_track;
        argc = parse_options(argc, argv, options, builtin_branch_usage, 0);
        if (!!delete + !!rename + !!force_create > 1)
                usage_with_options(builtin_branch_usage, options);
Simple merge
diff --cc cache.h
index 9ebe7913b01aed7cbfa089ce811e57bbc64a6e15,0cd1368aef252b340f1855afd1090681772fdcd7..f16d341f5233b154c6fc1518ae0bd619c8f05c38
+++ b/cache.h
@@@ -417,14 -373,15 +417,23 @@@ extern size_t packed_git_limit
  extern size_t delta_base_cache_limit;
  extern int auto_crlf;
  
 +enum safe_crlf {
 +      SAFE_CRLF_FALSE = 0,
 +      SAFE_CRLF_FAIL = 1,
 +      SAFE_CRLF_WARN = 2,
 +};
 +
 +extern enum safe_crlf safe_crlf;
 +
+ enum branch_track {
+       BRANCH_TRACK_NEVER = 0,
+       BRANCH_TRACK_REMOTE,
+       BRANCH_TRACK_ALWAYS,
+       BRANCH_TRACK_EXPLICIT,
+ };
+ extern enum branch_track git_branch_track;
  #define GIT_REPO_VERSION 0
  extern int repository_format_version;
  extern int check_repository_format(void);
diff --cc config.c
Simple merge
diff --cc environment.c
index 3527f1663f3f948085ab56a81609ed9764b4e6e9,1f74b4b55703922a050da9f6c87bcd552b55b1e3..6739a3f41745fe1c01dc767e09af8746d6f2815f
@@@ -30,13 -30,13 +30,14 @@@ int core_compression_seen
  size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
  size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
  size_t delta_base_cache_limit = 16 * 1024 * 1024;
 -char *pager_program;
 +const char *pager_program;
  int pager_use_color = 1;
 -char *editor_program;
 -char *excludes_file;
 +const char *editor_program;
 +const char *excludes_file;
  int auto_crlf = 0;    /* 1: both ways, -1: only when adding git objects */
 +enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
  unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
+ enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
  
  /* This is set by setup_git_dir_gently() and/or git_default_config() */
  char *git_work_tree_cfg;
index d21081d0f19bc52e1f1da54c220bc30a026f1093,900d814627ae8ad2147d27965026df30193bcf7a..38a90adad6874d0073059da542835df210172938
@@@ -15,13 -15,15 +15,16 @@@ test_expect_success 
      'echo Hello > A &&
       git update-index --add A &&
       git-commit -m "Initial commit." &&
+      echo World >> A &&
+      git update-index --add A &&
+      git-commit -m "Second commit." &&
       HEAD=$(git rev-parse --verify HEAD)'
  
 -test_expect_failure \
 -    'git branch --help should not have created a bogus branch' \
 -    'git branch --help </dev/null >/dev/null 2>/dev/null || :
 -     test -f .git/refs/heads/--help'
 +test_expect_success \
 +    'git branch --help should not have created a bogus branch' '
 +     git branch --help </dev/null >/dev/null 2>/dev/null;
 +     ! test -f .git/refs/heads/--help
 +'
  
  test_expect_success \
      'git branch abc should create a branch' \
diff --cc t/t7201-co.sh
index 724adef0bfdc1f9028f112451c76d9053b60223f,17cff8d515656605a61f8097ada897854e355116..63915cd87b74aaddb943f45057bda10d283b4351
@@@ -279,38 -263,28 +279,62 @@@ test_expect_success 'checkout with ambi
  
  '
  
 +test_expect_success 'switch branches while in subdirectory' '
 +
 +      git reset --hard &&
 +      git checkout master &&
 +
 +      mkdir subs &&
 +      (
 +              cd subs &&
 +              git checkout side
 +      ) &&
 +      ! test -f subs/one &&
 +      rm -fr subs
 +
 +'
 +
 +test_expect_success 'checkout specific path while in subdirectory' '
 +
 +      git reset --hard &&
 +      git checkout side &&
 +      mkdir subs &&
 +      >subs/bero &&
 +      git add subs/bero &&
 +      git commit -m "add subs/bero" &&
 +
 +      git checkout master &&
 +      mkdir -p subs &&
 +      (
 +              cd subs &&
 +              git checkout side -- bero
 +      ) &&
 +      test -f subs/bero
 +
 +'
 +
+ test_expect_success \
+     'checkout w/--track sets up tracking' '
+     git config branch.autosetupmerge false &&
+     git checkout master &&
+     git checkout --track -b track1 &&
+     test "$(git config branch.track1.remote)" &&
+     test "$(git config branch.track1.merge)"'
+ test_expect_success \
+     'checkout w/autosetupmerge=always sets up tracking' '
+     git config branch.autosetupmerge always &&
+     git checkout master &&
+     git checkout -b track2 &&
+     test "$(git config branch.track2.remote)" &&
+     test "$(git config branch.track2.merge)"
+     git config branch.autosetupmerge false'
+ test_expect_success \
+     'checkout w/--track from non-branch HEAD fails' '
+     git checkout -b delete-me master &&
+     rm .git/refs/heads/delete-me &&
+     test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
+     !(git checkout --track -b track)'
  test_done