Merge branch 'jk/branch-l-0-deprecation'
The "-l" option in "git branch -l" is an unfortunate short-hand for "--create-reflog", but many users, both old and new, somehow expect it to be something else, perhaps "--list". This step warns when "-l" is used as a short-hand for "--create-reflog" and warns about the future repurposing of the it when it is used. * jk/branch-l-0-deprecation: branch: deprecate "-l" option t: switch "branch -l" to "branch --create-reflog" t3200: unset core.logallrefupdates when testing reflog creation
This commit is contained in:
commit
d18602f412
@ -91,7 +91,6 @@ OPTIONS
|
||||
-D::
|
||||
Shortcut for `--delete --force`.
|
||||
|
||||
-l::
|
||||
--create-reflog::
|
||||
Create the branch's reflog. This activates recording of
|
||||
all changes made to the branch ref, enabling use of date
|
||||
@ -101,6 +100,8 @@ OPTIONS
|
||||
The negated form `--no-create-reflog` only overrides an earlier
|
||||
`--create-reflog`, but currently does not negate the setting of
|
||||
`core.logAllRefUpdates`.
|
||||
+
|
||||
The `-l` option is a deprecated synonym for `--create-reflog`.
|
||||
|
||||
-f::
|
||||
--force::
|
||||
|
@ -37,6 +37,7 @@ static const char * const builtin_branch_usage[] = {
|
||||
|
||||
static const char *head;
|
||||
static struct object_id head_oid;
|
||||
static int used_deprecated_reflog_option;
|
||||
|
||||
static int branch_use_color = -1;
|
||||
static char branch_colors[][COLOR_MAXLEN] = {
|
||||
@ -568,6 +569,14 @@ static int edit_branch_description(const char *branch_name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int deprecated_reflog_option_cb(const struct option *opt,
|
||||
const char *arg, int unset)
|
||||
{
|
||||
used_deprecated_reflog_option = 1;
|
||||
*(int *)opt->value = !unset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_branch(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int delete = 0, rename = 0, copy = 0, force = 0, list = 0;
|
||||
@ -610,7 +619,13 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
|
||||
OPT_BIT('c', "copy", ©, N_("copy a branch and its reflog"), 1),
|
||||
OPT_BIT('C', NULL, ©, N_("copy a branch, even if target exists"), 2),
|
||||
OPT_BOOL(0, "list", &list, N_("list branch names")),
|
||||
OPT_BOOL('l', "create-reflog", &reflog, N_("create the branch's reflog")),
|
||||
OPT_BOOL(0, "create-reflog", &reflog, N_("create the branch's reflog")),
|
||||
{
|
||||
OPTION_CALLBACK, 'l', NULL, &reflog, NULL,
|
||||
N_("deprecated synonym for --create-reflog"),
|
||||
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN,
|
||||
deprecated_reflog_option_cb
|
||||
},
|
||||
OPT_BOOL(0, "edit-description", &edit_description,
|
||||
N_("edit the description for the branch")),
|
||||
OPT__FORCE(&force, N_("force creation, move/rename, deletion"), PARSE_OPT_NOCOMPLETE),
|
||||
@ -683,6 +698,11 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
|
||||
if (list)
|
||||
setup_auto_pager("branch", 1);
|
||||
|
||||
if (used_deprecated_reflog_option && !list) {
|
||||
warning("the '-l' alias for '--create-reflog' is deprecated;");
|
||||
warning("it will be removed in a future version of Git");
|
||||
}
|
||||
|
||||
if (delete) {
|
||||
if (!argc)
|
||||
die(_("branch name required"));
|
||||
|
@ -339,8 +339,8 @@ test_expect_failure 'reflog with non-commit entries displays all entries' '
|
||||
'
|
||||
|
||||
test_expect_success 'reflog expire operates on symref not referrent' '
|
||||
git branch -l the_symref &&
|
||||
git branch -l referrent &&
|
||||
git branch --create-reflog the_symref &&
|
||||
git branch --create-reflog referrent &&
|
||||
git update-ref referrent HEAD &&
|
||||
git symbolic-ref refs/heads/the_symref refs/heads/referrent &&
|
||||
test_when_finished "rm -f .git/refs/heads/referrent.lock" &&
|
||||
|
@ -49,9 +49,9 @@ test_expect_success 'git branch HEAD should fail' '
|
||||
cat >expect <<EOF
|
||||
$ZERO_OID $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 branch: Created from master
|
||||
EOF
|
||||
test_expect_success 'git branch -l d/e/f should create a branch and a log' '
|
||||
test_expect_success 'git branch --create-reflog d/e/f should create a branch and a log' '
|
||||
GIT_COMMITTER_DATE="2005-05-26 23:30" \
|
||||
git branch -l d/e/f &&
|
||||
git -c core.logallrefupdates=false branch --create-reflog d/e/f &&
|
||||
test_path_is_file .git/refs/heads/d/e/f &&
|
||||
test_path_is_file .git/logs/refs/heads/d/e/f &&
|
||||
test_cmp expect .git/logs/refs/heads/d/e/f
|
||||
@ -82,7 +82,7 @@ test_expect_success 'git branch -m dumps usage' '
|
||||
|
||||
test_expect_success 'git branch -m m broken_symref should work' '
|
||||
test_when_finished "git branch -D broken_symref" &&
|
||||
git branch -l m &&
|
||||
git branch --create-reflog m &&
|
||||
git symbolic-ref refs/heads/broken_symref refs/heads/i_am_broken &&
|
||||
git branch -m m broken_symref &&
|
||||
git reflog exists refs/heads/broken_symref &&
|
||||
@ -90,13 +90,13 @@ test_expect_success 'git branch -m m broken_symref should work' '
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -m m m/m should work' '
|
||||
git branch -l m &&
|
||||
git branch --create-reflog m &&
|
||||
git branch -m m m/m &&
|
||||
git reflog exists refs/heads/m/m
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -m n/n n should work' '
|
||||
git branch -l n/n &&
|
||||
git branch --create-reflog n/n &&
|
||||
git branch -m n/n n &&
|
||||
git reflog exists refs/heads/n
|
||||
'
|
||||
@ -378,9 +378,9 @@ mv .git/config-saved .git/config
|
||||
git config branch.s/s.dummy Hello
|
||||
|
||||
test_expect_success 'git branch -m s/s s should work when s/t is deleted' '
|
||||
git branch -l s/s &&
|
||||
git branch --create-reflog s/s &&
|
||||
git reflog exists refs/heads/s/s &&
|
||||
git branch -l s/t &&
|
||||
git branch --create-reflog s/t &&
|
||||
git reflog exists refs/heads/s/t &&
|
||||
git branch -d s/t &&
|
||||
git branch -m s/s s &&
|
||||
@ -444,7 +444,7 @@ test_expect_success 'git branch --copy dumps usage' '
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -c d e should work' '
|
||||
git branch -l d &&
|
||||
git branch --create-reflog d &&
|
||||
git reflog exists refs/heads/d &&
|
||||
git config branch.d.dummy Hello &&
|
||||
git branch -c d e &&
|
||||
@ -459,7 +459,7 @@ test_expect_success 'git branch -c d e should work' '
|
||||
'
|
||||
|
||||
test_expect_success 'git branch --copy is a synonym for -c' '
|
||||
git branch -l copy &&
|
||||
git branch --create-reflog copy &&
|
||||
git reflog exists refs/heads/copy &&
|
||||
git config branch.copy.dummy Hello &&
|
||||
git branch --copy copy copy-to &&
|
||||
@ -486,7 +486,7 @@ test_expect_success 'git branch -c ee ef should copy ee to create branch ef' '
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -c f/f g/g should work' '
|
||||
git branch -l f/f &&
|
||||
git branch --create-reflog f/f &&
|
||||
git reflog exists refs/heads/f/f &&
|
||||
git config branch.f/f.dummy Hello &&
|
||||
git branch -c f/f g/g &&
|
||||
@ -497,7 +497,7 @@ test_expect_success 'git branch -c f/f g/g should work' '
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -c m2 m2 should work' '
|
||||
git branch -l m2 &&
|
||||
git branch --create-reflog m2 &&
|
||||
git reflog exists refs/heads/m2 &&
|
||||
git config branch.m2.dummy Hello &&
|
||||
git branch -c m2 m2 &&
|
||||
@ -506,18 +506,18 @@ test_expect_success 'git branch -c m2 m2 should work' '
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -c zz zz/zz should fail' '
|
||||
git branch -l zz &&
|
||||
git branch --create-reflog zz &&
|
||||
git reflog exists refs/heads/zz &&
|
||||
test_must_fail git branch -c zz zz/zz
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -c b/b b should fail' '
|
||||
git branch -l b/b &&
|
||||
git branch --create-reflog b/b &&
|
||||
test_must_fail git branch -c b/b b
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -C o/q o/p should work when o/p exists' '
|
||||
git branch -l o/q &&
|
||||
git branch --create-reflog o/q &&
|
||||
git reflog exists refs/heads/o/q &&
|
||||
git reflog exists refs/heads/o/p &&
|
||||
git branch -C o/q o/p
|
||||
@ -570,10 +570,10 @@ test_expect_success 'git branch -C master5 master5 should work when master is ch
|
||||
'
|
||||
|
||||
test_expect_success 'git branch -C ab cd should overwrite existing config for cd' '
|
||||
git branch -l cd &&
|
||||
git branch --create-reflog cd &&
|
||||
git reflog exists refs/heads/cd &&
|
||||
git config branch.cd.dummy CD &&
|
||||
git branch -l ab &&
|
||||
git branch --create-reflog ab &&
|
||||
git reflog exists refs/heads/ab &&
|
||||
git config branch.ab.dummy AB &&
|
||||
git branch -C ab cd &&
|
||||
@ -685,7 +685,7 @@ test_expect_success 'renaming a symref is not allowed' '
|
||||
'
|
||||
|
||||
test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
|
||||
git branch -l u &&
|
||||
git branch --create-reflog u &&
|
||||
mv .git/logs/refs/heads/u real-u &&
|
||||
ln -s real-u .git/logs/refs/heads/u &&
|
||||
test_must_fail git branch -m u v
|
||||
|
Loading…
Reference in New Issue
Block a user